Geometric Transformations - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

Geometric Transformations

Description:

Magnitude (e.g. real numbers) Vector u, v, w, x. Direction. Magnitude. No Position ... No Magnitude. All figures are extracted from Angle's book. 7. 7 ... – PowerPoint PPT presentation

Number of Views:367
Avg rating:3.0/5.0
Slides: 53
Provided by: compHk
Category:

less

Transcript and Presenter's Notes

Title: Geometric Transformations


1
Geometric Transformations
  • In this chapter, you will learn
  • Scalars, points and vectors
  • Vector and affine spaces
  • Changes of coordinate systems
  • Homogeneous coordinates (and why we need)
  • Affine transformation translation, rotation,
    scaling and shearing
  • Transformations in homogeneous coordinates
  • Concatenation of transformations
  • Geometric transformation using OpenGL

2
Transformations
  • Maps an object into another object
  • In general, a transformation maps every point on
    an object to another point in the underlying
    coordinate space.
  • Why do we want/need transformations?
  • Change size, location, orientation of objects
    without changing underlying model (or primitive
    drawing commands)
  • Animation
  • Instancing

3
What Do We Require of Transforms?Line Preserving
P1
Line Not Preserved
P2
4
Geometric Pipeline
Pixels
Vertices
Transformer
Clipper
Projector
Rasterizer
5
Vector Space vs Affine Space
  • Vector Space
  • Contains 2 distinct entities vectors and scalars
  • Supports 2 operations addition and
    multiplication
  • Scalar-vector multiplication and vector-vector
    addition
  • Affine space
  • Extension of vector space
  • Supports
  • Vector-point addition that produces a new point
  • Point-point subtraction that produces a vector
  • Euclidean space
  • Extension of vector space that adds a measure of
    size or distance

6
Abstract Data TypesAffine Space
  • Scalar a, b, d, e
  • Magnitude (e.g. real numbers)
  • Vector u, v, w, x
  • Direction
  • Magnitude
  • No Position
  • Point P, Q, R, X
  • Position
  • No Direction
  • No Magnitude

7
Commutative, Associative and Distributive
  • Commutative
  • ab ba
  • Associative
  • (a(bc)) ((ab)c)
  • Distributive
  • a(bc) ab bc

8
Defined OperationsScalars
  • Addition ab
  • Additive identity zero
  • Additive inverse - b
  • Subtraction defined in terms of additive inverse
  • Multiplication d j
  • Multiplicative identity 1
  • Multiplicative inverse 1/ d
  • Division defined in terms of multiplicative
    inverse

9
Defined OperationsVectors
Dot Product
Cross Product
Addition
v
u
u v
q
v
u
Produces vector w orthogonal to u and v.
u v u v cos q
Magnitude
(produces scalar)
A2 u 2 v 2
w u x v w u v sin q
(produces vector)
10
Defined OperationsPoints
Subtraction (Addition of points has no meaning.)
P
u P - R
R
Produces vector
11
Defined OperationsScalars and Vectors
Multiplication of vector by scalar Produces
vector
u
v a u
a u a u
12
Defined OperationsPoints and Vectors
Affine Addition Point Vector Point
Q
v
P
Q P v
Related to point subtraction.
13
Lines in Affine Space
R
R
Q
v
Q P v
R P a v 1 ? a ? 0
R P a v - lt a lt
P
Affine Sum/Combination R P a (Q - P) a
Q (1- a) P a1 P a2 Q where a1 a2 1
Line segment from P to Q defined when 0 a 1
14
Planes in Affine Space
Planes are defined uniquely by three points P,
Q, R
W(l)
Q
u Q - P v R - P
u
T( b)
R
P
v
S(a)
S(a) P a v T(b) P b u W(a, b, l) S -
l (T - S) P a v - l (b u - a v) W (a, b, l)
P a ( 1 l ) v - l b u W P d v c u
15
Linear Transformations
  • Let T A?B, where A and B vector spaces
  • T is linear transformations iff
  • T(ab) T(a) T(b) a, b ?vector space V
  • T(?a) ?T(a) ? is a scalar
  • T(?i ?iai) ?i?iT(ai)

16
Affine Transformations
  • Let T A?B, where A and B affine spaces
  • T is affine transformations iff
  • T is a linear transformations on vectors
  • T maps vectors to vectors and points to points
  • T(P a) T(P) T(a) where P is a point and a
    is a vector

17
Affine Transformations (2)
  • Properties of affine transformations
  • T preserves affine combinations
  • T(?i ?iPi) ?i?iT(Pi)
  • Where ?i ?i 0 or 1
  • T maps lines to lines
  • T( (1 - ?)P ? Q) (1 - ?) T(P) ? T(Q)
  • Ratios of distance along a line is preserved
  • T maps parallel lines to parallel lines

18
Representations of Points and Vectors
Coordinate system
  • Unique representation of v?
  • Point and vector have the different
    representations?

P (x, y, z)
19
Changes of Coordinate Systems
The 3x3 matrix is then given by
20
Changes of Coordinate Systems (2)
Given a vector w that has the representation
?1,?2,?3 w.s.t. v1, v2, v3
Assume that b has the representation of w w.s.t.
u1, u2, u3
Where
21
Changes of Coordinate Systems (3)
Rotation and scaling of a basis
The inverse of matrix (MT) takes us from a to b
Translation of a basis
22
Problem in 3D Coordinate Systems
  • Failure to distinguish between points and vectors
  • E.g. two vectors formed by point from (1,1,1) to
    (2,3,4), and point from (0,0,0) to (1,2,3) are
    the same
  • Make implementation more difficulty because
    multiplication in 3D cannot represent a change of
    frames
  • Composition is difficult to expression because
    translation is expressed in addition while
    rotation and scale are expressed in
    multiplications
  • gt Use of Homogenous Coordinate

23
Homogeneous Coordinates
Frame is specified by
where
are linearly independent basis vectors and P0
arbitrary point
Frame
Homogeneous coordinate representation
24
Representation of VectorsIn Homogeneous
Coordinates
25
Affine AdditionIn Homogeneous Coordinate
Representation
Point
Point
Scalar times vector
26
Transform as aChange of Frame
y
Want to translate by Dx 2, Dy4
(2, 3) in x-y (4,7) in x -y
y
(4, 7)
x
Dx 2, Dy4
x
1. Transform frame 2. Find representation in
orignial frame
27
Transform as aChange of Frame
Representation
Frame
28
Transformation Matrix
Original Frame
Transformed Frame
Express elements of transformed frame in original
frame
where
29
Transformation of Representation
where is of the form
30
Affine Transformations
T(point) -gt point
T(vector) -gt vector
31
What Do We Require of Transforms?Line Preserving
P1
Line Not Preserved
P2
32
Affine TransformationLine Preservation
Matrix multiplication is linear. Therefore
T(p)aT(v)
pav
v
T(v)
p
T(p)
Meets our requirements!
33
Translation
Assumptions
Translate the new frame
34
Scaling
Scale the new frame
35
Rotation
Rotation around the z axis
36
Rotation About x, y and z axes
Similar derivations give
37
Concatenation of Transformations
Frame Transformation Approach Post-multiply
Apply T1, Then apply T2
Point Transformation Approach Pre-multiply
38
Rotation About an Fixed Point
  • Strategy
  • translate the cube to the origin,
  • rotate it about the origin,
  • translate it back again at

39
Sequence of transformations
40
General Rotation
  • Any rotation about the origin is equivalent to 3
    successive rotations about 3 axes, x, y, and z.

?
?
41
The Instance Transformation
  • Each occurrence of an object in the scene?an
    instance of the objects prototype

42
Rotation About an Arbitrary Axis
43
Rotation (contd)
  • Strategy
  • translate the fixed point to the origin,
  • align the axis of rotation with the z axis,
  • complete the rotation of the cube,
  • undo the rotation of the rotation axis,
  • translate the fixed point back again.

?
44
Rotation (contd)
  • Rotation matrix

45

Rotation (contd)
46
Rotation (contd)
  • Rotate about x by

47
Rotation (contd)
  • Rotate about y by

48
Rotation (contd)
  • The complete sequence of matrices to be applied

49
OpenGL Matrix Operations
glLoadIdentity() Loads an identity matrix onto
the top of the current stack glLoadMatrixf(pointe
r_to_matrix) Loads arbitrary matrix onto top of
the current stack glMultMatrixf(pointer_to_matrix
) Postmultiplies current matrix by arbitrary
matrix Matricies are one-dimensional arrays of
type GLfloat in column major order.
50
Predefined Postmultiplier Operatorsin OpenGL
glTranslatef(dx, dy, dz) Multiplies current
matrix with translation matrix. dx, dy, and dz
are translations along x,y, and z
axes. glRotatef(angle, x, y, z) Multiplies
current matrix with rotation about the line from
the origin through the point (x, y, z) by angle.
Right hand rule applies. glScalef(sx, sy,
sz) Multiplies current matrix with scaling
matrix. sx, sy, sz are the scale factors along
the x, y, and z axes.
51
Rotation About a Fixed Point in OpenGL
  • glMatrixMode(GL_MODELVIEW)
  • glLoadIdentity()
  • Move the fixed point to the origin
  • glTranslatef(4.0, 5.0, 6.0)
  • Rotate about the origin
  • glRotatef(45.0, 1.0, 2.0, 3.0)
  • Move the fixed point back again
  • glTranslatef(-4.0, -5.0, -6.0)

52
Transformation Matrices in OpenGL
Matrix Mode
3D Model Vertices
2D
3D
Vertices
Modelview
Projection
Write a Comment
User Comments (0)
About PowerShow.com