logo back up home forward   further reading more topics »

Maths - Calculation of Matrix for 3D Rotation about a point

Abstract

On this page we will show that a rotation, about any point, is equivalent to a rotation (by the same angles) about the origin combined with a linear translation. We already have lots of methods for calculating a rotation about the origin (such as matrices and quaternions) so to rotate about any point, other than the origin, we do the rotation as if it was around the origin then apply a linear transform to get the same result.

This applies to both two and three dimensional transforms.

We will then go on to show that, in two dimensions only, that the converse is also true. That is any combination of translation and rotation can be represented by a single rotation provided that we choose the correct point to rotate it around.

Prerequisites

If you are not familiar with this subject you may like to look at the following pages first:

Combined Rotation and Translation

In order to calculate the rotation about any arbitrary point we need to calculate its new rotation and translation. In other words rotation about a point is an 'proper' isometry transformation' which means that it has a linear and a rotational component.

Assume we have a matrix [R0] which defines a rotation about the origin:

We now want to apply this same rotation but about an arbitrary point P:

As we can see its orientation is the same as if it had been rotated about the origin, but it has been translated to a different point on space by the rotation.

In order to prove this and to calculate the amount of linear translation we need to replace:

With the following 3 simpler transforms which, when done in order, are equivalent:

So if we are using the global frame-of-reference (as explained here) then,

[resulting transform] = [third transform] * [second transform] * [first rotation]

[resulting transform] = [+Px,+Py,+Pz] * [rotation] * [-Px,-Py,-Pz]

Note for matrix algebra, the order of operations is important, so these translations do not cancel out.

So matrix representing rotation about a given point is:

[R] = [T]-1 * [R0] * [T]

where:

[T]-1 = inverse transform = translation of point to origin

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

[R0] = rotation about origin (if this is not clear see this discussion)

r00 r01 r02 0
r10 r11 r12 0
r20 r21 r22 0
0 0 0 1

[T] = translation of origin to point

1 0 0 -x
0 1 0 -y
0 0 1 -z
0 0 0 1

 

when these matrices are multiplied this will give the following result for rotation about x,y:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
*
r00 r01 r02 0
r10 r11 r12 0
r20 r21 r22 0
0 0 0 1
*
1 0 0 -x
0 1 0 -y
0 0 1 -z
0 0 0 1

 

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
*
r00 r01 r02 -r00*x - r01*y - r02*z
r10 r11 r12 -r10*x - r11*y - r12*z
r20 r21 r22 -r20*x - r21*y - r22*z
0 0 0 1

 

r00 r01 r02 x - r00*x - r01*y - r02*z
r10 r11 r12 y - r10*x - r11*y - r12*z
r20 r21 r22 z - r20*x - r21*y - r22*z
0 0 0 1

So the rotational components are the same but the rotation moves the position of the centre.


Further Reading

You may be interested in other means to represent orientation and rotational quantities such as:

Or you may be interested in how these quantities are used to simulate physical objects:


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover 3D Math Primer - Aimed at complete beginners to vector and matrix algebra.

Other Math Books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

Can you help?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

http://sourceforge.net/projects/mjbworld/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.