Computer Graphics Transformations: 2-D, Linear Algebra, and Homogeneous Coordinates, Study notes of Computer Graphics

An introduction to transformations in computer graphics, focusing on 2-d transformations, linear algebra, and homogeneous coordinates. Transformations are functions applied to points in space, making modeling more convenient and enabling efficient implementation of graphics systems. Linear algebra is used to represent points as vectors and understand the properties of transformations. Homogeneous coordinates are added to vectors to represent them in projective space, allowing for matrix formulation of transformations.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-r7y
koofers-user-r7y 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Today: 2-D Transformations
Transformations are functions applied to points in space
Provide a mechanism for manipulating geometric models
Transformations are essential pieces of graphics systems
OpenGL and PostScript, for instance, use them extensively
' ( )f=p p
Why Do We Need Transformations?
Makes modeling more convenient
for example, often easier to generate models around origin
gluSphere() draws a sphere of radius r about the origin
can then move them to final position with transformations
Model viewing process via transformations
projecting 3-D to 2-D will be done this way
Animation
transformations as a function of time creates motion
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Computer Graphics Transformations: 2-D, Linear Algebra, and Homogeneous Coordinates and more Study notes Computer Graphics in PDF only on Docsity!

Today: 2-D Transformations

Transformations are functions applied to points in space

Provide a mechanism for manipulating geometric models

Transformations are essential pieces of graphics systems

  • OpenGL and PostScript, for instance, use them extensively

p ' = f ( p )

Why Do We Need Transformations?

Makes modeling more convenient

  • for example, often easier to generate models around origin
    • gluSphere() draws a sphere of radius r about the origin
  • can then move them to final position with transformations

Model viewing process via transformations

  • projecting 3-D to 2-D will be done this way

Animation

  • transformations as a function of time creates motion

Linear Algebra in 30 Seconds

We represent points as vectors p = [ x y z ]

  • vectors add according to parallelogram rule
  • a linear combination of two vectors is
  • set of vectors is linearly independent if none is a linear

combination of the others

  • a basis for a space is a linearly independent set of vectors

whose linear combinations include all vectors in the space

  • but there are infinitely many possible bases

p

q

p+q

! p +" q

standard basis for 2 - D plane: 1 2

!^1 "! 0 "

e e

Linear & Affine Transformations

We’ll be specifically interested in linear transformations

  • transformation of shape determined by effect on vertices
  • a crucial property that allows for efficient implementation

And the related class of affine transformations

  • preserves affine combinations (e.g., they map lines to lines)
  • another view: a linear transformation + a translation
  • this is a more general class of functions

f (! p + " q ) =! f ( p ) +" f ( q )

f ( p + !( q " p ) ) = f ( p ) +! f ( q " p )

Rotation of Points About Origin

First, write points in polar coordinates

And solve for the new positions

Can write this as a vector equation as well

cos sin

' cos( ) ' sin( )

x y

x y

! "! "

! " #! " #

= =

= + = +

θ

φ

x

y

x

y

' cos sin

' sin cos

x x y

y x y

or

' cos sin

' sin cos

x x

y y

p = Rp

The Three Fundamental Transformations

We can represent any affine transformation as a sequence of these 3

Translation is only one not represented as matrix multiplication

  • because it’s not a linear transformation
  • wouldn’t it be nice if we could come up with a matrix formulation!

Translation:

Scaling:

Rotation:

p p d

p Sp

p Rp

Homogeneous Coordinates

Let’s add an extra dimension to our vectors

  • this added dimension is the homogeneous coordinate
  • in general, we’ll have coordinates [ x y w ]
  • the resulting 3-D space is a projective space

To convert back, divide by w and drop the last coordinate

  • all vectors [ α x α y α w ] represent the same point
  • if w= 0 , it represents a “point at infinity”

So what does this do to our transformation equations?

position: direction:

x a

x a

y b

y b

Transforms in Homogeneous Coordinates

or

x s x

y t y

p = Sp

Scaling

or

' cos sin

' sin cos

x x

y y

!!

!!

# $ # "^0 $ # $

p = Rp

Rotation

or

x x x

y y y

" # "^1 0! # "

p = Tp

Translation

Exercise: Composing Transformations

original R = rotate(60°) S = scale(1.3, 0.5) T = trans(0.2, 0.2)

What order of R , S , T

will produce this figure?

(a) TRSv

(b) RSTv

(c) TSRv

(d) RTSv

Exercise: Composing Transformations

(b) RSTv

(c) TSRv (d) RTSv

(a) TRSv

Writing Transformations in OpenGL

OpenGL maintains a current transformation matrix M

  • issue commands to post-multiply matrices into M
  • so, commands are listed in reverse order of application
  • glLoadIdentity() — set M to identity matrix (M ← I)
  • glTranslatef(Δx, Δy, Δz) — translation (M ← MT)
  • glRotatef(θ, x, y, z) — rotate about given axis (M ← MR)
  • glScalef(r, s, t) — scale by given factors (M ← MS)

Example: to rotate about an arbitrary point p = [ x y ]

glTranslatef(x, y, 0); // (3) move p back

glRotatef(theta, 0, 0, 1); // (2) rotate around z axis

glTranslatef(-x, -y, 0); // (1) move p to origin

DrawSomething();

A Word of Caution on Notation

We’ve consistently written points as column vectors

  • virtually everyone does this
  • typically represent matrices in row-major order

[[ a b ] [ c d ]]

Some in graphics have traditionally used row vectors

  • convert by transposing everything:

ABv → ( ABv )

T = v

T B

T A

T

  • note that order is reversed as well
  • typically represent matrices in column-major order

[[ a c ] [ b d ]]

  • OpenGL actually does it this way
  • but you’ll probably never notice

x a b x

y c d y

[ ' '] [ ]

a c

x y x y

b d