Docsity

2D Transforms - Introduction to Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download 2D Transforms - Introduction to Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

2D Transforms

Today

  • Vector spaces and coordinate frames
  • Transforms in 2D
  • Composing Transforms

Vector Spaces

  • For illustration, let’s flip things around i j (u,v) x y j i x y (x,y) = (-u,v)

Vector Spaces

  • Any pair of non-parallel, non-anti-parallel vectors can define a vector space in 2D - We’re used to thinking about spaces defined by orthogonal, normalized, axis-aligned vectors - But there’s no reason this is the only way to do things

2D Transforms

  • What am I talking about when I say “transforms”? - Translation (x,y) (x’,y’)
  • Scaling
  • Rotation

General Form

  • The transformations we consider are of the following form: Transformation Matrix

• Remember that the transformation

matrix describes the change in vector space: x y

Object vs. World Space

  • Makes building large models easier
  • Example: Object Space (x 0 ,y 0 ) (x 2 ,y 2 ) (x 1 ,y 1 ) World Space Docsity.com

Translation

  • Basically, just moving points
    • In 2D, up, down, left, or right
    • All points move in the same way
  • For example, we may want to move all points 4 pixels to the right and 3 down: Object Space (x,y) World Space (x+4,y-3) Docsity.com

How Do We Do It?

  • Option 1: Implement translation as a 2 - step process e is the x-offset f is the y-offset

• What are the values for our example?

So How Do We Do It?

  • Option 2: Use bigger matrices

• If we set w = 1, then

c is the x-offset f is the y-offset Docsity.com

Homogeneous Coordinates

  • We refer to this as a homogeneous coordinate:

• This mathematical construct allows us to

• Represent affine transforms with a single

matrix

• Do calculations in projective space

(vectors are unique only up to scaling)

Homogeneous Coordinates

  • For points, w must be non-zero
    • If w=1, the point is “normalized”
    • If w!=1, can normalize by

Vectors in Homogeneous

Coordinates

  • Since vectors don’t have a position, they should not be affected by translation - What about rotation/scaling?
  • Set w=0 for vectors: These have no effect

Summing up Translation

  • We will represent translation with a matrix of the following form: u is the x-offset v is the y-offset