CSCE 441 Lecture 8

From Notes
Jump to navigation Jump to search

« previous | Friday, January 31, 2014 | next »


2D Transformations

Coordinates

Depends on choice of origin (0,0) and axes.

Analogous to assembly language:

  • Assembly is a necessary evil for computation
  • But we'd like to think at a higher level

Vector operations

dot product
commutative
2D cross product
Rotates by


Types of Transformations

  1. Conformal
    • Preserves angles
    • Translation, rotation, uniform scaling
  2. Affine
    • Represented by matrix multiplication
    • Translation, rotation, general scaling, shear


Translation

Add vector to point :


Uniform Scaling

origin about which to scale

Given point to scale and scaling factor ,

  1. find vector from to :
  2. scale that vector by alpha:
  3. add the vector back to to get final position:

Rearranging the terms gives

Non-Uniform Scaling

Point and vector:

  • origin point for center of scaling
  • direction of scale (assumed unit length)

Given point to scale and a scaling factor ,

  1. find vector from to :
  2. take vector projection of onto :
  3. use projection to find residual vector:
  4. scale the -parallel component of :
  5. add residual vector back in and add to origin point to get final point:

Substituting definitions and rearranging the formula gives


Rotation

Need center of rotation and angle

Given point to rotate about point ,

  1. find vector from to :
  2. set up a "coordinate system" by taking the 2D cross product
  3. using and as new axes, observe that the rotated point is at position
  4. hence the vector from to is given by
  5. Add the origin point to get the final position.


Shearing

Point and unit vector .

Given point to shear by amount ,

  1. compute
  2. set up a coordinate system by finding the 2D cross product of :
  3. project onto and to get and , respectively.
  4. the shearing vector scales (in the direction of depending on the magnitude of and :
  5. Add to get the final position

Plugging in definitions and rearranging gives


Transformations as Matrices

  • Compact representation of all affine transformations
  • allows multiple transformatinos to be represented as a single matrix
  • requires coordinates Face-sad.svg