# CS代考计算机代写 chain CS580

CS580

Transformations
Ulrich Neumann
CS580
Computer Graphics Rendering

Transformation Example (1)
What are the 2D coordinates of the vertices?

V1
V3
V2

Transformation Example (2)
A reference frame (origin and axes) is required to measure or specify numeric coordinates.

V1
V3
V2
Y
X
(0,0)

Transformation Example (3)
Case 1: Changing (transforming) the object coordinates changes the object’s location in the coordinate frame.

Y
X
(0,0)
V1
V3
V2

Transformation Example (4)
Case 2: Changing (transforming) the reference frame also changes the object coordinates.

V1
V3
V2

Y
X
(0,0)

Transformations
Linear transformations (Xforms) define a mapping of coordinates (coords) in one coordinate frame to another
the mappings are 1:1 and invertible
Vb = Xba Va
homogeneous vectors (V) are 4×1 columns (x,y,z,w)T
homogeneous transforms (X) are 4×4 matricies
Projection of 4D points into a subspace (w = 1) yields Euclidean 3-space values (examples shown later)
General Xforms can be decomposed into scale, translate, rotate, shear, reflection, …
View Xforms in graphics are a subset based on S T R
Scale, Translate, Rotate
we do not allow shears or other
non-shape-preserving transforms

Basic Types
Scalars: s

3D Points:

3D Direction vectors:

3D Translations
Translations occur along the axes of the space
Axis directions are preserved, but origin changes

Properties of Translations
=
=
=
=

Rotations (2D)
x
y
by angle theta

Rotations occur about the origin of the space
The origin does not change (fixed-point), but the axis directions do
The input axes prior to rotation (e.g., (1,0,0) … ) may become non-axis vectors

3D General Rotation
This matrix rotates the point (x,y,z) about the vector ⟨u,v,w⟩ by the angle θ, under the constraint that ⟨u,v,w⟩ is a unit vector; i.e., that u2 + v2 + w2 = 1

http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/

3D Scaling
Uniform scaling iff
Scaling occurs about the origin of the space
The origin does not change (fixed-point)
The axis directions do not change (preserves axes)
Distances between points change

4D Homogeneous Coordinates
can be represented as
where
A 3D coord (x,y,z) is represented by an infinite locus of 4D coords of varying w
The projection of 4D coords to manifold w=1 is the 3D coord system
Projection of 4D coord is done by scaling about the origin (0,0,0,0) with a divide by w

(x,y,z) <==> (x,y,z,1) <==> (X/w, Y/w, Z/w, w/w) <==> (X, Y, Z, w)

4D to 3D Conversions
Convert 3D to 4D by adding a w=1 term
Convert 4D to 3D by dividing all terms by w

4D Translation
using homogeneous transformation

4D Rotation & Scaling
homogeneous transformation
We will always assume Sx = Sy = Sz (uniform scaling),
unless clearly noted otherwise
The term along the axes of rotation is unchanged (x in this case)

Combining Transformations
where
The result of a sequence of transformations [T] [R] [S] v
is the same as the result of a single transformation [M] v
where M is the concatenated (or combined) transform M = [T] [R] [S]
and concatenation is right-to-left

Scale and Rotation Combined
chain any S,R,T matrices to arbitrary length
fully associative (combine any adjacent xforms)
X = S R = R S (commutative property is for S,R only)
rotation and scaling commute – neither change origin
assume uniform scaling in all dimensions
translations do not commute with R or S
due to change of origin (fixed-point)

apply SR or RS
to arrive at the
same result

Origin

R
S
RSv = SRv
v

Translation
Translations do not commute with R or S

TR ≠ RT TS ≠ ST

Origin

STv
TSv

RTv
TRv
Origin

v
v

Rotation and Translation Combined
A 4×4 matrix combining rotation and translation Xab = T R
Rotation about origin in space-b occurs first
Then, translation using axis of space-a is applied

Xab = =

T R
A different transformation (and matrix) is obtained if we reorder the operations as: Xab ≠ R T
The translation occurs first, shifting the origin along the axes in space-b
The rotation follows about the new origin and axes of space-b

(Note that R can also contain a scale xform S, and RS=SR so they commute)

cos ø 0 sin ø xt
0 1 0 yt
-sin ø 0 cos ø zt
0 0 0 1

1 0 0 xt
0 1 0 yt
0 0 1 zt
0 0 0 1

cos ø 0 sin ø 0
0 1 0 0
-sin ø 0 cos ø 0
0 0 0 1

Rotations in 2D and 3D
Successive rotations in 2D commute R1 R2 = R2 R1

2D rotations are about the same axis (perpendicular to the 2D plane)

Successive rotations in 3D do not commute

R1 R2 ≠ R2 R1
The object-axes are altered by each rotation

Show this with 90-degree 3D rotations of a dice
Spin it CCW, then flip it

vs
Flip it, then spin it CCW

The outcome is different