University of California, Berkeley
EECS Dept, CS Division
Jordan Smith SLIDE: Scene Language for
Interactive Dynamic Environments
Prof. Carlo H. Séquin

Home Goals Publications People Gallery Assignments Distributions

SLIDE 3D Transformation Notes

Contents


Transformations in 3D

Type Column Vector Matrix Row Vector Matrix Properties
Translation

translate (tx ty tz)
100tx
010ty
001tz
0001
1000
0100
0010
txtytz1
Rigid Body
Orthogonal Submatrix
Scale

scale (sx sy sy)
sx000
0sy00
00sz0
0001
sx000
0sy00
00sz0
0001
Non-rigid Body
Rotation around X

rotate (1 0 0) (a)
1000
0cos(a)-sin(a)0
0sin(a)cos(a)0
0001
1000
0cos(a)sin(a)0
0-sin(a)cos(a)0
0001
Rigid Body
Orthogonal
Rotation around Y

rotate (0 1 0) (a)
cos(a)0sin(a)0
0100
-sin(a)0cos(a)0
0001
cos(a)0-sin(a)0
0100
sin(a)0cos(a)0
0001
Rigid Body
Orthogonal
Rotation around Z

rotate (0 0 1) (a)
cos(a)-sin(a)00
sin(a)cos(a)00
0010
0001
cos(a)sin(a)00
-sin(a)cos(a)00
0010
0001
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-wzwy0
wz0-wx0
-wywx00
0000
0wz-wy0
-wz0wx0
wy-wx00
0000
Skew Symmetric
W3 = -W
Shear XY

[x, y, z, 1] =>
[x + shx*z, y + shy*z, z, 1]
10shx0
01shy0
0010
0001
1000
0100
shxshy10
0001
Non-rigid Body
Shear XZ

[x, y, z, 1] =>
[x + shx*y, y, z + shz*y, 1]
1shx00
0100
0shz10
0001
1000
shx1shz0
0010
0001
Non-rigid Body
Shear YZ

[x, y, z, 1] =>
[x, y + shy*x, z + shz*x, 1]
1000
shy100
shz010
0001
1shyshz0
0100
0010
0001
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)
BXAxBYAxBZAxBOAx
BXAyBYAyBZAyBOAy
BXAzBYAzBZAzBOAz
0001
BXAxBXAyBXAz0
BYAxBYAyBYAz0
BZAxBZAyBZAz0
BOAxBOAyBOAz1
Rigid Body

The lookat transformation


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

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.

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
pu
pv
pn
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:

a = atan(
1
1 + shx
)
s = sqrt( ( 1 + shx ) * ( 1 + shx + shx2 ) )
b = atan( sqrt(
1 + shx + shx2
1 + shx
) )
sx = sqrt(
1
1 + shx
)
sy = sqrt(
1
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