# moving on a sphere

This topic is 3708 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys. i'm trying to make an object moving on a sphere, by a constant distance. so my problem is this : There is a sphere of radius R and center (0,0,0). There is one object on the sphere, its location defined by polar coordinates to be : phi0,thi0 ( longitude, latitude) or by it's cartesian coordinates (x0,y0,z0). This object can rotate around it's axis [ the (0,0,0)-(x0,y0,z0) axis ] and we call this angle chi. The object can move a distance equal to 'dis' [ the chord is equal to 'dis'] along the meridian which is defined by the point on the sphere and the angle chi. What i need is the formulas phi=f(phi0,thi0,chi,a,R,x0,y0,z0), thi=g(phi0,thi0,chi,a,R,x0,y0,z0). As an example and for simplicity reasons, let's have a sphere with center (0,0,0) and with a perimeter of 360 ( so that 1 degree equals to 1 meter ). An object is somewhere on this sphere and can move a distance equal to 1. So, depending on the angle chi that the object is rotated around it's own axis [ 0,0,0-x0,y0,z0 ] it will move one degree each time at the specific direction ( chi ). i've tried using a thi -= cos(chi), phi += sin(chi) but doesn't seem to solve it. anyone has has any ideas ? Thank you in advance.

##### Share on other sites
I personally would convert to a spherical coordinate system.
http://mathworld.wolfram.com/SphericalCoordinates.html
That way you only do the conversion to x,y,z once. Every thing else can be done in r,phee,and z.

##### Share on other sites
The chi angle is ill-defined and is the cause of you troubles.
I would suggest using a tangent vector instead. To move you just add the tangent to the position, then you'd just re-normalize the position (which is a vector as well).
If you want to go with a better method, if you're mathematically comfortable, you can build a rotation matrix from the position/tangent and apply that to both the position and tangent vectors. To rotate around the body's axis, you need to rotate the tangent as well.
Both methods use more memory than is necessary but the sphere is usually weird to work with and the added memory usage allows a much more elegant method

Cheers

##### Share on other sites
i solved the problem according to your suggestion about adding a tangent vector to the position vector. the solution also required the binormal ( for rotating the unit tangent vector ).

now my problem is this :

i need to have the object appear rotated properly ( not upside down for example as it goes down ) and it rotating around itself ( looking at direction ). the only tool i have to do this is a function object->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. is there 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 PV=(0,100,0) (position vector ) and the object is facing the screen, when we apply a SetRotation(90,0,0) PV will still be (0,100,0) but the object will be lying down, facing up.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 37
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631705
• Total Posts
3001827
×