View Full Version : how to roam on a sphere

12-18-2001, 03:09 AM
two location cordinates on the sphere already available ,i want to know how to roam along the big circle between these two point ,who will help me ??

12-18-2001, 06:13 AM
There is something called 'Quaternions' which should help, but I can't help you using it.

12-18-2001, 06:45 AM
Do you know the radius of the sphere?

12-18-2001, 08:58 AM
The circle can also be determined with a 3rd point that is also on the circle.

12-19-2001, 02:28 AM
yes ,i know the sphere's radius,just as R
and the sphere's center is origin

12-19-2001, 07:33 AM
Lets call A and B the two locations, and O the center of the sphere, and N the normal at A.
What you need is probably the coordinates of n points between A and B on the sphere.
So why don't you simply do this (pseudocode) ? :

for (i=0; i<n; i++) {
C[i][3] = A[3] + (i*(B[3]-A[3])/n)
C[i][3] *= sphereRadius/length(C[i][3]);

then you have n vector C that's between A and B and on the sphere.

(note, the trick do not work when A and B are not close, and in general the C[i] are not exactly equidistants)

is it enough ?

[This message has been edited by rixed (edited 12-19-2001).]

12-20-2001, 01:55 AM
i use the method just as u said ,and when A and B are not so close ,it will work well,the eye cordinates maybe IN the sphere

is there any more good method

12-20-2001, 02:53 AM
Take the cross product of the two points on the sphere (treated as vectors starting at the sphere's origin) and use the resultant Vector as an axis to rotate around. For a full interpolation (i.e completely at one point) rotate pointA dot pointB angles. Or you could lerp spherical coordinates, but I'm not sure that would work.