please dont rip this site

Spatial Transformation Matrix Math Methods

Affine spatial transformation matrices are used to represent the orientation and position of a coordinate system within a 3 dimensional "world" coordinate system. Spatial transformation matrices can be used to map from one to another. They are often used in Kinematics.

Any combination of translation, rotation, scaling, reflection and shear can be represented by a single 4 by 4 affine transformation matrix:

A =
a11 a12 a13 x
a21 a22 a23 y
a31 a32 a33 z
0 0 0 1

This matrix A can be used to transform any point / vector p to a new point / vector p'.

DCM (Direction Cosine Matrix): The upper left 3x3 area is the rotation / orientation / scale / shear sub-section. It is made of 3 sections:

Position: The upper right area translates position.

The 4th row is always [0, 0, 0, 1] to maintain transformation matrix format.

To apply the transformation, simply enter the desired values for the type of transformation (see below) and apply matrix math multiplication to the original point as a vector of x, y, z, and 1.

p' = Ap

Multiple translations can be applied sequentially, or can be merged into a single matrix operation by multiplying all the transformation matrixes together. Remember that unlike normal math, in matrix multiplication the order matters, and as applied here, this maintains the order of transformations.


A =
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

Where x, y, and z are the desired translation in each direction.


A =
Sx 0 0 0
0 Sy 0 0
0 0 Sz 0
0 0 0 1

Where Sx, Sy, and Sz are the desired scaling factor in each dimension. Note that if you want to scale in all three axis by the same amount, you can just change the lower right "1" to factor and leave Sx, Sy, Sz as 1.


Where theta O is the desired rotation in radians around the given axis. These can be combined, by multiplying all three matrix together, and separate the "thetas" to three different variables:

Rotation about X

A =
1   0 0 0
0   cos(O) sin(O) 0
0   -sin(O) cos(O) 0
0   0 0 1

Rotation about Y

A =
cos(O 0   -sin(O) 0
0   1   0 0
sin(O 0   cos(O) 0
0   0   0 1

Rotation about Z

A =
cos(O -sin(O   0 0
sin(O)   cos(O)   0 0
0   0     1 0
0   0     0 1

Note that these are "right handed" rotations. Positive angles of O cause counter-clockwise rotation about an axis as seen from a point on the positive side of the axis looking in toward the origin.

These three transformations (in X, Y, and Z) can, theoretically, be applied in sequence to reach any orientation. This uses a set of three angles, which are referred to as Euler Angles.

Note that if you apply a rotation of 1/4 of a full turn around, for example, the X axis, then you have effectively aligned the other two axis, Y and Z, with each other. If you then apply any rotation around, for example, the Z axis, that would be exactly the same as rotation around the Y axes. This removes a degree of freedom from any further transformations, and is called "gimbal lock" which is one type of singularity. It is a limitation of Euler Angles.

To avoid this limitation, a better system for rotations in multiple axis can be developed by using Quaternions. These are 4 dimensional values where the extra dimensions are akin to complex numbers. Where a complex number has one real and one imaginary part, a quaternion has a vector component and 4 imaginary parts, called i, j, and k.

qw + i qx + j qy + k qz.

A quaternion holds the angles in the real and imaginary parts. Because they are all combined, any rotation around a combination of axis can be described. Quaternions can be converted into 3x3 rotational matrixes.

See also:

file: /Techref/method/math/spatial-transformations.htm, 15KB, , updated: 2023/11/8 20:17, local time: 2024/7/25 09:42,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> Spatial Transformation Matrix Math Methods</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!