# Math Help - moving on sphere

1. ## moving on sphere

Hi guys. I'm trying to simulate ( with a computer program ) the movement of an object on a sphere. The data are as this : The sphere has a radius R and it's center is at (0,0,0). There is an object at point P(x0,y0,z0) or in polar coordinates defined as P(phi,theta). The object can rotate around it's own axis ( at the tangent plane of the sphere in the point (x0,y0,z0) and it can move by a distance "dist" along the great circle ( geodesic ) defined by the point P and the direction of the rotation around its axis. My problem is to define the equations that govern this type of movement.

What i have done till now is this :

i defined an angle called "chi" which is the direction the object is "looking at", the rotation around its axis. i also have a "unit" vector which let's say vec=(0,0,1) which gets added to the P thus producing the new point P1. I have the rotation matrix of a point around an axis and this is fine. The problem is each time the object moves, "vec" must rotate appropriately so that it is perpendicular to the vector P. Any help would be appreciated.

2. Originally Posted by Mirror
... the movement of an object on a sphere. The data are as this : The sphere has a radius R and it's center is at (0,0,0)....

What i have done till now is this :

i defined an angle called "chi" which is the direction the object is "looking at", the rotation around its axis. i also have a "unit" vector which let's say vec=(0,0,1) which gets added to the P thus producing the new point P1. I have the rotation matrix of a point around an axis and this is fine. The problem is each time the object moves, "vec" must rotate appropriately so that it is perpendicular to the vector P. Any help would be appreciated.

1. With your unit vector the object leaves the surface of the sphere.

2. All vectors which describe the direction the object is "looking at" form a plane (the tangent plane at P with the vector $\overrightarrow{OP}$ as it's normal vector. Let $\vec q$ be the stationary vector pointing at an arbitrary point in the tangent plane and let $\vec p$ be the staionary vector pointing at P and since you know the coordinates of P the equation of the tangent plane in P would be:

$\overrightarrow{OP} \cdot (\vec q - \vec p)=0~\implies~\vec p \cdot \vec q - (\vec p)^2=0$ and $|\vec p| = R$

3. Originally Posted by earboth
1. With your unit vector the object leaves the surface of the sphere.
i forgot to mention that i normalize the new vector and then multiply it by R so it doesn't leave the sphere.

Originally Posted by earboth
1. With your unit vector the object leaves the
2. All vectors which describe the direction the object is "looking at" form a plane (the tangent plane at P with the vector $\overrightarrow{OP}$ as it's normal vector. Let $\vec q$ be the stationary vector pointing at an arbitrary point in the tangent plane and let $\vec p$ be the staionary vector pointing at P and since you know the coordinates of P the equation of the tangent plane in P would be:

$\overrightarrow{OP} \cdot (\vec q - \vec p)=0~\implies~\vec p \cdot \vec q - (\vec p)^2=0$ and $|\vec p| = R$
i solved the problem by using the binormal ( crossproduct of the OP and OV ) and rotating the OV along the OB ( binormal vector ).

now my problem is this :

i need to have the object appear rotated properly ( not upside down for example as he goes down ) and him rotating around itself ( looking at direction ). the only tool i have to do this is a function SetRotation(a,b,c), which rotates the object by 'a' degrees along the X axis, by 'b' degrees along the Y axis and by 'c' degrees along the Z axis IN THE POSITION that it currently is. any way to accomplish this ? the available data is the point's position in a vector format or it's position in polar coordinated ( theta,phi) and also the angle 'chi' of the rotation ( where the object looks ) in the tangent plane.

for example if OP=(0,100,0) and the object is facing the screen, when we apply a SetRotation(90,0,0), OP will still be (0,100,0) but the object will be lying down, facing up.