0% found this document useful (0 votes)
7 views17 pages

Lect 9

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)
7 views17 pages

Lect 9

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/ 17

Computer Graphics

(Lecture 9)
3D Translation
 Translation by (tx, ty, tz) is achieved using the following matrix:
1 0 0 tx 
0 1 0 ty 
M T (t x , t y , t z )   
0 0 1 tz 
 
0 0 0 1

 For example: translation by (1, 1, 1) is the following:


1 0 0 1
0 1 0 1
M T (1,1,1)   
0 0 1 1
 
0 0 0 1
3D Scaling

The scale formula changes the size of the object and


repositions the object with relative to the coordinate
origin.

Y -z

-x
(2,0,-4)
(4,0,-2)
-y
Z
Scaling with respect to a selected point

 Scaling with respect to a selected point (xf,yf,zf) can be represented


with the following transformation sequence:
 1: Translate the fixed point to the origin.
 2: Scale the object with respect to origin.
 3: Translate the fixed point back to its original position.

T(xf,yf,zf).S (sx,sy,sz) .T (-xf,-yf,-zf)

 e.g : scale the previous example around (2,0,-4)


Scaling with respect to a selected point

 Solution:
 1: Translate the object to system origin by T(-2,0,4)
 2: Scale the object by S (2,1,0.5)
 3:Translate the object back to (2,0,-4) by T (2,0,-4)
 p’ = T-1.S.T .p

transformation
Scaling with respect to a selected point

Y -z Y -z
Y -z

-x -x
-x

-y -y -y
Z Z Z

T(-2,0,4) S(2,1,0.5) T(2,0,-4)


𝑥′ 1 0 0 𝑥𝑓 𝑆𝑥 0 0 0 1 0 0 −𝑥𝑓 𝑥
𝑦′ 0 1 0 𝑦𝑓 0 𝑆𝑦 0 0 0 1 0 −𝑦𝑓 𝑦
 =
𝑧′ 0 0 1 𝑧𝑓 0 0 𝑆𝑧 0 0 0 1 −𝑧𝑓 𝑧
1 0 0 0 1 0 0 0 1 0 0 0 1 1
𝑥′ 1 0 0 2 2 0 0 0 1 0 0 −2 𝑥
𝑦′ 0 1 0 0 0 1 0 0 0 1 0 0 𝑦
 =
𝑧′ 0 0 1 −4 0 0 0.5 0 0 0 1 4 𝑧
1 0 0 0 1 0 0 0 1 0 0 0 1 1

𝑥′ 1 0 0 2 2 0 0 −4 𝑥
𝑦′ 0 1 0 0 0 1 0 0 𝑦
 =
𝑧′ 0 0 1 −4 0 0 0.5 2 𝑧
1 0 0 0 1 0 0 0 1 1

𝑥′ 2 0 0 −2 𝑥
𝑦′ 0 1 0 0 𝑦
 =
𝑧′ 0 0 0.5 −2 𝑧
1 0 0 0 1 1
3D Rotation
1 0 0 0
 cos  sin 0
• About X axis (Pitch angle) R x  0  (x,y,z)
0 sin cos 0
 
x

0 0 0 1
(x’,y’,z’)

 cos 0 sin 0
 0 0
• About Y axis (Yaw angle) Ry 
1 0
 (x,y,z)
  sin 0 cos 0 (x’,y’,z’)

 
 0 0 0 1

cos  sin 0 0
(x,y,z)
 sin cos 0
• About Z axis (Roll angle) Rz  
0
 x

 0 0 1 0
  (x’,y’,z’)
 0 0 0 1
Major Axis Rotation
Exercise - Rotate by 45 about x axis
 To rotate by 45 degrees about x-axis, use the following matrix:

1 0 0 0
1 0 0 0  1 1 
0  0  0
cos 45  sin 45 0
R x ( 45)  
2 2
  
0 sin 45 cos 45 0 0 1 1
0
   2 2 
0 0 0 1
 1
0 0 0 
3D Shear - One axe
𝒙′ 𝟏 𝒔𝒉𝒙𝒚 𝒔𝒉𝒙𝒛 𝟎 𝒙
• X-shearing a point 𝒚′ 𝟎 𝟏 𝟎 𝟎 𝒚
=
𝒛′ 𝟎 𝟎 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏

𝒙′ 𝟏 𝟎 𝟎 𝟎 𝒙
• Y-shearing a point 𝒚′ 𝒔𝒉𝒚𝒙 𝟏 𝒔𝒉𝒚𝒛 𝟎 𝒚
=
𝒛′ 𝟎 𝟎 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏

• Z-shearing a point 𝒙′ 𝟏 𝟎 𝟎 𝟎 𝒙
𝒚′ 𝟎 𝟏 𝟎 𝟎 𝒚
=
𝒛′ 𝒔𝒉𝒛𝒙 𝒔𝒉𝒛𝒚 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏
3D Shear - Two axis
• XY-shearing a point (Z is fixed)
𝒙′ 𝟏 𝟎 𝒔𝒉𝒛𝒙 𝟎 𝒙
𝒚′ 𝟎 𝟏 𝒔𝒉𝒛𝒚 𝟎 𝒚
=
𝒛′ 𝟎 𝟎 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏

• XZ-shearing a point (Y is fixed)


𝒙′ 𝟏 𝒔𝒉𝒚𝒙 𝟎 𝟎 𝒙
𝒚′ 𝟎 𝟏 𝟎 𝟎 𝒚
=
𝒛′ 𝟎 𝒔𝒉𝒚𝒛 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏

• YZ-shearing a point (X is fixed)

𝒙′ 𝟏 𝟎 𝟎 𝟎 𝒙
𝒚′ 𝒔𝒉𝒙𝒚 𝟏 𝟎 𝟎 𝒚
=
𝒛′ 𝒔𝒉𝒙𝒛 𝟎 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏
3D Shear - All together

𝒙′ 𝟏 𝒔𝒉𝒙𝒚 𝒔𝒉𝒙𝒛 𝟎 𝒙
𝒚′ 𝒔𝒉𝒚𝒙 𝟏 𝒔𝒉𝒚𝒛 𝟎 𝒚
=
𝒛′ 𝒔𝒉𝒛𝒙 𝒔𝒉𝒛𝒚 𝟏 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏
Example
We want to Rotate a Line around a point with a specific Angle :

We Need Three Matrix 4 * 4


M = T1’ * R1* T1
T1 : translate the point to the Origin
R1 : apply the desired rotation
T1’ : translate the point to the original position
Perspective Projection Back
Clipping
VUP
plane
View
Front
plane
Clipping
plane VRP

VPN

F B

 Projections transform points from 3D to 2D


 VPN: View Plane Normal
 VRP: View Reference Point (any point on the view plane)
 VUP: a vector to determine the viewer’s up direction
 COP: Center of projection (eye)
Perspective Projection (Pinhole Camera)
 If COP is placed at the origin (0,0,0) and the view plane is
perpendicular to z direction of a distance d from the origin:
Projection
x plane P(x, y, z)
xp
xp x yp y
 ; 
z
d z d z
d x y
xp  ; yp 
z/d z/d
d 1 0 0 0
z 0 1 0 0
yp M per   
Projection 0 0 1 0
y P(x, y, z)  
plane
0 0 1 / d 0
Perspective Projection
 xp  X  1 0 0 0  x  x
y  Y  0     y
      M per  P   1 0 0  y   
p
 z
zp  Z  0 0 1 0  z 
        z
 1  W  0 0 1/ d 0  1  
d 

 However W  1, so we must divide by W to return from homogeneous
coordinates  d
 xp  x 
y   d z

 p   y 
zp   z 
   d 
 1   
 1 
 If COP is placed at point (a,b,c) first translate the view to the origin then
do the projection and finally translate it back

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy