 # Spatial Transformation MatrixMathMethods

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:

• X unit vector: The first, leftmost, column [a11, a21, a31] is a unit vector representing the change relative to the X axis.
• Y unit vector: The 2nd, center, column [a12, a22, a32] represents change from the Y axis. For example, if it is [0,0,-1] then we have rotated straight down, because a32 is the z component of the y unit vector.
• Z unit vector: The 3rd, rightmost, column [a13, a23, a33] is the Z component.

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.

## Translation

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.

## Scaling

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.

## Rotation

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:

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

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

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.

 file: /Techref/method/math/spatial-transformations.htm, 14KB, , updated: 2022/6/20 14:21, local time: 2023/2/7 04:21, TOP NEW HELP FIND:  44.192.247.184:LOG IN

 ©2023 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! Spatial Transformation Matrix Math Methods

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.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant"

.