Geometric Transformations - PowerPoint PPT Presentation

1 / 49
About This Presentation
Title:

Geometric Transformations

Description:

... formed by point from (1,1,1) to (2,3,4), and point from (0,0,0) to (1,2,3) are the same ... Multiplies current matrix with rotation about the line ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 50
Provided by: hughmas
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
P
R P a v - lt a lt
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
Representations of Points and Vectors
Coordinate system
  • Unique representation of v?
  • Point and vector have the different
    representation?

P (x, y, z)
16
Changes of Coordinate Systems
The 3x3 matrix is then given by
17
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
18
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
19
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

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

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

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

39
Rotation About an Arbitrary Axis
40
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.

?
41
Rotation (contd)
  • Rotation matrix

42

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

44
Rotation (contd)
  • Rotate about y by

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

46
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.
47
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.
48
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)

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