0% found this document useful (0 votes)
98 views77 pages

03 2D-3D Geometry

The document discusses various types of transformations in 2D and 3D, including translations, rotations, scaling, and shears. It provides the mathematical representations of these transformations using homogeneous coordinates and transformation matrices. Key points include: - Transformations in 2D are represented by 2x3 matrices while in 3D they use 4x4 matrices - Common 2D transformations are translations, rotations, scaling and shearing - In 3D, transformations also include rotations about different axes, as well as compositions of multiple transformations using matrix multiplication.

Uploaded by

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

03 2D-3D Geometry

The document discusses various types of transformations in 2D and 3D, including translations, rotations, scaling, and shears. It provides the mathematical representations of these transformations using homogeneous coordinates and transformation matrices. Key points include: - Transformations in 2D are represented by 2x3 matrices while in 3D they use 4x4 matrices - Common 2D transformations are translations, rotations, scaling and shearing - In 3D, transformations also include rotations about different axes, as well as compositions of multiple transformations using matrix multiplication.

Uploaded by

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

 Types

• Scaling
• Rotation
• Shear
• Translation
 Mathematical
representation
sx

Horizontal shift proportional to horizontal position


sy
1

Vertical shift proportional to vertical position


µ
µ
µ

(this is a counterclockwise rotation; reverse signs of sines to get a clockwise one)


µ
rizontal displacement proportional to vertical position
(Shear factor h is positive for the figure above)
# Shifting Right # Shifting Up

for j in range(WIDTH): for j in range(WIDTH):


for i in range(HEIGHT): for i in range(HEIGHT):
if (i < HEIGHT-20): if (j < WIDTH - 20 and j >
img[j][i] = img[j][i+20] 20):
plt.imshow(img) img[j][i] = img[j+20][i]
plt.show() else:
img[j][i] = 0
plt.imshow(img)
plt.show()
Also used in Image Augmentation to increase
our dataset size to train robust Convolutional
Network models
 import cv2
 import numpy as np

 img = cv2.imread('messi5.jpg',0)
 rows,cols = img.shape

 M = np.float32([[1,0,100],[0,1,50]])
 dst = cv2.warpAffine(img,M,(cols,rows))

 cv2.imshow('img',dst)
 cv2.waitKey(0)
 cv2.destroyAllWindows()
 replace 2d points with 3d points, last
coordinate 1

 for a 3d point (x,y,w) the corresponding


2d point is (x/w,y/w) if w is not zero
 each 2d point (x,y) corresponds to a
line in 3d; all points on this line can be
written as [kx,ky,k] for some k.
 From homogeneous to 2d: [x,y,w]
becomes [x/w,y/w]
 From 2d to homogeneous: [x,y] becomes
[kx,ky,k] (can pick any nonzero k!)
 Full-generality 3 x 3 homogeneous
transformation is called a homography
 Full-generality 3 x 3 homogeneous
transformation is called a homography

Translation components
 Full-generality 3 x 3 homogeneous
transformation is called a homography

Scale/rotation components
 Full-generality 3 x 3 homogeneous
transformation is called a homography

Shear/rotation components
 Full-generality 3 x 3 homogeneous
transformation is called a homography

Homogeneous scaling factor


 Full-generality 3 x 3 homogeneous
transformation is called a homography

When these are zero (as they have been so far), H


is an affine transformation
 Methods for object modeling
transformation in three dimensions
are extended from two dimensional
methods by including consideration
for the z coordinate.
 Generalize from 2D by including z coordinate
 Straightforward for translation and scale,
rotation more difficult
 Homogeneous coordinates: 4 components
 Transformation matrices: 4×4 elements
 We will consider points as column vectors.
Thus, a typical point with coordinates (x, y, z)
is represented as:

 x
 y
 
 z 
 A 3D point P is represented in
homogeneous coordinates by a 4-dim. Vect:

x
 y
P 
z
 
1 
 We don't lose anything
x
 The main advantage: it is easier to  y
compose translation and rotation  
 Everything is matrix multiplication z
 
1 
 Right Hand  Left Hand coordinate
coordinate system: system:
 In homogeneous coordinates, 3D
transformations are represented by 4×4
matrixes:
a b c t
x

d e f t 
 y

g h i t
z
 
0 0 0 1
3D Translation
 P is translated to P' by:
 x  1 0 0 tx  x
 y  0 1 0 t y   y 
   
 z  0 0 1 tz   z
     
1 0 0 0 1  1 

P  T  P
 An object is translated in 3D dimensional by
transforming each of the defining points of the
objects .
 An Object represented as a set of polygon surfaces, is translated
by translate each vertex of each surface and redraw the polygon
facets in the new position.

 x ' , y ' , z '


T  t x , t y , t z 
 x, y , z 

 Inverse Translation:
T (t , t , t )  T (t ,t ,t )
1
x y z x y z
3D Rotation
 In general, rotations are specified by a
rotation axis and an angle. In
two-dimensions there is only one
choice of a rotation axis that leaves
points in the plane.
 The easiest rotation axes are those that parallel to the
coordinate axis.
 Positive rotation angles produce counterclockwise rotations
about a coordinate axix, if we are looking along the positive half
of the axis toward the coordinate origin.
Coordinate Axis
Rotations
 Z-axis rotation: For z axis same as 2D rotation:
 x' cos   sin  0 0  x 
 y '  sin  cos  0 0  y 
  
 z'  0 0 1 0  z 
     
1  0 0 0 1  1 

P   R z (θ )  P
 X-axis rotation:
 x '  1 0 0 0  x 
 y ' 0 cos   sin  0  y 
   
 z '  0 sin  cos  0  z 
     
 1  0 0 0 1  1 

P   R x ( )  P
 Y-axis rotation:
 x'  cos  0 sin  0  x 
 y '  0 1 0 0  y 
   
 z '   sin  0 cos  0  z 
     
1  0 0 0 1  1 

P   R ( )  P
y
Other way to look at
rotation
Roll, Pitch, Yaw
 Imagine three lines running through an
airplane and intersecting at right
angles at the airplane's center of
gravity.
 Roll: rotation around the front-to-back
axis.
 PITCH: Rotation around the side-to-side
axis
 YAW: Rotation around the vertical axis.
An Example of the
Airplane
 Consider the following example. An airplane is oriented
such that its nose is pointing in the positive z direction,
its right wing is pointing in the positive x direction, its
cockpit is pointing in the positive y direction. We want
to transform the airplane so that it heads in the direction
given by the vector DOF (direction of flight), is centre
at P, and is not banked.
3D Scaling
 About origin: Changes the size of the object and
repositions the object relative to the coordinate origin.
 x  s x 0 0 0  x 
 y   0 sy 0 0  y 
  
 z   0 0 sz 0  z 
     
1 0 0 0 1  1 
P  S  P
Composite
3D Transformations
 Multiply matrices
 Rightmost term in matrix product is the first
transformation to be applied
Rotation axis parallel with coordinate axis (Example x axis):

P  T 1
 R x (θ )  T  P
An arbitrary axis (with the rotation axis projected onto the Z
axis):

R ( )  T 1  R x 1 ( )  R y1 (  )  R z ( )  R y (  )  R x ( )  T
 To compose transformations, multiply
the matrices:
• composition of a rotation and a translation:
M = RT
 all transformations can be expressed
as matrices
• even transformations that are not
translations, rotations and scaling
 Rotation about a point Q:
• translate Q to origin (TQ),
• rotate about origin (R)
• translate back to Q (- TQ).

P’=(-TQ)RTQ P

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