Um...
Actually, having said that, I'm lost again.
I need to find the angle between normal (which is the cartesian coodinates of the point on the surface of the sphere, normalized) and the current y axis (which is just (0, 1, 0), yes?) by taking the inverse cosine of the dot product of these two vectors.
OK, got that bit; in my code it looks like this:
****************************
ASEVector3f pos, rot, normal;
planet->GetSurfaceCoordinates(z, phi, &pos); // z and phi here are essentially my current latitude and longitude - this puts a cartesian coordinate on the surface of the sphere into pos
// Find angle between normal and current y-axis
normal = pos;
normal.Normalize();
ASEVector3f yAxis(0, 1.0f, 0);
double angle = acos(normal.DotProduct(yAxis));
****************************
quote:
And the axis of rotation is simply the cross-product of the y axis and the normal.
- OK, no worries...
****************************
// Find axis of rotation
ASEVector3f axisRotation = yAxis.CrossProduct(normal);
****************************
quote:
Can't you use a quaternion or a matrix to find the correct rotation using theta and the axis of rotation?
- No, I don't know how to

If I do figure out how to do it with a matrix (off to Google again) will this result in values for rotation.x, rotation.y and rotation.z that I can use when the object comes to set it's position by doing the following?
****************************
// Camera transformations...
glLoadIdentity();
glTranslatef(0, 0, -distance);
glRotated(elevation, 1, 0, 0);
glRotated(azimuth, 0, 0, 1);
// Object transformations...
// (for each object)
glPushMatrix();
glTranslatef (position.x, position.y, position.z);
glRotatef(rotation.x, 1.0f, 0.0f, 0.0f);
glRotatef(rotation.y, 0.0f, 1.0f, 0.0f);
glRotatef(rotation.z, 0.0f, 0.0f, 1.0f);
// (draw object)
glPopMatrix();
// (next)
****************************
Hmmm.. Should I be asking in the OpenGL forum instead? Apologies if in the wrong place...
Brgrds,
I.
www.coldcity.comcode, pics, life
[edited by - IainC on February 23, 2003 9:16:39 AM][edited by - IainC on February 23, 2003 9:17:51 AM]