0% found this document useful (0 votes)
45 views38 pages

Tables Shapiro

The document discusses various coordinate systems and transformations used in computer graphics. It describes: 1) Different coordinate systems including device, view, and world coordinate systems. 2) Common transformations between coordinate systems like translation, scaling, and rotation that are used to manipulate 3D objects. 3) The use of homogeneous coordinates to represent transformations as matrix multiplications for convenience. 4) Examples of transformations including translation, scaling, and rotation about different axes.

Uploaded by

Glugut Adhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views38 pages

Tables Shapiro

The document discusses various coordinate systems and transformations used in computer graphics. It describes: 1) Different coordinate systems including device, view, and world coordinate systems. 2) Common transformations between coordinate systems like translation, scaling, and rotation that are used to manipulate 3D objects. 3) The use of homogeneous coordinates to represent transformations as matrix multiplications for convenience. 4) Examples of transformations including translation, scaling, and rotation about different axes.

Uploaded by

Glugut Adhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Coordinate Systems and

Transformations
Graphic Libraries

Hardware dependent program

Hardware independent program

GL Examples:
Core, GKS, PEX, OpenGL
Coordinate Systems
• Device Coordinate System:
identifies locations on the display

=>Virtual Device Coordinate System:


Usually the origin is at the low left corner and u,v
range from 0 to 1.
Coordinate Systems
• Model Coordinate System(MCS):
identifies the shapes of object and it is attached to the
object. Therefore the MCS moves with the object in the
WCS
• World Coordinate System (WCS):
identifies locations of objects in the world in the
application.
• Viewing Coordinate System (VCS):
Defined by the viewpoint and viewsite
Coordinate Systems
viewpoint and viewsite
Coordinate Systems
Projection on Screen
• Parallel Projection
• Perspective Projection
Parallel Projection

• Preserve actual dimensions and shapes of objects


• Preserve parallelism
• Angles preserved only on faces parallel to the
projection plane
• Orthographic projection is one type of parallel
projection
Perspective Projection

• Doesn’t preserve parallelism


• Doesn’t preserve actual dimensions and angles
of objects, therefore shapes deformed
• Popular in art (classic painting); architectural
design and civil engineering.
• Not commonly used in mechanical engineering
Perspective Projection

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

⎡ r cos ϕ cos θ − r sin ϕ sin θ ⎤


= ⎢⎢ r cos ϕ sin θ + r sin ϕ cos θ ⎥⎥ P2 (x2, y2)
x
y
⎢⎣ z ⎥⎦
⎡ x1 cos θ − y1 sin θ ⎤ θ P1(x1, y1)
= ⎢⎢ x1 sin θ + y1 cos θ ⎥⎥ φ
o x
⎢⎣ z1 ⎥⎦
3-D Transformation

Rotation about Z Axis - CCW by Ө

x2 = x1 cos θ − y1 sin θ
y2 = x1 sin θ + y1 cos θ
z2 = z1
y P2 (x2, y2, z2)

P1(x1, y1, z2) ⎡ x2 ⎤ ⎡cos θ − sin θ 0 ⎤ ⎡ x1 ⎤


θ ⎢ y ⎥ = ⎢sin θ cos θ 0 ⎥⎢y ⎥
φ ⎢ 2⎥ ⎢ ⎥ ⎢ 1⎥
o ⎢⎣ z2 ⎥⎦ ⎢⎣ 0 0 1 ⎥⎦ ⎢⎣ z1 ⎥⎦
x

Counter Clockwise, CCW


Rotation about X Axis -
z
CCW by Ө
x2 = x
y
o y2 = y1 cos θ − z1 sin θ
x
z2 = y1 sin θ + z1 cos θ
P2 (x2, y2, z2)
z

P1(x1, y1, z1) ⎡ x2 ⎤ ⎡1 0 0 ⎤ ⎡ x1 ⎤


θ ⎢ y ⎥ = ⎢0 cos θ − sin θ ⎥ ⎢ y ⎥
φ ⎢ 2⎥ ⎢ ⎥ ⎢ 1⎥
⎢⎣ z2 ⎥⎦ ⎢⎣0 sin θ cos θ ⎥⎦ ⎢⎣ z1 ⎥⎦
o y
Rotation about Y Axis -
⎡ x1 ⎤ ⎡ r cos ϕ ⎤
P1 = ⎢⎢ y1 ⎥⎥ = ⎢⎢ y1 ⎥⎥
CCW by Ө
⎢⎣ z1 ⎥⎦ ⎢⎣ r sin ϕ ⎥⎦
⎡ x2 ⎤ ⎡ r cos (ϕ − θ ) ⎤ ⎡ r cos ϕ cos θ + r sin ϕ sin θ ⎤
⎢ ⎥ ⎢
P2 = ⎢⎢ y2 ⎥⎥ = ⎢ y1 =
⎥ ⎢ y1


⎢⎣ z2 ⎥⎦ ⎢⎣ r sin (ϕ − θ ) ⎥⎦ ⎢⎣ r sin ϕ cos θ − r cos ϕ sin θ ⎥⎦
⎡ x1 cos θ + z1 sin θ ⎤
Z
= ⎢⎢ y1 ⎥
⎥ P1
⎢⎣ − x1 sin θ + z1 cos θ ⎦⎥
⎡ x2 ⎤ ⎡ cos θ 0 sin θ ⎤ ⎡ x1 ⎤ P2
θ
P2 = ⎢⎢ y2 ⎥⎥ = ⎢⎢ 0 1 0 ⎥⎥ ⎢⎢ y1 ⎥⎥ = R[ y ] P1
⎢⎣ z2 ⎥⎦ ⎢⎣ − sin θ 0 cos θ ⎥⎦ ⎢⎣ z1 ⎥⎦ φ
X Y
Homogeneous Representation
The representation is introduced to express all
geometric transformations in the from of matrix
multiplication for the convenience of manipulation.

⎡ 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 ⎦

Dummy (n+1)th coordinate to facilitate multiplication


Homogeneous Representations
Scaling ⎡sx 0 0 0⎤
⎢0 s y 0 0⎥
[H ] = ⎢ ⎥
⎢0 0 sz 0 ⎥
⎢ ⎥
⎣0 0 0 1⎦
Rotation

⎡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

Consider a 3D object. The coordinates of


the vertices are given as follows:

A=[3, 5, 3] B=[7, 5, 3] C=[7, 5, 5]

D=[3, 5, 5] E=[3, 6, 5] F=[3, 6, 3]

Rotate the 3D object by 30 degree in


clockwise (CW) direction at point D about
the Y-axis.
Step 1
[T]D-O
o

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

⎡ 4.00 7.46 6.46 3.00 3.00 4.00 ⎤


⎢5.00 5.00 5.00 5.00 6.00 6.00 ⎥
P2 = ⎢ ⎥
⎢3.27 5.27 7.00 5.00 5.00 3.27 ⎥
⎢ ⎥
⎣1.00 1.00 1.00 1.00 1.00 1.00 ⎦
Mapping and Parallel Projections
• Mapping involves calculating the coordinates of a point
known with rispect to a CS to a new CS.
About Transformations
• Transformations are applied for both changing WCS
in respect to MCS, but also for projections
Mapping and Parallel Projections

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

Once mapping has been performed the Z coordinate is dropped


Mapping and Perspective
Projections
Once mapping has been performed the zv coordinate are not dropped
yet and the xv, yv coordinates are scaled following the similarity rule of
triangles (L,S needed). Then zv is dropped.
Generating Parallel Projection
Drop the n (zv) coordinate ⎡1 0 0 0⎤ ⎛ u⎞ ⎛u⎞
⎢0 1 0 0⎥ ⎜ V⎟ ⎜ V⎟
[Dn ]= ⎢⎢0 0 0 0⎥
⎥, ⎜ ⎟ = [Dn ]⎜ ⎟
⎜ 0⎟ ⎜n⎟
⎢0 ⎜ ⎟ ⎜ ⎟
⎣ 0 0 1 ⎥⎦ ⎝ 1⎠ ⎝1⎠

In summary, to project a view of an object on the UV plane, one needs to


transform each point on the object by:

[T ] = [ Dn ][ Rz ][ Ry ][ Rx ][ Dov ,o ]
⎛ u⎞ ⎛ x⎞
⎜ V⎟ ⎜ y⎟
P ′ = ⎜ ⎟ = [T ]P = [T] ⎜ ⎟
⎜ 0⎟ ⎜ z⎟
⎜ ⎟ ⎜ ⎟
⎝ 1⎠ ⎝ 1⎠

Note: The inverse transforms are not needed! We don't want to


go back to x - y - z coordinates.
Orthographic Projection
Y
Top
Front Right

• Projection planes (Viewing planes) are


perpendicular to the principal axes of the
MCS of the model
• The projection direction (viewing direction)
coincides with one of the MCS axes
Geometric
Y Transformations for
Top Generating
Front Right
Orthographic Projection
X (Front View)

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

⎡1 0 0 0 ⎤ ⎡ cos( −90°) 0 sin( −90°) 0⎤ ⎡0 0 − 1 0⎤


⎢0 1 0 0 ⎥ ⎢ 0 1 0 0 ⎥⎥ ⎢0 1 0 0 ⎥⎥
Pv = ⎢ ⎥ ⎢ P=⎢ P
⎢ 0 0 0 0 ⎥ ⎢ − sin ( −90° ) 0 cos( −90°) 0 ⎥ ⎢0 0 0 0⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎣ 0 0 0 1 ⎦ ⎢⎣ 0 0 0 1 ⎥⎦ ⎣0 0 0 1⎦

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

ry ( x ) = ±45°, rz = ANY ANGLE

You might also like