0% found this document useful (0 votes)
5 views64 pages

Chapter 4

Chapter 4 covers the fundamentals of 3D viewing, including the 3D coordinate system, vector operations, and geometric transformations. It explains the 3D viewing pipeline, which transforms 3D object data into 2D images for display, and details various transformations such as translation, scaling, and rotation. The chapter emphasizes the use of homogeneous coordinates for representing transformations and the importance of geometric transformations in manipulating 3D objects.

Uploaded by

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

Chapter 4

Chapter 4 covers the fundamentals of 3D viewing, including the 3D coordinate system, vector operations, and geometric transformations. It explains the 3D viewing pipeline, which transforms 3D object data into 2D images for display, and details various transformations such as translation, scaling, and rotation. The chapter emphasizes the use of homogeneous coordinates for representing transformations and the importance of geometric transformations in manipulating 3D objects.

Uploaded by

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

Chapter 4: 3D viewing

Outline Contents
2

1. 3D Coordinate System
2. Vector Fundamentals
3. 3D Homogeneous Coordinate
4. 3D Geometric Transformations
5. 3D Inverse Transformations
6. 3D Coordinate Transformations
7. Composite transformations
3 3D Viewing Pipeline

• The 3D viewing pipeline is used to transforms 3D object data into 2D


images for display on a screen.
• This process involves several steps, including defining a camera,
applying transformations to objects, and projecting them onto a viewing
plane.
• The viewing pipeline ensures that 3D objects are accurately represented
in 2D, enabling the rendering of realistic and complex scenes.
• The overall steps for 3D viewing pipeline is shown in Fig 1 and we will
focus in this chapter about the modelling transformation.
3D Viewing Pipeline
Primitives
Object space
Modeling Transformation

World space
Viewing Transformation
Camera space

Hidden Surface Removal

Lighting & Shading

3D-Clipping

Projection
Normalized view space
Scan conversion, Hiding
Image space,
Fig 1 Device coordinates
Image
5 3D Coordinate System
 3D coordinate system consists of a reference point called
origin and three mutually perpendicular passing through
origin. y axis

z
x

z axis x axis Right-Hand


Reference System
6 3D Coordinate System

 A point P(x,y,z) specifies that point y axis

is
 At a distance of x units from YZ-plane y
 At a distance of y units from XZ-plane
 At a distance of z units from XY-plane
P

z
x

z axis x axis
7 Vector Fundamentals
 In 3D there are 3 natural coordinate vectors I, J and K having
unit along X, Y and Z axis respectively.

y axis

 Any vector V = aI+bJ+cK can be


y V=aI+bJ+cK
resolved into three components
(a,b,c) that represent corresponding
point when the tail of V is placed at P (a,b,c)
the origin.
z
x

z axis x axis
8 Vector Fundamentals
 If P(x0,y0,z0) and Q(x1,y1,z1) are two points in space then
PQ = (x1 – xo)I+ (y1 – yo)J+ (z1 – zo)K
y axis

 Vector has two attributes: y V=aI+bJ+cK

 length- a scalar denoted by |v|


 direction in 3D space P (a,b,c)

 Equality: Two vectors are equal if


z
they have same length and direction x
z axis
x axis
9 Vector Fundamentals

1. Vector Addition: perform addition by the head-to-tail rule.


Note u+v = v+u
v
v+u
u+v
u
10 Vector Fundamentals

2. Vector Subtraction: To perform subtraction, given u and v, we


define u - v to be u + (-v):
Note u - v ≠ v – u

u u -v
v
u-v
Vector Fundamentals
11

3. Zero Vector: i.e. vector with zero length and no direction.


v + (-v) = 0
4. Magnitude of Vector of a vector u = aI+bJ+cK is a scalar
quantity defined as:
2 2 2
u  a b c

5. Unit vector for any vector u is a vector having direction of


u and unit magnitude. It can be found as
v
u -v
uv 
u
12 Vector Fundamentals

6. Scalar Multiplication: (Scalar times a vector ) Let  be a scalar


and u a vector we define u to be the vector with length |  ||u|
with
 the direction of u if  > 0
 the opposite of u if  < 0

if  = 0, the vector is the zero vector or a point.

u 2u
-3u
13 Vector Fundamentals

7. Dot Product: Given two vectors u = a1I+b1J+c1K and v = a2I+b2J+c2K


the dot product of the vectors is defined to be the scalar as follows
u.v = a1.a2+b1. b2+c1.c2
or u.v = |u| |v| cos  , 0 ≤≤
where  is the angle between u and v
Also
cos  = u.v /|u| |v|
Or  = cos-1(u.v /|u| |v|) v
θ
u
14 Vector Fundamentals

The dot product is a scalar value that tells us something about


the relationship between two vectors
 If u·v > 0 then 0<θ < 90º
 Vectors point in the same general direction

 If u·v < 0 then θ > 90º


 Vectors point in opposite direction

 If u·v = 0 then θ = 90º


 Vectors are perpendicular
 (or one or both of the vectors is degenerate (0,0,0))
15 Vector Fundamentals

8. Cross Product: Given two vectors u = a1I+b1J+c1K and v =


a2I+b2J+c2K the cross product of the vectors is defined to be the
new vector whose length is |u||v| sin , 0 ≤≤ and direction is
given by the right hand rule.
u x v = (b1.c2 – c1. b2)I+ (c1.a2 – a1. c2)J+ (a1.b2 – b1. a2)K
u
or |u x v| = |u| |v| sin  , 0 ≤≤ where  is the angle b/w u & v
v
sin  = |u x v| /|u| |v|
uXv
Or  = sin-1(|u x v| /|u| |v|)
16 Vector Fundamentals

 In a Right handed coordinate System J

 IxJ=K
 JxK=I
 I x K = -J
or K x I = J
K I

Right-Hand
Reference System
17 3D Homogeneous Coordinates
 Similar to the 2-D situation we can use homogeneous
coordinates for 3-D transformations - 4 coordinate
y axis
column vector

y
 All transformations can
then be represented
as matrices  x  P
y
P(x, y, z) =  
 z
 
 1 z
x

z axis x axis
18 3D Homogeneous Coordinates
 Transform a point:

 px   mxx mxy mxz d x   px   mxx px  mxy py  mxz pz  d x 


 p   m myy myz d y   py   myx px  myy py  myz pz  d y 
 y    yx     
 pz   mzx mzy mzz dz   pz   mzx px  mzy py  mzz pz  dz 
      
1  0 0 0 1 1   0  0  0 1 

 px 
  
M  py   d
 pz 

 Top three rows are the affine transform!


 Bottom row stays 1
19 3D Homogeneous Coordinates
 Transform a vector:
 vx   mxx mxy mxz d x   vx   mxx vx  mxy vy  mxz vz  0 
 v   m myy myz d y   vy   myx vx  myy vy  myz vz  0 
 y    yx     
 vz   mzx mzy mzz dz   vz   mzx vx  mzy vy  mzz vz  0 
      
 0  0 0 0 1 0  0000 

 vx 
 
M  vy 
 vz 

 Top three rows are the linear transform


 Displacement d is properly ignored
 Bottom row stays 0
20 3D Homogeneous Coordinates
 In Homogeneous arithmetic Legal operations always end in
0 or 1!      
vector+vector:  0   0   0
     
     
vector-vector:  0   0   0
     
   
scalar*vector: s    
 0  0
     
point+vector:  1   0   1
     
     
point-point:  1   1   0 
     
     
point+point:  1   1   2
     
   
scalar*point: s    
 1  s
 weighted average  1   2    
  of points:  
 affine combination  3 1
 3 
 1
 1
 

21 3D Homogeneous Coordinates
 Rotation, Scale, and Translation of points and vectors
unified in a single matrix transformation:

p M p  mxx mxy mxz dx 


m myy myz dy 
Where M
 =yx 
 mzx mzy mzz dz 
 
 0 0 0 1
 Matrix has the form:
 Last row always 0,0,0,1

 Transforms compose by matrix multiplication.


3D Geometric Transformations
23

 Geometric Transformations: In Geometric transformation an


object itself is moved relative to a stationary coordinate system
or background. The mathematical statement of this view point is
described by geometric transformation applied to each point of
the object. Various Geometric transformations are:

 Translation
 Scaling
 Rotation
 Reflection
 Shearing
24 3D Geometric Transformations
 Once we have an object described, transformations are used
to move that object, scale it and rotate it
3D Geometric Translation
25

Translation is defined as the displacement of any object by a


given distance and direction from its original position. Or it
moves an object to a new location by adding translation
offsets to its coordinates.
26 3D Geometric Translation
 To translate a point in three dimensions by tx, ty and tz simply
calculate the new points as follows:
x’ = x + tx y’ = y + ty z’ = z + tz

(x, y, z)
(x’, y’, z’)
Translated Position
27 3D Geometric Translation
 The translation of a point P(x,y,z) by (tx, ty, tz) can be
written in matrix form as:

P Tv ( P ) where v tx I  ty J  tz K

1 0 0 tx   x  x
0  y
1 0 ty   y
T v  P   '  P  
0 0 1 tz  z  z
     
0 0 0 1 1  1 
28 3D Geometric Scaling
Scaling is the process of expanding or compressing the
dimensions of an object determined by the scaling factor.
29 3D Geometric Scaling
 To scale a point in three dimensions by sx, sy and sz simply
calculate the new points as follows:
x’ = sx*x y’ = sy*y z’ = sz*z

(x, y, z) (x’, y’, z’)

Scaled Position
30 3D Geometric Scaling
 The scaling of a point P(x,y,z) by scaling factors Sx, Sy and
Sz about origin can be written in matrix form as:
P Ssx, sy, sz( P ) where
 sx 0 0 0  x  x
 0 sy 0  y
0  y
Ssx, sy, sz  P   '  P  
 0 0 sz 0 z  z
     
0 0 0 1 1  1 
 x  sx 0 0 0  x   sx x 
 y 
0 sy 0 0  y   sy y 
such that  '    
z  0 0 sz 0  z   sz z 
       
1   0 0 0 1  1  1 
31 3D Geometric Rotations
 It changes the orientation of an object around a specified axis
(X, Y, or Z) using rotation matrices.
 When we performed rotations in two dimensions we only had
the choice of rotating about the z axis
 In the case of three dimensions we have more options
 Rotate about x – pitch
 Rotate about y – yaw
 Rotate about z - roll
3D Geometric Rotations
32
 Roll is known as the rising or dipping of the airplane's wing. The movement is done
about Longitudinal axis. The Ailerons controlling the roll are located on the trailing
edge of both wings.
 Pitch refers to the movement of the airplane's nose either up or down. It movement is
done about Lateral axis. The elevator controls the pitch is also located on the rear of
the aircraft on the tail, along with the rudder.
 Yaw allows the airplane to move towards the left or right while in flight. The
movement is done about a ventricle axis. The yaw is controlled by the rudder located
in the rear of the aircraft on the tail.

Roll Pitch Yaw


33 3D Geometric Rotations
 Rotate about z – axis: The picture shows a z-axis rotation
around the origin in a positive angle, (Anti-clockwise) as you
look down the z-axis towards the origin. The angle is
measured in the xy-plane from the x-axis, just as in 2D.
34 3D Geometric Rotations
 Rotate about y – axis: You are looking down the y-axis which is not
shown. A positive (counter-clockwise) angle is shown.
 N.B: The counterclockwise direction is also known as the anticlockwise
direction.
35 3D Geometric Rotations
 Rotate about x – axis: You are looking down the x-axis
which is not shown. A positive (counter-clockwise) angle is
shown.
36 3D Geometric Rotations
 The equations for the three kinds of rotations in 3-D are :

x’ = x·cosθ - y·sinθ x’ = x x’ = z·sinθ + x·cosθ


y’ = x·sinθ + y·cosθ y’ = y·cosθ - z·sinθ y’ = y
z’ = z z’ = y·sinθ + z·cosθ z’ = z·cosθ - x·sinθ
3D Geometric Rotations
37

 The scaling of a point P(x,y,z) by an angle of  about


different axis about origin can be written in matrix form as:
P R , axis( P )
 x  x  cos   sin  0 0
 y  y  sin  cos  0 0
where P  '  P   R , K  
z  z  0 0 1 0
     
1
  1   0 0 0 1
 cos  0 sin  0 1 0 0 0
 0 1 0 0   0 cos   sin  0
R , J    R , I  
  sin  0 cos  0  0 sin  cos  0
   
 0 0 0 1  0 0 0 1
38 3D Geometric Reflections
 We can perform reflections relative to a selected reflection
axis or with respect to a reflection plane.
 Reflections relative to a given axis are equivalent to 180°
rotations about that axis.
 Reflections with respect to a plane are equivalent to 180°
rotations in 4D space.
 3 standard Reflections are
 About z axis or with respect to xy plane
 About y axis or with respect to zx plane
 About x axis or with respect to yz plane
3D Geometric Reflections
39

 Reflection about XY – plane: Reflection relative to the xy


plane can be obtained from following set of equations:
x’ = x y’ = y z’ = – z
 In homogenous matrix form
1 0 0
0
0 1 0 0
P' = Mxy(P) where M xy 
0 0  1 0
 
0 0 0 1

 Reflections about other planes can also be obtained by


symmetry.
40 3D Geometric Reflections
 Reflection about XY – plane is a useful reflection as it
converts a right-handed coordinate system into a left-handed
coordinate system.
y
y

x
x
z
Inverse Transformations
41

 1
Inverse Translation: Tv T v
1
 Inverse Scaling: S sx,sy,sz S1/ sx,1/ sy,1/ sz

1
 Inverse Rotations: R , p R  , p
1
M plane M plane
 Inverse Reflections:
3D Coordinate Transformations
42

 Coordinate Transformation: The object is held stationary


while coordinate system is moved relative to the object.
These can easily be described in terms of the opposite
operation performed by Geometric transformation.
3D Coordinate Transformations
45

 Coordinate Translation: 1
T v Tv T v
1
 Coordinate Scaling: S sx,sy,sz S sx,sy,sz S1/ sx,1/ sy,1/ sz
1
 Coordinate Rotations: R , p R , p R  , p

1
 M plane M plane M plane
Coordinate Reflections:
47 Composite Transformation

 Various composite transformations are

1. Scaling about arbitrary point P


2. Tilting as rotation about x-axis followed by y-axis
3. Aligning vector V with K (Z – axis)
4. Rotation about arbitrary axis L
5. Mirror Reflection about arbitrary plane (N, R0)
48 Exercise 1

Scaling about arbitrary point P


 Imagine scaling an object around a point (a,b,c) other than the origin
 Translate point (a,b,c) to origin
 Scale around origin
 Translate back to point
49 Exercise 1
50 Exercise 1
Let P is the object point which is to be scaled by factors sx, sy and sz about the fixed
point (a,b,c). Then the composite transformation S sx,sy,sz,(a,b,c) can be obtained by
performing following sequence of transformations :
1. Translate (a,b,c) to origin and the new object point is found as
P1 = TV(P) where V= – aI – bJ– cK
2. Scale object about origin and the new object point is
P2 = Ssx,sy,sz(P1)
3. Retranslate (a,b,c) back the final object point is
PF = T-1V(P2) = T-V (P2)
The composite transformation can be obtained by back substituting
PF = T-1V(P2)
= T-V Ssx,sy,sz(P1)
= T-V Ssx,sy.TV(P) where V= – aI – bJ– cK
51 Exercise 1
Thus we form the matrix to be Ssx,sy,sz(a,b,c)= T-VSsx,sy,szTV
And the composite scaling transformation matrix is

1 0 0 a   sx 0 0 0  1 0 0  a
0 1 0 b   0 sy 0 0  0 1 0  b 
S sx, sy, sz ( a ,b ,c )   
0 0 1 c   0 0 sz 0  0 0 1  c
     
0 0 0 1   0 0 0 1  0 0 0 1
 sx 0 0  a.sx  a 
 0 sy 0  b.sy  b 

0 0 sz  c.sz  c 
 
0 0 0 1 
52 Exercise 2

Define tilting as rotation about the x-axis followed by a rotation


about y-axis.

a) Find the tilting matrix T = Ry,J x Rx,I


b) Does order of rotation matters ?
53 Exercise 3
Z axis
Aligning vector V with Vector K
Let V = aI+bJ+cK then the alignment can be
performed by following sequence of
operations:

 Rotate V about X-axis by an angle of 1, so P(a,b,c)


c
that V rotates into upper -half of the xz – V
plane. V’= R1,I(V)
a b
Y axis
 Rotate V’ about Y-axis by an angle of -2,
so that V’ rotates and align with Z – axis.
V”= R -2,J(V ’).
X axis
How to get these two angles???
54 Exercise 3
Z axis

Step1: Rotate V about X-axis by an angle of


1, so that V rotates into upper -half of the xz
V’
– plane. V’= R1,I(V) C P’(0,b,c)
Q(a,0,b2+c2
P(a,b,c)
Let P’ be projection of P(a,b,c) in YZ plane. V
1
P’↔(0,b,c). If 1 be the angle that OP
makes with +ve Z-axis, then from OP’C O B
b Y axis
sin 1  A
b2  c2
c
cos 1 
b2  c2 X axis
55 Exercise 3
Rotate vector V about X-axis by an angle of 1

V’= R1,I(V) or Q = R (P)


1,I

Where
1 0 0 0
 0 cos   sin 1 0
R1 , I  1

 0 sin 1 cos 1 0
 
0 0 0 1
b
sin 1 
b2  c2
c
cos 1 
b2  c2

Does V have rotated into upper -half of the xz – plane?


56 Exercise 3
1 0 0 0  a 
 0 cos   sin  0  b 
Q R1 , I ( P )  1 1  
 0 sin 1 cos 1 0  c 
  
 0 0 0 1   1
1 0 0 0  a 
 c b   a  cb  bc 
 0  0   b  
b 2
 c 2
b 2
 c 2
 .   b2  c2 
 b c b2  c2 
0 0  c  
 b2  c2 b2  c2   1  b2  c2 
0 0 0 1    1 
   
 a 
 0 
 2 2 
 b c 
 
 1 
57 Exercise 3
Z axis

R(0,0,a2+b2+c2)
Step2: Rotate V’ about Y-axis by an angle of
Q’(0,0,b2+c2)
– 2 , so that V’ aligns with +ve Z axis. V”=
V’
R ,I(V) a P’(0,b,c)
1
Q(a,0,b2+c2) C P(a,b,c)
Let Q’ be projection of Q(a,0,b2+c2) on Z 2 V
axis, Q’↔(0,0, b2+c2 ). If 2 be the angle
that OQ’ makes with +ve Z-axis, then from
O B
OQQ’ a Y axis
sin  2  A
a2  b2  c2
b2  c2
cos  2  X axis
a2  b2  c2
58 Exercise 3

Rotate vector V’ about Y-axis by an angle of – 2

V”= R-2,J(V’) or R = R- (Q)


2,J
 cos 1 0  sin  2 0
Where  0 1 0 0
R  2 , J 
 sin  2 0 cos  2 0
 
 0 0 0 1
a
sin  2 
a2  b2  c2
b2  c2
cos  2 
a2  b2  c2

Does V have aligned Z axis?


59 Exercise 3
 cos  2 0  sin  2 0  a 
 0 1 0 0  0 
R R  2 , J (Q)  
 sin  2 0 cos  2 0  b  c 2 2

  
 0 0 0 1  1 
 b2  c2 a 
 2 0  0  a 
2 2 2 2 2
 a b c a b c  
 0 1 0 0   0 
 2 2
.
  b c 
2 2
a b c
 0 0  
2
 a b c 2 2 2
a b c 2 2
 1 
 0 0 0 1
 a b2  c2  a b2  c2 
 2 2 2
  0 
 a b c   
0
 0   
 2
a b c 2 2
  a b c  2 2 2

 2 2 2
  
 a  b  c   1 
 1 
Exercise 3
60

Composite Matrix AV,K can be found as


R R  2 , J (Q) R  2 , J * R1 , I ( P) 
 b2  c2 a  1 0 0 0
 2 0  0  c b 
 a  b2  c2 a 2  b2  c2  0 2 2
 0
b c b2  c2
 0 1 0 0 .
 b c

a b  c2
2
0
 0 0  0 
 a2  b2  c2 a 2  b2  c2  b2  c2 b2  c2
 0 0 0 1  0 0 0 1

  ab ac 
 a  V  0
V 0  0  1 0 0 0 V V
V  c b   
  0  0  0 c b
  0   b2  c2
 a0 1 0

0 .
 b c      where
 0 
0 0 0  a b c  V  a 2  b2  c2
V V      0
 0
 0 0 1  0 0 0 1 V V V 
 0 0 0 1
Exercise 3
61

Corollary I: If both b = c =0
then  0, V  a and  2 900
 a 
0 0  0
a
 
AV , K  a0 1 0 0 .
 0 0 0
a 
0 0 0 1

R  2 , J
Exercise 3
62

Corollary II: The inverse of AV,K can be found as

A 1V , K ( R  2 , J . R1 , I )  1
1 1
R 1 , I .R  2 ,J
T T
R 1 , I .R  2 ,J
T
( R  2 , J . R1 , I )
T
( AV , K )
T
A V ,K
Exercise 4
63
Find transformation AV,N that aligns vector V = 2I – J – K with
another N = I+J+K.

 2 2   2 1 1 
 0 0    0
 6 6   3 2 3 2 3 
 2 1 1  1 1
  0 AK ,N  0  0
AV ,K  2 6 2 6  2 2 
 2   1 1 1 
1 1  0
  0
 2 6 2 6   3 3 3 
 0 0 0 1  0 0 0 1
 4 1 1 
 0
18 18 18
 
 1 2 1 2 1
    0
AV ,N  18 18 2 18 2 
 1 2 1 2 1 
     0
 18 18 2 18 2 
 0 0 0 1
64 Exercise 5

Rotation by an angle  about arbitrary axis L specified by a


direction vector V and fixed point P0.
The transformation can be found as:
1. Translate P0 to origin.
2. Align Vector V with K.
3. Rotate object about Z axis by angle .
4. Realign vector V back.
5. Retranslate P0 back.
65 Exercise 5
If P is the object point the sequence of transformations is:
1. Translate P0 to origin  P1 = T-P0(P)

2. Align Vector V with K.  P2 = AV,K(P1)


3. Rotate object about Z axis by angle .  P3 = R,K(P2)
4. Realign vector V back.  P4 = A-1V,K(P3)
5. Retranslate P0 back.  P5 = T-1-P0(P4)

Thus P5 = T-1-P0(P4)

= T-1-P0.A-1V,K(P3)

= T-1-P0.A-1V,K. R,K(P2)

= T-1-P0.A-1V,K. R,K. AV,K(P1)

= T-1-P0.A-1V,K. R,K. AV,K. T-P0(P)

Thus we form the matrix to be R,L= T-1-P A-1V,K R,K AV,KT-P


0 0
66 Exercise 5
Exercise 6
67

The pyramid is defined by A(0,0,0), B(1,0,0), C(0,1,0) and D(0,0,1) is


rotated by 450 about line L in the direction of V = J+K passing
through P(0,1,0). Find the coordinates of rotated figure.

 2 1 1 1   1 1 2 
    0 1 
 2 2 2 2   2 2 
 1 2 2 2 2 2 2
 2  2 2 4 2
1
2 2
R450 , L
 1
4 4 4   A' B' C ' D'  4 4 2 
2 2 2 2 2 2  2 2
  2 4 2 
 2 4 4 4   0 
 0 0 0 1   4 4 2 
 1 1 1 1 
68

Thank you!

You might also like