Mirror_Mirror 122 Report post Posted May 14, 2008 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. 0 Share this post Link to post Share on other sites
phil126 199 Report post Posted May 14, 2008 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. 0 Share this post Link to post Share on other sites
arithma 226 Report post Posted May 14, 2008 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 methodCheers 0 Share this post Link to post Share on other sites
Mirror_Mirror 122 Report post Posted May 21, 2008 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 ).thank you for your replynow 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. 0 Share this post Link to post Share on other sites