You are on page 1of 32

MEE307 CAD/CAM

Dr. A.S.Sheytrabalan (Asso.Prof)


SMBS
Course Objective
•To understand the role and requirements of geometric
modeling in manufacturing
•To study the different types of geometric modeling
techniques
•To recognize the different types geometric entities and
its mathematical representations

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 2


Unit II- Principles of Computer Graphics

• Geometric Modelling – Wireframe, Surface and Solid –


Parametric representation of curves & surfaces –CSG and
B-Rep- World/device coordinate representations, 2D
and 3D geometric transformations, Matrix
representation, translation, scaling, shearing, rotation
and reflection, composite transformations,
concatenation

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 3


Geometric Modelling

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 4


Wireframe Modeling

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 5


Surface Modeling

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 6


Coordinate axes and transformation
• Coordinate axes
– Model coordinate system
– World coordinate system
– Screen coordinate system
• Transformations
• Translation
• Rotation
• Scaling
• Shear
Model Coordinate System
• MCS is defined as the reference
space of the model with respect
to which all the model
geometrical data is stored.

• The origin of MCS can be


arbitrary chosen by the user.

• Every object have its own MCS


relative to which its geometrical
data is stored.
World Coordinate System

• Multiple objects in the same


working space, then there is need
of a World Coordinate System
which relates each MCS to each
other with respect to the
y
orientation of the WCS.
z
x
Screen Coordinate System
• SCS is defined as a two dimensional device-
dependent coordinate system.

• Origin is usually located at the lower left


corner of the graphics display as shown in
the picture below.

• A transformation operation from MCS


coordinates to SCS coordinates is
performed by the software before displaying
the model views and graphics.
Transformation
• "Transformation" is the elementary term used for a variety of
operation such as translation, rotation, scaling, reflection,
shearing etc.
• CAD requires transformations from conceptual design and
layout, through detailed engineering and analysis of
components to definition of manufacturing methods.
• Every aspect of modeling in CAD is dependent on the
transformation to view model from different directions we
need to perform rotation operation.
• To move an object to a different location translation operation
is done.
• Similarly Scaling operation is done to resize the object.
What is transformation ?
Representation of transformations using
Matrix operations
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 P’
P
x  x  d x 
P    , P    , T   
 y  y d y 
Now
P  P  T
2D Translation
• Repositioning an object along a straight line path from one co-ordinate
location to another
(x,y) (x’,y’)
To translate a 2D position, we add translation distances tx and ty to the
original coordinates (x,y) to obtain the new coordinate position
(x’,y’)
x’= x + tx , y’= y + ty
y
Matrix form

 x   x   t x 
 y    y    t  T
     y
P  P  T x
2D Rotation about the origin.
Repositioning an object along a circular path in the xy-plane

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  Substituting for r : x  r . cos 
y  r. sin(   )  r. cos  . sin   r. sin  . cos  y  r . sin 
Given us: 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 
2D Rotation about a Pivot position
• Rotating about pivot position (xr, yr)
y

(x’,y’)
r

θ r
φ (x,y)
yr
xr x

x  xr  ( x  xr ) cos   ( y  yr ) sin 

y  yr  ( x  xr )sin   ( y  yr ) cos 
2D Scaling from the origin.
PointP definedas P(x, y),
Performa scale(stretch)to PointP(x, y) by a factorsx alongthe x axis,
andsy alongthey axis.
x  sx .x, y  sy .y
Definethematrix
P’
sx 0  P
S  
 0 s y

Now
x sx 0  x
P  S  P or     . 
y  0 sy  y
2D Scaling
• Altering the size of an object. Sx and Sy are the scaling factors.
• If Sx = Sy then uniform scaling.
y
x  xS x
y  yS y
Matrix form Sx = Sy = ½ x

 x   S x 0  x 
    0  
Sy  y 
y  
P  S  P x’ x
Sx = Sy = ½
Reduced in size and moved
closer to the origin
2D Scaling relative to Fixed point
• Scaling relative to fixed point (xf, yf)

x  x f  ( x  x f ) S x y P1
P1’
(xf , yf)
y  y f  ( y  y f ) S y P 2’ P2
P3’
OR P3

x  xS x  x f (1  S x ) Sx = ¼ , Sy = ½ x

y  yS y  y f (1  S y )

where the additive terms xf(1-Sx) and yf(1-Sy) are constants for all
points in the object.
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.
Homogeneous coordinates
• If we represent (x,y,w) 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 W=1.

W P

W=1 plane

Y
Translations in homogenised coordinates
• Transformation matrices for 2D translation are now 3x3.
 x   1 0 d x   x  x  x  d x
 y  0 1 d . y 
   y   y  y  d y
 1  0 0 1   1  11
• 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 d x1  1 0 d x 2  1 0 d x1  d x 2 
0 1 d .0 1 d   0 1 d  d 
 y1   y2   y1 y2 

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


Matrix product is variously referred to as compounding, concatenation, or
composition.
This single matrix is called the Coordinate Transformation Matrix or CTM.
Reflection

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 25


Reflection

9-Sep-15 MEE307 CAD-CAM VIT VELLORE 26


Matrix Representation
• Use 3×3 matrices to combine transformations
 x   1 0 t x  x 
• Translation     
y
    0 1 t y  y 
 1   0 0 1  1 
    

 x   cos   sin  0  x 
• Rotation     
 y    sin  cos  0  y 
1  0 0 1  
    1 

 x   S x 0 0  x 
• Scaling     
y  0 Sy 0  y 
1  0 0 1  1 
    
Inverse Transformations

 1 0 t x 
• Translation  
T 1   0 1 t y 
0 0 1 
 

 cos  sin  0 
• Rotation  
R 1    sin  cos  0 
 0 0 1 

 S1x 0 0
 
• Scaling 1
S  0 1
Sy 0
 
0 0 1
Example
• Consider the line with endpoints (10, 10) and (30, 25). Translate it by tx
= -20, ty = -10 and then rotate it by θ = 90º.
y
(30, 25)

(10, 10)

Right-to-left

 x   cos 90  sin 90 0  1 0 20  x 


     
y
    sin 90  cos 90 0  0 1 10  y 
1  0 0 1   
    0 0 1  1 
Solution
 x   cos 90  sin 90 0  1 0 20  x 
     
y
    sin 90  cos 90 0  0 1 10  y 
1  0 0 1   
    0 0 1  1 

 0 1 0  1 0 20   x 
   
  1 0 0  0 1 10   y 
 0 0 1  0 0 1   1 
   

 0 1 10   x 
   y
  1 0 20   y  (30, 25)
0 0 1  1 
  
(10, 10)

x
Solution (continue)
 x   0 1 10  x  y
    
y
    1 0 20  y  (30, 25)
 1  0 0 1  1  (-15, 10)
     (10, 10)
x
(0, -10)
Point (10, 10)
 x   0 1 10  10   0 
      
y
    1 0 20 10
   10 
 1  0 0 1  1   1 
      
Point (30, 25)
 x   0 1 10  30   15 
      
y
    1 0 20 25
   10 
 1  0 0 1  1   1 
      
Exercises
• Consider the following object:

25

10

10 45 x

1. Apply a rotation by 145º then scale it by Sx=2 and Sy=1.5 and then
translate it by tx=20 and ty=-30.
2. Scale it by Sx=½ and Sy=2 and then rotate it by 30º.
3. Apply a rotation by 90º and then another rotation by 45º.
4. Apply a rotation by 135º.

You might also like