Tables Shapiro
Tables Shapiro
Transformations
Graphic Libraries
GL Examples:
Core, GKS, PEX, OpenGL
Coordinate Systems
• Device Coordinate System:
identifies locations on the display
Coordinate scaling:
Transformations between
Coordinate Systems
Model Transformation
Viewing Transformation
ProjectionTransformation
Translation 3D
2D y
P2 (x2, y2)
y d
yd P2
P1(x1, y1)
o xd x P1
x
⎡ x1 ⎤
⎢ ⎥
P1 = ⎢ y1 ⎥ z
⎢⎣ z1 ⎥⎦
⎡ x1 ⎤ ⎡ x d ⎤ ⎡ x1 + xd ⎤
P 2 = ⎢⎢ y1 ⎥⎥ + ⎢⎢ y d ⎥⎥ = ⎢⎢ y1 + yd ⎥⎥ = P1 + d
⎢⎣ z1 ⎥⎦ ⎢⎣ z d ⎥⎦ ⎢⎣ z1 + zd ⎥⎦
Scaling y
2D 3D
y P2
P2 (x 2, y2)y’)
V’(x’, P1
P1(xV(x, y)
1, y1)
x
θ x
o
z
⎡x1 ⎤ ⎡sx1 ⎤
⎢ ⎥ ⎢ ⎥
P1 = ⎢y1 ⎥ P 2 = ⎢sy1 ⎥ P 2 = sP1
⎢⎣z1 ⎥⎦ ⎢⎣sz1 ⎥⎦
y
P2
Reflection (about XOY
Plane)
o x
P1
⎡ x1 ⎤ ⎡ x1 ⎤ ⎡1 0 0 ⎤
⎢ ⎥ ⎢ ⎥
P1 = ⎢ y1 ⎥ P 2 = ⎢ y1 ⎥ P 2 = ⎢⎢ 0 1 0 ⎥⎥ P1
⎢⎣ z1 ⎥⎦ ⎢⎣ −z1 ⎥⎦ ⎢⎣ 0 0 −1⎥⎦
Rotation about Z Axis - CCW by Ө
⎡ x1 ⎤ ⎡ r cos ϕ ⎤ φ
z
P1 = ⎢⎢ y1 ⎥⎥ = ⎢⎢ r sin ϕ ⎥⎥ CCW
y2 y
⎢⎣ z1 ⎥⎦ ⎢⎣ z ⎥⎦ y1
P2
⎡ x2 ⎤ ⎡ r cos (ϕ +θ ) ⎤ z θ
⎢ ⎥
P2 = ⎢⎢ y2 ⎥⎥ = ⎢ r sin (ϕ +θ ) ⎥
Φ r P1
o x2
⎢⎣ z2 ⎥⎦ ⎢⎣ z ⎥⎦ x1
x2 = x1 cos θ − y1 sin θ
y2 = x1 sin θ + y1 cos θ
z2 = z1
y P2 (x2, y2, z2)
⎡ x2 ⎤ ⎡1 0 0 d x ⎤ ⎡ x1 ⎤
⎢ y ⎥ ⎢0 1 0 d y ⎥⎥ ⎢ y1 ⎥
Translation ⎢ 2 ⎥ = ⎢ ⎢ ⎥
⎢ z2 ⎥ ⎢0 0 1 d z ⎥ ⎢ z1 ⎥
⎢ ⎥ ⎢ ⎥⎢ ⎥
⎣1 ⎦ ⎢⎣ 0 0 0 1 ⎥⎦ ⎣1 ⎦
⎡cos θ − sin θ 0 0⎤
⎢ sin θ cos θ 0 0 ⎥⎥
P2 = [Rz ]P1 and [Rz ] = ⎢
⎢ 0 0 1 0⎥
⎢ ⎥
⎣ 0 0 0 1⎦
Homogeneous Representations
⎡1 0 0 0⎤ ⎡ cos θ 0 sin θ 0⎤
⎢ 0 cos θ − sin θ 0 ⎥⎥ ⎢ 0 1 0 0 ⎥⎥
[ Rx ] = ⎢⎢ ; ⎡⎣ R y ⎤⎦ = ⎢
0 sin θ cos θ 0⎥ ⎢ − sin θ 0 cos θ 0⎥
⎢ ⎥ ⎢ ⎥
⎣0 0 0 1⎦ ⎣ 0 0 0 1⎦
Reflection
⎡± 1 0 0 0⎤
⎢ 0 ±1 0 0⎥⎥
P2 = [M ]P1 and [M ] = ⎢
⎢ 0 0 ±1 0⎥
⎢ ⎥
⎣0 0 0 1⎦
Composition of Transformation
(Concatenation of Transformation)
via Pre-Multiplication
P2 = [ H n ][ H n −1 ]"[ H1 ]P1
An Example
Step 2 Step 3
[R]y-30 [T]O-D
Procedure:
• First we translate ([T]D-O) the object at the refernece point
D to the origin O.
• Then we rotate ([ R]Y−30) about the Y-axis
• Finally, we translate ([T]O-D) the point D from the origin
back to its original position.
⎡1 0 0 − 3 ⎤ ⎡cos(−30) 0 sin ( −30 ) 0 ⎤
⎢0 1 0 − 5⎥ ⎢ ⎥
=⎢ ⎥
0 1 0 0
[T ] D − O = ⎢ ⎥ [ R]Y−30
⎢ − sin(−30) 0 cos(−30) 0 ⎥
⎢0 0 1 − 5⎥
⎢ ⎥ ⎢ ⎥
⎣ 0 0 0 1 ⎦ ⎢⎣ 0 0 0 1 ⎥⎦
⎡1 0 0 3⎤
⎢0 1 0 5 ⎥⎥
[T ]O − D = ⎢
⎢0 0 1 5⎥
⎢ ⎥
⎣0 0 0 1⎦
[A B C D E F]
⎡3 7 7 3 3 3 ⎤
⎢5 5 5 5 6 6 ⎥ The definition of the point
P1 = ⎢ ⎥ matrix in the homogeneous
⎢3 3 5 5 5 3 ⎥
⎢ ⎥ representation.
⎣1 1 1 1 1 1 ⎦
−30
P2 = [T ]O − D [ R] [T ]D −O P1
Z
Where:
Px,py,pz=x2,y2,z2 components required to translate (X2,Y2,Z2) to (X1,Y1,Z1),
the following are evaluated as the translation as been performed:
nx,ny,nz=x2,y2,z2 components of a unit vector along x1
ox,oy,oz=x2,y2,z2 components of a unit vector along y1
ax,ay,az=x2,y2,z2 components of a unit vector along y1
[T ] = [ Dn ][ Rz ][ Ry ][ Rx ][ Dov ,o ]
⎛ u⎞ ⎛ x⎞
⎜ V⎟ ⎜ y⎟
P ′ = ⎜ ⎟ = [T ]P = [T] ⎜ ⎟
⎜ 0⎟ ⎜ z⎟
⎜ ⎟ ⎜ ⎟
⎝ 1⎠ ⎝ 1⎠
Z
⎡1 0 0 0 ⎤
⎢0 1 0 0 ⎥
Pv = ⎢ ⎥P
Yv,Y
⎢0 0 0 0 ⎥
⎢ ⎥
Front
⎣0 0 0 1 ⎦
Xv, X Drop Z
Geometric Transformations
for Generating
Orthographic Projection
Y
(Top View)
Yv
Top
Front Right
X Top
Xv, X
Z Z
⎡1 0 0 0 ⎤ ⎡1 0 0 0⎤ ⎡1 0 0 0⎤
⎢ 0 1 0 0 ⎥ ⎢ 0 cos(90 ° ) − sin(90 ° ) 0 ⎥⎥ ⎢0 0 − 1 0 ⎥⎥
Pv = ⎢ ⎥⎢ P=⎢ P
⎢ 0 0 0 0 ⎥ ⎢ 0 sin ( 90 ° ) cos(90 ° ) 0⎥ ⎢0 0 0 0⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎣ 0 0 0 1 ⎦ ⎢⎣ 0 0 0 1 ⎥⎦ ⎣0 0 0 1⎦
Drop Z [ R]90
x
Geometric Transformations
for Generating
Y Orthographic Projection
(Right View)
Top Yv, Y
Front Right
Right
X
Z Xv
Z
Drop Z [ R ]−y90
Rotations Needed for Generating Isometric Projection
Y
Yv
Top Y
Front Right Top
X Front Right Xv
Z
Z Zv X
⎡1 0 0 0 ⎤ ⎡cos θ 0 sin θ 0 ⎤
⎢0 cos φ − sin φ ⎥ ⎢
0⎥ ⎢ 0 1 0 0 ⎥ ⎥
Pv = [ R]φx [ R]θy P = ⎢ P
⎢0 sin φ cos φ 0 ⎥ ⎢ − sin θ 0 cos θ 0 ⎥
⎢ ⎥⎢ ⎥
⎣0 0 0 1⎦⎣ 0 0 0 1 ⎦
Isometric Projection: Equally foreshorten the
three main axes
θ = ±45°, φ = ±35.26°
Other Possible Rotation Paths
• Rx --> Ry
rx = ±45°, ry = ±35.26°
• Rz --> Ry(Rx)
rz = ±45°, ry ( x ) = ±54.74°
• Rx(Ry) --> Rz