0% found this document useful (0 votes)
72 views114 pages

CAED KJHA 2d Transformation

This course provides an overview of computer aided engineering design and geometric modeling. The objectives are to impart knowledge of computational aspects of engineering drawing, geometric modeling, and design automation. Key topics covered include 2D and 3D geometric transformations using matrices, modeling of curves, surfaces, and solids, and programming techniques for computer graphics. Transformations such as translation, rotation, scaling, and homogeneous coordinates are discussed to represent geometric objects in different orientations for modeling and design applications.

Uploaded by

Anu Singh
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)
72 views114 pages

CAED KJHA 2d Transformation

This course provides an overview of computer aided engineering design and geometric modeling. The objectives are to impart knowledge of computational aspects of engineering drawing, geometric modeling, and design automation. Key topics covered include 2D and 3D geometric transformations using matrices, modeling of curves, surfaces, and solids, and programming techniques for computer graphics. Transformations such as translation, rotation, scaling, and homogeneous coordinates are discussed to represent geometric objects in different orientations for modeling and design applications.

Uploaded by

Anu Singh
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/ 114

Computer Aided Engineering

Design(MEC504)
M. Tech. (Machine Design)

Kailash Jha
Associate Professor
Dept. of Mechanical Engineering
COURSE OBJECTIVES

• To impart knowledge dealing with computation


aspects of engineering drawing and geometric
modeling.
• This course is essential for design automation. It
is the first step in all engineering
analysisGeometric Transformations
Outcome of the course

• get basic knowledge of different transformations


which will be very useful in robotic and
mechatronics
• get mathematic details of the projections used in
mechanical Engineering for visualization
• learn the concepts of parametric curves and
surface modeling
• learn the basic techniques of representation of
solids.
Syllabus

• Overview of computer graphics: Introduction to


CAD and Geometric Modeling, advantages of CAD,
computer graphics software.

• 2-D Transformations: Transformations of points


and straight lines, midpoint transformation,
transformation of parallel lines and intersecting
lines, rotation, reflection, scaling, combined
transformations, solid body transformations,
translations and homogeneous coordinates,
rotation about an arbitrary point, reflection
through an arbitrary line, projection.
Syllabus

• 3-D Transformations: 3-D scaling, shearing,


rotation, reflection and translation, rotation about
an arbitrary axis in space, reflection through an
arbitrary plane, affine and perspective geometry,
orthographic and axonometric projections,
techniques for generating perspective views,
vanishing points, stereographic projection,
reconstruction of 3-D images.
• Plane curves: Introduction to geometrical
modeling, representation of parametric curves,
composite curves, rational curves, interpolation,
intersection of curves
Syllabus
• Surface description and generation: Surfaces of
revolution, sweep surfaces, quadratic surfaces,
mapping parametric surfaces, Bilinear surface,
ruled and developable surfaces, linear Coons
surface, Coons bicubic surface, Bezier and B-
spline surfaces, Gaussian curvature and surface
fairness.
• Solid Modeling and Programming: Introduction to
solid modeling, feature based design,
• Introduction of object oriented programming, and
introduction to OpenGL...
OVERVIEW OF THE COURSE

• Geometric Transformations
• Introduction to Projections
• Modeling of Curves
• Modeling of Surfaces
• Modeling of Solids
• Programming Techniques
• Introduction of OpenGL
Geometric Transformations

To see the object in different orientations


To model the higher order objects
To facilitate different Boolean operations
OVERVIEW

• Representation of points
• Two dimensional transformations
• Matrix representations
• Inverse transformations
• Three dimensional transformations
• Multiple transformations
Point Representation

• Previously, point in 2D as column matrix

 x
 x  
   y
 y 1
 

• Now, extending to 3D, add z-component:


 x  Px 
   
 y or  Py 
 z P 
  Pz
1  
  1
 
Point Representation as row vector

• Previously, point in 2D as row matrix

X Y X Y 1

• Now, extending to 3D, add z-component:

X Y Z 1 or P   Px Py Pz 1
Geometric transformation functions

• Translation
• Rotation
• Scaling
• Reflection
• Shearing

• We first discuss the 2D transformations, then we


will continue with 3D.
2D Translations

Point P defined as P( x, y ),
translate to Point P( x, y) a distance d x parallel to x axis, d y parallel to y axis.
x  x  d x y   y  d y
Define the column vectors
 x  x  d x 
P    , P    , T   
 y  y  dy  P’
P
Now
P  P  T
2D Transformation.

Point P defined as P ( x, y ),
Perform a 2d tranformation to a Point P( x, y) by a Matrix S

Define the matrix


a c 
S 
 b d 
Now
 x   a c   x 
P  S  P or  y  b d . y 
    
2D Scaling from the origin.
if b  c  0
if a  1 and d  1 it is called identity tranformation
if a  -1 and d  1 it is called reflection y - axix
if a  1 and d  -1 it is called reflection about x - axis
if a  d  0 it is called reflection about origin
if a  d  1
c  0 then it is called shearing transformation
proprtional to x - coordinate.
b  0 then it is called shearing transformation
proprtional to y - coordinate

 x   a c   x 
P  S  P or  y  b d . y 
    
2D Scaling from the origin. Px Py Pz 1

if b and c is zero than the transformation is called scaling


Sx and Sy is same then the scaling is called uniform and non - uniform
x  a.x, y  d . y
Define the matrix
P’
a 0 
S 
P
 0 d 
Now
 x   a 0   x 
P  S  P or  y  0 d . y 
    
2D Scaling and reflection Transformations
2D Shearing Transformation
2D Transformation of square.
2D Rotation about the origin.


P’(x’,y’)

P(x,y)
r

r
x
2D Rotation about the origin.
y

P’(x’,y’)

r
P(x,y) x  r. cos 
y  r. sin 
 y
r

x
x
2D Rotation about the origin.

x  r. cos(   )  r. cos  . cos  r. sin  . sin 


y y  r. sin(   )  r. cos  . sin   r. sin  . cos

P’(x’,y’)

P(x,y)
r x  r. cos 
y  r. sin 
 y
r

x
x
2D Rotation about the origin.

x  r. cos(   )  r. cos  . cos   r. sin  . sin 


y  r. sin(   )  r. cos  . sin   r. sin  . cos 
Substituting for r :

x  r. cos 
y  r. sin 
Gives us :

x  x. cos  y. sin 
y  x. sin   y. cos
2D Rotation about the origin.

x  x. cos   y. sin 
y  x. sin   y. cos 

Rewriting in matrix form gives us :

 x  cos   sin    x 
 y   sin  . 
cos    y 
  

cos  sin  
Define the matrix R    , P  R  P
 sin  cos 
Transformations.

• Translation.
– P = T + P
• Scale
– P = S  P
• Rotation
– P = R  P
• We would like all transformations to be multiplications so we can
concatenate them  express points in homogenous
coordinates.
Similar transformation using row vector

a b 
 x y   x y . 
c d 

 cos( ) sin( ) 
 x y   x y . 
 sin( ) cos( )
Origin can not be transformed in 2D
transformation

0 
 x   a c  0  
 y  b d .0 0 
      

a b   0 0
 x y   0 0   

 
c d   
Homogeneous coordinates
• Add an extra coordinate, h, to a point.
– P(x,y,h).
• Two sets of homogeneous coordinates represent the
same point if they are a multiple of each other.
– (2,5,3) and (4,10,6) represent the same point.
• At least one component must be non-zero  (0,0,0) is
not defined.
• If  0 , divide by it to get Cartesian coordinates of point
(x/h,y/h,1).
• If h=0, point is said to be at infinity.
Homogeneous coordinates ∅
• If we represent (x,y,h) in 3-space, all triples representing the same
point describe a line passing through the origin.
• If we homogenize the point, we get a point of form (x,y,1)
– homogenised points form a plane at h=1.

W P

W=1 plane

Y
Translate 2D point in x and y directions
by m and n unit

h = h

 x  a c m  x 
 y'   .b d n . y 
    
h  0 0 h  1 
Homogeneous coordinate using
geometry having row matrix

 a b 0

 x' y' h    x y 1 . c d 0 
m n h 
Generalized 2D-homogeneous
coordinate
 a b p
 c d q
 
m n h 
p 
a b  q 
c d   
  P and q are Perspective
Rotations, Shearings, reflections,
transformations
uniform and non-uniform scalings

m n
M and n is responsible for translation in
x and y directions
Now Origin can be transformed

 1 0 0

 x' y' 1   0 0 1 . 0 1 0
m n 1

 x' y' 1   m n 1 
Technique to solve two linear equations

3 / 5 2 / 5
Matrix technique to solve two linear
equations
Realization of Intersection of parallel
lines
Realization of Intersection of parallel
lines
Realization of Intersection of parallel
lines
Realization of Intersection of parallel
lines
Translations in homogenised
coordinates
• Transformation matrices for 2D translation are
now 3x3.

1 0 0 x  x  d x
 
 x y' 1   x y 1  0 1 0. y  y  d y
d x dy 1 11

Concatenation.

• We perform 2 translations on the same point:

P  P  T (d x1 , d y1 )
P  P  T (d x 2 , d y 2 )
P  P  T (d x1 , d y1 )  T (d x 2 , d y 2 )  P  T (d x1  d x 2 , d y1  d y 2 )

So we expect :
T (d x1 , d y1 )  T (d x 2 , d y 2 )  T (d x1  d x 2 , d y1  d y 2 )
Concatenation.

The matrix product T (d x1 , d y1 )  T (d x 2 , d y 2 ) is :


1 0 0  1 0 0
  
0 1 0. 0 1 0  ?
d x1 d y1 1 d x 2 d y2 1

Matrix product is variously referred to as compounding,
concatenation, or composition
The matrix product T (d x1 , d y1 )  T (d x 2 , d y 2 ) is :
1 0 0  1 0 0  1 0 0
    
0 1 0. 0 1 0   0 1 0
d x1 d y1 1 d x 2 d y2 1 d x1  d x 2 d y1  d y 2 1

Matrix product is variously referred to as compounding, concatenation, or


composition.
This single matrix is called the Coordinate Transformation Matrix or CTM.
Properties of translations.

1. T (0,0)  I
2. T ( s x , s y )  T (t x , t y )  T ( s x  t x , s y  t y )
3. T ( s x , s y )  T (t x , t y )  T (t x , t y )  T ( s x , s y )
4. T -1 ( s x , s y )  T ( s x , s y )

Note : 3. translation matrices are commutative.


Homogeneous form of scale.

Recall the (x,y) form of Scale : sx 0


S (sx , s y )  
0 s y 

In homogeneous coordinates :

sx 0 0
S ( s x , s y )   0 sy 0
 0 0 1
Concatenation of scales.

The matrix product S ( s x1 , s y1 )  S ( s x 2 , s y 2 ) is :


s x1 0 0  s x2 0 0  s x1  s x2 0 0
0 s 0  . 0 s 0    0 s  s 0 
 y1  y2   y1 y2 
 0 0 1   0 0 1   0 0 1
Only diagonal elements in the matrix - easy to multiply !
Reflection

corresponds to negative scale factors

sx = -1 sy = 1 original

sx = -1 sy = -1 sx = 1 sy = -1
Homogeneous form of rotation.

 cos  sin  0 
 x' y' 1   x y 1  sin  cos  0 
 0 0 1 

For rotation matrices,


R ( )  R( ).
1

Rotation matrices are orthogonal, i.e :


R 1 ( )  R T ( )
i.e. the inverse is the transpose
Orthogonality of rotation matrices.

 cos  sin  0  cos   sin  0 


R( )   sin  cos  0 , R T ( )   sin  cos  0 
 0 0 1   0 0 1 

 cos  sin   0  cos   sin  0 


R( )   sin   cos  0    sin  cos  0 
 0 0 1   0 0 1 
Perspective transformation

1 0 p 
 x' y' 1   x y 1 .0 1 q 
 
0 0 1 
  x y (px  qy  1) 
  x/ (px  qy  1) y/ (px  qy  1) 1 
Perspective transformation
Composite transformation
The matrix product R( )  S (Ø) is :
 cos  sin  0   cos Ø sin Ø 0 
 sin  cos  0 . sin Ø cos Ø 0  
  
 0 0 1   0 0 1 
 cos  cos Ø  sin  sin Ø cos  sin Ø  sin  cos Ø 0 
 cos sin Ø  sin  cos Ø cos  cos Ø  sin  sin Ø 0  
 
 0 0 1 

 cos(  Ø) sin(  Ø) 0 
 sin(  Ø) cos(  Ø) 0   R (  Ø)
 
 0 0 1 
Concatenation of scales.
Other properties of rotation.

R (0)  I
R ( )  R ( )  R(   )

and
R ( )  R ( )  R( )  R ( )
only if the centres of rotation are the same,
Otherwise order matters.
2D Composite Transformations

• Combine transformations of different type


– translate, rotate, translate
– translate, scale, translate
– translate, reflect, translate
• Use to rotate or scale an object w.r.t. a point that
is not the origin
• Implement by multiplication of the corresponding
homogeneous matrices
T (m, n)  R( ))  T (m, n)
T ( m, n)  S (s x1 , s y1 )  T (m, n)

1 0 0  s x1 0 0   1 0 0   s x1 0 0
0 1 0 . 0 s 0 . 0 1 0    0 s 0

  y1    y1 
- m  n 1   0 0 1  m n 1  m(1 - Sx1 ) n(1 - Sy1) 1
reflection in x and y axes reflection in origin
1 a   x   x  a y 
0 1   y    y 
     
1 0   x   x 
b 1   y   b x  y 
     Sh gives the slope
x
of a vertical line
after shear, as dx/dy
Reflection about an arbitrary line in 2D
homogeneous coordinate system

1. Translate the first point of the line to origin


2. Rotate line to coincide with one of the axis
3. Multiply with the reflection about the coincident axis
4. Reverse of the rptaion
5. Translate back the point at original positiom
T (m,n)  R( )  R(Re flection)  R  1( )  T (m, n)
Example 1
1 0.4
T ( x, y )   x y   
y 0 1 
  x 0.4x  y
(0,1) (1,1)

S
(0,0) (1,0) x
Example 1

T ( x, y )   x 0.4x  y
y

(0,1) (1,1)

S
(0,0) (1,0) x
Example 1

y (1, 1.4)

T ( x, y )   x 0.4x  y
(0,1)

T(S)
(1, 0.4)

(0,0)
x
Example 2
 1 0
T ( x, y )   x y   
0.6 1
y   x  0 .6 y y 
(0,1) (1,1)

S
(0,0) (1,0)
x
Example 2

(0,1) (1,1)

S
(0,0) (1,0) x
Example 2

T ( x , y )   x  0. 6 y y 
y

(0,1) (0.6, 1) (1.6, 1)

T(S)
(0,0) (1, 0) x
Summary

Shear in x:
1 shx   x   x  shx y 
Shx        
0 1   y   y 
Shear in y:

 1 0  x   x 
Shy       
sh
 y 1  y   shy .x  y 
Double Shear: not commutative!

1 a  1 0 (1  ab) a 
0 1  b 1   b 1

   
1 0 1 a  1 a 

b 1 0 1  b (1  ab)
    
Shear Matrix defined by angle, not slope

e.g. simple shear along x axis

x’ = x + y cot 
y’ = y
z’ = z

1 cot  0 0
0 1 
0 0
H() = 
0 0 1 0
 
0 0 0 1
3D Homogeneous Transformations.
• Use homogeneous coordinates, just as in 2D case.
• Transformations are now 4x4 matrices.

 a b c p a b c
d e f q  d e f  Rotations, Shearings,
scalings, reflections
  
g j k r   g j k 
 
 l m n h
p 
q  Perspective
 
l m n  r 
transformations

Translations
3D Transformations.

• We will use a right-handed (world) coordinate system -


( z out of page ).
1 cot  0 0
0 1 0 0

0 0 1 0
 
0 0 0 1

Note:
Convenient to think of display as
Being left-handed !!
x
( z into the screen )
z (out of page)
Simple extension to the 3D case:

1 0 0 0
0 1 
 P'   P  0 0
0 0 1 0
 
l m n 1
Scale in 3D.

Simple extension to the 3D case:

s x 0 0 0
0 sy 0 0
S (s x , s y , s z )  
0 0 sz 0
 
0 0 0 1
Rotation in 3D
• Need to specify which axis the rotation is about.
• z-axis rotation is the same as the 2D case.

 cos  sin  0 0
 sin  cos  0 0
Rz ( )  
 0 0 1 0
 
 0 0 0 1
Rotation about coordinate axis
 cos  sin  0 0 1 0 0 0
 sin  cos  0 0 0 cos  sin  0
Rz ( )   Rx ( )  
 0 0 1 0 0  sin  cos  0
   
 0 0 0 1 0 0 0 1

cos  0  sin  0
 0 1 0 0
R y ( )  
 sin  0 cos  0
 
 0 0 0 1

 P' ]  [P] .[R( )


Rotation about x and y axises
Reflection about xy-plane
1 0 0 0
0 1 0 0
Rreflection _ xy ( )  
0 0 1 0
 
0 0 0 1

 P'  [P] .[R( )


Reflection about xy-plane
3D Shearing
3D Shearing α β
Example
Rotation around an axis parallel to x-axis
Rotation around an axis parallel to x-axis
Rotation around an axis inclined to
coordinate axis and parellel to the
coordinate plane

1. Translate the first point of the line to origin


2. Rotate line to coincide with one of the axis
3. Multiply with the reflection about the coincident axis
4. Reverse of the rptaion
5. Translate back the point at original positiom
Rotation around an axis in space

1. Translate the first point of the line to origin


2. Perform appropriate rotates to coincide the
transformed line with one of the axis
3. Rotate about the coincided axis with stated angles
4. Reverse of the combination of rotations
5. Translate back the point at original position
Rotation around an axis in space

Find normal components of the given axis(Cx, Cy, Cz)


Rotation around an axis in space
Rotation around an axis in space
Rotation around an axis in space

d 0  Cx 0
0 1 0 
0
Inv[ R y (alpha)]  
Cx 0 d 0
 
0 0 0 1

1 0 0 0
0 Cx / d  Cy / d 0
Inv[ Rx (alpha)]  
0 Cy / d Cx / d 0
 
0 0 0 1
Rotation around an axis in space

Write matrices for rotation about an


arbitrary axis passes through point
p1(2 1 1) and p2(3 2 2) by -45 degree.
Rotation around an axis in space
Rotation around an axis in space

Te =
Rotation around an axis in space

Transformed geometry
Input geometry
Rotation around an axis in space

1. Translate the first point of the line to origin


2. Perform appropriate rotates to coincide the
transformed line with one of the axis
3. Reflect about the coincided axis
4. Reverse of the combination of rotations
5. Translate back the point at original position
Rotation around an axis in space

Find normal components of the given axis(Cx, Cy, Cz)


Rotation around an axis in space
Rotation around an axis in space
Rotation around an axis in space

d 0  Cx 0
0 1 0 
0
Inv[ R y (alpha)]  
Cx 0 d 0
 
0 0 0 1

1 0 0 0
0 Cx / d  Cy / d 0
Inv[ Rx (alpha)]  
0 Cy / d Cx / d 0
 
0 0 0 1
Rotation around an axis in space

Write matrices for rotation about an


arbitrary axis passes through point
p1(2 1 1) and p2(3 2 2) by -45 degree.

You might also like