2D TRANSFORMATION Transformations in 2D:, Exams of Computer Graphics

2D TRANSFORMATION Transformations in 2D: vector/matrix notation example: translation, scaling, rotation Homogeneous coordinates: consistent notation several other good points (later) Composition of transformations Transformations for the window system

Typology: Exams

2017/2018

Uploaded on 10/22/2018

Taranpreet31
Taranpreet31 🇮🇳

1 document

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2D transformations and
homogeneous coordinates
Dr Nicolas Holzschuch
University of Cape Town
Modified by Longin Jan Latecki
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download 2D TRANSFORMATION Transformations in 2D: and more Exams Computer Graphics in PDF only on Docsity!

2D transformations and

homogeneous coordinates

Dr Nicolas Holzschuch

University of Cape Town e-mail: [email protected] Modified by Longin Jan Latecki [email protected]

Map of the lecture

  • (^) Transformations in 2D:
    • (^) vector/matrix notation
    • (^) example: translation, scaling, rotation
  • (^) Homogeneous coordinates:
    • (^) consistent notation
    • (^) several other good points (later)
  • (^) Composition of transformations
  • (^) Transformations for the window system

Translations

  • (^) Each vertex is modified:
    • (^) x’ = x+tx
    • (^) y’ = y+ty Before (^) After

Translations: vector notation

  • (^) Use vector for the notation:
    • (^) makes things simpler
  • (^) A point is a vector:
  • (^) A translation is merely a vector

sum:

P’ = P + T

x y      

Scaling in 2D, matrix

notation

  • (^) Scaling is a matrix multiplication: P’ = S P x   y         s x 0 0 s y       x y      

Rotating in 2D

  • (^) New coordinates depend on both x

and y

  • (^) x’ = cos x - sin y
  • (^) y’ = sin x + cos y Before (^) After 

2D transformations,

summary

  • (^) Vector-matrix notation simplifies writing:
    • (^) translation is a vector sum
    • (^) rotation and scaling are matrix-vector multiplication
  • (^) I would like a consistent notation:
    • (^) that expresses all three identically
    • (^) that expresses combination of these also identically
  • (^) How to do this?

Homogeneous coordinates

  • (^) Introduced in mathematics:
    • (^) for projections and drawings
    • (^) used in artillery, architecture
    • (^) used to be classified material (in the 1850s)
  • (^) Add a third coordinate, w
  • (^) A 2D point is a 3 coordinates vector: x y w

Translations with

homogeneous

x   y  w 

1 0 t x 0 1 t y 0 0 1

x y w

x  y  w 

xwt x ywt y w

x  

w 

y 

w 

x

w

 t

x

y

w

 t

y

Scaling with homogeneous

x   y  w             s x 0 0 0 s y 0 0 0 1           x y w           x   y  w 

s x x s y y w

x 

w 

y 

w 

s

x

x

w

s

y

y

w

Composition of

transformations

  • (^) 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 around a point Q

  • (^) Rotation about a point Q:
    • (^) translate Q to origin ( T Q),
    • (^) rotate about origin ( R )
    • (^) translate back to Q ( - T Q).

P’= ( - T

Q

)R

T

Q

P

From World to Window

  • (^) Inside the application:
    • (^) application model
    • (^) coordinates related to the model
    • (^) possibly floating point
  • (^) On the screen:
    • (^) pixel coordinates
    • (^) integer
    • (^) restricted viewport: umin/umax, vmin/vmax

From Model to Viewport

xmin xmax ymin ymax