Added maths functions, fixed compiler errors, completed ray-sphere intersection function