I apologize if this argument is not advanced…
I want to retrieve the center of a sphere after a rotation and a translation.
I know that if I use only a translation, the center is exactly the coordinate of the traslation, but if I rotate before then the local coordinate system of the sphere is not more aligned with the global coordinate system, and I don’t know how to retrieve the right coordinates.
I know, I have to study trigonometry… but in the meantime, anyone can helps me?
glRotate(a, axX, axY, axZ)
glTranslat(x, y, z)
how can I calculate the center C?
Thank you everyone and Merry Christmas!
Search for rotation matrix on the internet or better yet, general rotation matrix.
The Red Book shows you how transformation works.
It’s really not hard to find info like this on the internet.
Mmm, the thing is you’re going to have get hold of that matrix you’re manipulating. You can do this using glGetFloatv, or actually doing all this matrix maths on your own matrix in system memory, then uploading it to GL with glLoadMatrix (recommended approach)…or doing the maths twice by mirroring your gl calls with your own maths, but that’s insane).
If you do the matrix maths yourself (which is pretty easy, just go here:- “http://www.flipcode.com/documents/matrfaq.html” and copy and paste, if you can’t be arsed understanding whats going on).
Eventually, you’ll want to transform your translation by the rotation matrix you create with your glRotate.
Merry thingagum to you
//insert fancy matrix*vector calc here
Ho, ho, ho
[This message has been edited by zeckensack (edited 12-24-2002).]
FESTIVUS FOR THE RESTOFUS!!
Originally posted by zeckensack:
Ho, ho, ho
Ho ho ho indeed. How terribly efficient.