Rotation Matrix


I have a 3D object.

I would like to perform a 3D rotation about its COM (centre of mass), in terms of theta and phi. Not about the axes. I did have a piece of code to do this, but have lost the official reference for where I saw this worked out in more detail. I know it was a coupled combination of a rotation by theta and then phi for example.

The problem is I have implemented code that I wrote 2.5 years ago and cannot find my reference to how I actually performed the COM part. Its quite involved and I suspect it involves rotating the co-ordinate axes. I am rather embarrassed because I cannot remember the reference… “Let this be a lesson to you all”. I now my code words and use it, but cannot remember how I came by it in the first place and now hoping if you guys might know.


If you want to rotate around a certain point p, use following matrix translate(-p).rotate®.translate§

I’m guessing you meant to write translate§.rotate®.translate(-p) :wink:

You’re right… I can never remember if OpenGL does premultiplication or postmultiplication. It’s been years since I actually wrote something :slight_smile:

I must confess that I am using the routines for some programming outside out OpenGL, so unfortunately need to be able to use it independent of the opengl routines…

Any reference to how this is done by hand would be appreciated!


The matrix operations are explained in the specs, e.g. glRotate and glTranslate