SLIDE 3D Transformation Notes
Contents
Transformations in 3D
Type |
Column Vector Matrix |
Row Vector Matrix |
Properties |
Translation
translate (tx ty tz)
|
|
|
Rigid Body
Orthogonal Submatrix
|
Scale
scale (sx sy sy)
|
|
|
Non-rigid Body
|
Rotation around X
rotate (1 0 0) (a)
|
1 | 0 | 0 | 0 |
0 | cos(a) | -sin(a) | 0 |
0 | sin(a) | cos(a) | 0 |
0 | 0 | 0 | 1 |
|
1 | 0 | 0 | 0 |
0 | cos(a) | sin(a) | 0 |
0 | -sin(a) | cos(a) | 0 |
0 | 0 | 0 | 1 |
|
Rigid Body
Orthogonal
|
Rotation around Y
rotate (0 1 0) (a)
|
cos(a) | 0 | sin(a) | 0 |
0 | 1 | 0 | 0 |
-sin(a) | 0 | cos(a) | 0 |
0 | 0 | 0 | 1 |
|
cos(a) | 0 | -sin(a) | 0 |
0 | 1 | 0 | 0 |
sin(a) | 0 | cos(a) | 0 |
0 | 0 | 0 | 1 |
|
Rigid Body
Orthogonal
|
Rotation around Z
rotate (0 0 1) (a)
|
cos(a) | -sin(a) | 0 | 0 |
sin(a) | cos(a) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
cos(a) | sin(a) | 0 | 0 |
-sin(a) | cos(a) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
Rigid Body
Orthogonal
|
Rotation around an Unit Axis
rotate (x y z) (a)
|
w = [x, y, z, 0]
W = CrossProduct(w)
R = I + W sin(a) + W2 (1 - cos(a))
|
w = [x, y, z, 0]
W = CrossProduct(w)
R = I + W sin(a) + W2 (1 - cos(a))
|
Rigid Body
Orthogonal
|
Create Cross Product Matrix
w is a unit vector
W = CrossProduct(w )
b = w * a = W a
|
0 | -wz | wy | | 0 |
wz | 0 | -wx | 0 |
-wy | wx | 0 | 0 |
0 | 0 | 0 | 0 |
|
0 | wz | -wy | | 0 |
-wz | 0 | wx | 0 |
wy | -wx | 0 | 0 |
0 | 0 | 0 | 0 |
|
Skew Symmetric
W3 = -W
|
Shear XY
[x, y, z, 1] =>
[x + shx*z, y + shy*z, z, 1]
|
|
|
Non-rigid Body
|
Shear XZ
[x, y, z, 1] =>
[x + shx*y, y, z + shz*y, 1]
|
|
|
Non-rigid Body
|
Shear YZ
[x, y, z, 1] =>
[x, y + shy*x, z + shz*x, 1]
|
|
|
Non-rigid Body
|
Change of Basis
Compute GA<-B or GB->A
Given BOA, BXA, BYA, and BZA
(the origin and orthonormal basis vectors of the B coordinate system expressed
with respect to A's coordinate system)
|
BXAx | BYAx | BZAx | BOAx |
BXAy | BYAy | BZAy | BOAy |
BXAz | BYAz | BZAz | BOAz |
0 | 0 | 0 | 1 |
|
BXAx | BXAy | BXAz | 0 |
BYAx | BYAy | BYAz | 0 |
BZAx | BZAy | BZAz | 0 |
BOAx | BOAy | BOAz | 1 |
|
Rigid Body
|
The standard camera placement transformation is represented in
SLIDE by the
lookat
transformation.
Although the most common use for this transformation is to place a
camera at one point in space looking at another point in space,
it can also be used to place any object or light in the scene.
The lookat transformation is particularly useful for pointing a
spotlight at something in the scene.
The lookat transformation specifies a new coordinate system,
(u,v,n) within the current system by
- the origin of the new system (eye),
- a point that will lie on the -n-axis (vrp),
- and an up vector that should project onto the v-axis in the
uv-plane (up).
In order to compute the transformation matrix for the lookat
transform, we must first find the orthonormal coordinate axes
(u,v,n) and the origin c.
- c = eye
- n = c - vrp / |c - vrp|
- u = up x n / |up x n|
- v = n x u
If the up vector is parallel to the vector between the
eye and the vrp, then the u and v axes
will be degenerate. In this case, do whatever you like with
u and v, so long as (u,v,n) is orthonormal, since
the operation is not well defined.
Now that we have the necessary information: the origin, c, and
the coordinate axes, (u,v,n), we can compute the lookat
transformation, Qlookat.
The matrix, Qlookat, will transform points in the
camera's or object's system into the world system just like any other
modeling transform.
Let's call
puvn=(pu pv pn)
and
pxyz=(px py pz)
pxyz=Qlookatpuvn
pxyz=
c +
(puu + pvv + pnn)
pxyz
= T(c) Qxyz<-uvn puvn
= T(c)
|
ux | vx | nx | 0 |
uy | vy | ny | 0 |
uz | vz | nz | 0 |
0 | 0 | 0 | 1 |
|
|
|
Note that Qxyz<-uvn is an orthogonal matrix
(Qxyz<-uvn-1=Qxyz<-uvnT).
So it is easy to find
Quvn<-xyz=Qxyz<-uvn-1.
so we get
Qlookat
= T(c) Qxyz<-uvn
where
Qxyz<-uvn =
|
ux | vx | nx | 0 |
uy | vy | ny | 0 |
uz | vz | nz | 0 |
0 | 0 | 0 | 1 |
|
|
and Quvn<-xyz =
|
ux | uy | uz | 0 |
vx | vy | vz | 0 |
nx | ny | nz | 0 |
0 | 0 | 0 | 1 |
|
|
We also need to find Qlookat-1, which we
can do in a straightforward fashion:
Qlookat-1
= (T(c)
Qxyz<-uvn)-1
= Qxyz<-uvn-1 T(c)
-1
= Qxyz<-uvnT T(c)
-1
= Quvn<-xyz T(-c)
Representing a Rotation as Three Shears
A rotation around the z-axis by an angle a
can be represented by the following column vector matrix:
Rz(a) |
= |
cos(a) | -sin(a) | 0 | 0 |
sin(a) | cos(a) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
This same rotation can also be represented by a string of three
shear operations:
Rz(a) = SHx along y( -tan(a/2) ) * SHy along x( sin(a) ) * SHx along y( -tan(a/2) )
The following is the same equation written out with column vector
matrices:
Rz(a) |
= |
cos(a) | -sin(a) | 0 | 0 |
sin(a) | cos(a) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
| = |
1 | -tan(a/2) | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
1 | 0 | 0 | 0 |
sin(a) | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
1 | -tan(a/2) | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
Representing a Shear as Rotate, Scale, Rotate, Scale
A shear of the x coordinate while moving along the
y-axis can be represented by the following column vector
matrix:
SHx along y( shx ) |
= |
1 | shx | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
This same shear can also be represented by a string of a rotation, a non-uniform scaling, a rotation, and a non-uniform scaling:
SHx along y( shx ) = S( sx, sy, 1 ) * Rz( -b ) * S( 1, s, 1 ) * Rz( a )
SHx along y( -shx ) = S( sx, sy, 1 ) * Rz( b ) * S( 1, s, 1 ) * Rz( -a )
Where shx >= 0 and the other parameters follow these
equations:
s = sqrt( ( 1 + shx ) * ( 1 + shx + shx2 ) ) |
The following is the same equation written out with column vector
matrices:
SHx along y( shx ) |
= |
1 | shx | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
| = |
sx | 0 | 0 | 0 |
0 | sy | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
cos(-b) | -sin(-b) | 0 | 0 |
sin(-b) | cos(-b) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
1 | 0 | 0 | 0 |
0 | s | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
cos(a) | -sin(a) | 0 | 0 |
sin(a) | cos(a) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
SHx along y( -shx ) |
= |
1 | -shx | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
| = |
sx | 0 | 0 | 0 |
0 | sy | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
cos(b) | -sin(b) | 0 | 0 |
sin(b) | cos(b) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
1 | 0 | 0 | 0 |
0 | s | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
cos(-a) | -sin(-a) | 0 | 0 |
sin(-a) | cos(-a) | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 0 | 0 | 1 |
|
|
|
This page was originally built by Jordan Smith.
Last modified: Thursday, 24-Oct-2002 10:38:16 PDT