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?
Let
glRotate(a, axX, axY, axZ)
glTranslat(x, y, z)
how can I calculate the center C?
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:- “Matrix and Quaternion FAQ” 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.