PDA

View Full Version : how to roam on a sphere

ruixp
12-18-2001, 04: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 ??

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

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

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

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

rixed
12-19-2001, 08: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)
}

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).]

ruixp
12-20-2001, 02:55 AM
3x,rixed:
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

harsman
12-20-2001, 03: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.