3-D Coordinate System: - Locations Are Defined by X, Y, Z

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

3-D Coordinate System

• Locations are defined by x, y, z


3-D Coordinate System

• Locations are defined by x, y, z


Mathematical Notations

• 3D points can be described using simple


mathematical notation

P = (x, y, z)
Distance between Two 3D Points

• The distance between two points (Ax,Ay,Az)


and (Bx,By,Bz) can be found by again using
the pythagorus theorem
• Distance between A and B =
sqrt(dx2 + dy2 + dz2)
where
dx = Ax-Bx
dy = Ay-By
dz = Az-Bz
3D Vector

• a line going from the origin (0,0,0) to the


point (x,y,z).
Length of vector

• To calculate the length of a vector we simply


calculate the distance between the origin and
the point at (x,y, z) :
Operations between Points and Vectors

• point – point => vector


• point + point = point – ( - point) => vector
• vector – vector => vector
• vector + vector => vector
• point + vector => point
• point – vector = point + (-vector) => point
homogeneous coordinates
• Homogeneous coordinates: (xh, yh, h)
– Carry out operations on points and vectors
“homogeneously”
– h: Non-zero homogeneous parameter such that

– We can also write: (hx, hy, h)


– h=1 is a convenient choice so that we have (x, y, 1)
– Other values of h are useful in 3D viewing
transformations 8
2D translation matrix

9
2D rotation matrix

10
2D scaling matrix

11
Inverse transformations
Inverse translation

Inverse rotation

Inverse scaling

12
3D Translation

• Translation Distances tx, ty, tz


• For point P(x,y,z) after translation we have P′
(x′,y′,z′)
• x′ = x + tx ,
• y′ = y + ty ,
• z′ = z + tz
• (tx, ty , tz) is Translation vector
3D Translation
 • can be expressed as a single matrix equation:
P′ = P + T
Where P = P′ = T =
3D Rotation

Rotating a point requires :


1)  the coordinates for the point, and
2)  the rotation angles
3D Rotation
3D Rotation
Here we need to know three different angles:

• How far to rotate around the X axis


(YZ rotation, or “pitch”)

• How far to rotate around the Y axis


(XZ rotation, or “yaw”)

• How far to rotate around the Z axis


(XY rotation, or “roll”)
pitch
• Rotation about x-axis
(i.e. in yz plane):
• x′ = x
• y′ = y cosθ – z sinθ
• z′ = y sinθ + z cosθ
yaw
• Rotation about y-axis
(i.e. in xz plane):
• x′ = z sinθ + x cosθ
• y′ =y
• z′ = z cosθ – x sinθ
roll
• Rotation about z-axis
(i.e. in xy plane):
• x′ = x cosθ – y sinθ
• y′ = x sinθ + y cosθ
• z’ = z
3D Rotation about x-axis

 x' 1 0 0 0  x 
 y ' 0 cos   sin  0  y 
  .
 z '  0 sin  cos  0  z 
    
 1  0 0 0 1  1 
3D Rotation about y-axis

 x'  cos 0 sin  0  x 


 y '  0 1 0   
0  y 
  .
 z '   sin  0 cos  0  z 
    
1  0 0 0 1  1 
3D Rotation about z-axis

 x' cos   sin  0 0  x 


 y '  sin  cos    
0 0  y 
  .
 z'  0 0 1 0  z 
    
1  0 0 0 1  1 
3D Scaling
• Coordinate transformations for scaling relative to
the origin are
• X` = X . Sx
• Y` = Y . Sy
• Z` = Z . Sz
Uniform Scaling
• We preserve the original shape of an object with a
uniform scaling

• ( Sx = Sy = Sz)
Differential Scaling
• We do not preserve the original shape of an
object with a differential scaling

• ( Sx <> Sy <> Sz)


3D Scaling w.r.t. Origin

S x 0 0 0
0 Sy 0 0

0 0 Sz 0
 
0 0 0 1
3D Scaling w.r.t. a fixed position
• Translate the fixed point to the origin.
• Scale the object relative to the coordinate origin
• Translate the fixed point back to its original
position
3D Reflection
• In general, three-dimensional reflection
matrices are set up similarly to those for two
dimensions. Reflections relative to a given axis are
equivalent to 180 degree rotations.

You might also like