Mee307 Cad/Cam: Dr. A.S.Sheytrabalan (Asso - Prof) Smbs
Mee307 Cad/Cam: Dr. A.S.Sheytrabalan (Asso - Prof) Smbs
Mee307 Cad/Cam: Dr. A.S.Sheytrabalan (Asso - Prof) Smbs
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
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
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 11
• 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.
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
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º.