CSCE 441 Lecture 12

From Notes
Jump to navigation Jump to search

« previous | Monday, February 10, 2014 | next »


3D Transformations

The following transformations are the same:

  • Transformations
  • Uniform Scaling
  • Non-Uniform Scaling


Rotation

Rotation in 3D is slightly different.

Given a unit vector v, a point O, which is the 'origin' of v, and a point P to rotate,

  1. Compute q=PO
  2. Decompose q into its components parallel (q) and perpendicular (q) to v using vector projections:
    • q=(vq)v
    • q=qv
  3. Compute cross product v×q to define the basis for a plane perpendicular to v with q as an axis.
  4. Use v×q and q as a new 2D coordinate system.
  5. Find a new rotated form of q with (v×q)sinθ+qcosθ
  6. Add O and q to this rotated vector to get the rotated point:
P^=O+(1cosθ)q+(v×q)sinθ+qcosθ

Mirror Image

A new transformation for 3D space.

Given unit vector v, a point O, which is the 'origin' of reflection, and a point P, we will mirror p about the plane defined by the normal vector v and point O.

  1. Compute q=PO
  2. Decompose q into its components parallel (q) and perpendicular (q) to v:
    • q=projv(q)=(vq)v
    • q=qq
  3. Subtract 2q from P to get the vector from P to its reflection: P^=P2q
P^=P2((PO)v)v
Note: This is identical to non-uniform scaling with a scale factor of 1

Orthogonal Projection

Useful for projecting 3D objects onto the screen for rendering.

Given a point O, which is the 'origin' (like in mirror image), the orthogonal projection of a point P is given by:

  1. Compute q=PO
  2. Decompose q into its components parallel (q) and perpendicular (q) to v as above
  3. Subtract q from p (instead of 2q like in above)

Thus

P^=P((PO)v)v
Note: This is identical to non-uniform scaling with a scale factor of 0

Perspective Projection

Using a new point E, which is the eye of the observer, P^ is the intersection of PE and the plane defined by v and O.

  1. The equation of the plane is v(XO)=0
  2. The equation of the line from E to Pis (t)=E+t(PE)=(1t)E+tP
  3. Substitute the line equation for X in the plane equation and solve for t: v(((1t)E+tP)O)=0
  4. t=v(OE)v(PE)
  5. evaluate (t) to find the intersection point
P^=(v(OP))E+(v(EO))Pv(EP)

Precondition: PE cannot be parallel to the plane? (since denominator wold be zero)

Perspective projection of vectors is not defined because we would get different projections depending on the location of the vector to project.

Warning: Perspective transformation is not affine

3D Transformations as Matrices

Exactly like 2D, but the matrices are now 4 × 4

Similar block-structure M=[Lt01], but L is a 3 × 3 matrix.

Dot Product

Still vTw.

Cross Product

v×w=[0vzvyvz0vxvyvx0]w

Component Decomposition

  • q=vvTq
  • q=(IvvT)q

Translation

[It01][p1]=[p^1]

Uniform Scaling

What's multiplied by p?

  • αI

What's added to p?

  • (1α)o
L=αI and t=(1α)o

Non-Uniform Scaling

What's multiplied by p?

  • I
  • (α1)vvT

What's added to p?

  • (α1)vvTo
L=I+(α1)vvT and t=(1α)vvTo


Next time

Continue with rotation about an arbitrary axis.