Docsity

Homogeneous Coordinates - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Homogeneous Coordinates - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics

Lecture 12

2D Transformations II

Homogeneous Coordinates

Translation:

P′ = P + T

Rotation:

P′ = R. P

Scaling:

P′ = S. P Docsity.com

Can we find a way to eliminate the matrix addition associated with translation? Yes, we can. But for that M 1 will have to be rewritten as a 3x3 matrix and also the coordinate positions will have to be expressed as a homogeneous coordinate triple: (x, y) as (xh, yh, h) where xh yh x = –––– , y = –––– h h

For simplicity, 1 is used as value for h in affine transformations, thus (x, y) has homogeneous coordinates as (x, y, 1)

The rotation can now be expressed using homogeneous coordinates as:

Abbreviated as: P’ = R (θ). P

 

 

 

 

   

 

 

1

. 0 0 1

sin cos 0

cos sin 0

1

'

' y

x y

x  

 

Rotation with Homogeneous Coordinates

The scaling can now be expressed using homogeneous coordinates as:

Abbreviated as: P’ = S (Sx, Sy). P

 

 

 

 

  

 

 

1

. 0 0 1

0 0

0 0

1

'

' y

x S

S y

x y

x

Scaling with Homogeneous Coordinates

Which means that T(tx2,ty2). T(tx1,ty1) = T(tx1 + tx2 , ty1 + ty2) hence

 

  

1

. 0 0 1

0 1

1 0

1

'

' 1 2

1 2 y

x t t

t t y

x y y

x x

Composite Translations

Two successive Rotations applied to a point P produce: P’ = R(θ 2 ). {R(θ 1 ). P} = {R(θ 2 ). R(θ 1 )}. P But since, R(θ 2 ). R(θ 1 ) = R(θ 1 + θ 2 ) Therefore, P’ = R(θ 1 + θ 2 ). P

Composite Rotations

  • General pivot point (xr,yr)
  • Translate-Rotate-Translate
  • Translate the object to coincide the pivot with the origin
  • Rotate about the origin
  • Translate back to the original pivot position

General Pivot Point Rotation

General Fixed Point Scaling

 General fixed point (xf,yf)

 Translate-Scale-Translate

 Translate the object to coincide the

fixed point with the origin

 Scale w.r.t. origin

 Translate the object back to the

original position

General Composite Transformations and Computational Efficiency

Translations-Rotations-Scalings

  

1

. 1 0 0 1

'

' y

x rs rs trs

rs rs trs y

x

yx yy y

xx xy x

 rsij are Rotation-Scaling terms

 trsi are the translational terms

 It takes 9 multiplications and 6

additions to evaluate but explicit

calculations for transformed-coords:

 x’ = x.rsxx + y.rsxy + trsx

 y’ = x.rsyx + y.rsyy + trsy

 i.e. 4 multiplications and 4 additions