+ All Categories
Home > Documents > Review: Math (Ch 4)

Review: Math (Ch 4)

Date post: 22-Jan-2016
Category:
Upload: aglaia
View: 24 times
Download: 0 times
Share this document with a friend
Description:
Review: Math (Ch 4). General Purpose Graphics. API for use in high level languages Appl.program ------- Graph.API ------- Graph.hardware Primitives and Attributes Geometric and modeling transformations Viewing transformations Hierarchical modeling and manipulation - PowerPoint PPT Presentation
48
2/7/2001 Hofstra University – CSC290B 1 Review: Math (Ch 4)
Transcript
Page 1: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 1

Review: Math (Ch 4)

Page 2: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 2

General Purpose Graphics

API for use in high level languages Appl.program ------- Graph.API ------- Graph.hardware

Primitives and Attributes Geometric and modeling transformations Viewing transformations Hierarchical modeling and manipulation Raster (buffer) oriented transformations Control functions

Page 3: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 3

Fundamental Operations

Transformation – changes in coordinate systems through matrix operations

Clipping – adjusting our view of the world Projection – from 3D to 2D Rasterization – pixels in the frame buffer

Page 4: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 4

Geometric Transformations

• Work in Euclidean affine space:

vectors, + , multiplication with scalars, 0 linear combinations, linear independence, basis linear maps (transformations), change of basis

points, point+vector, point –point affine combinations, frame

inner product, distances, angles, unit vector, perpendicular

orthonormal frame, change of frames, affine maps

Page 5: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 5

Review: Affine Transformations change objects so programmer

can:

Model objects in simple configurations

Make multiple copies of objects Animate objects, move or deform

over time

Page 6: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 6

Vectors

Directed line segment that connects points

Does not have a fixed position

Page 7: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 7

Vectors

B = 2A

A

C = -A

B

A

C = A + B

head-to-tail rule

Linear independence, basis, linear maps

Page 8: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 8

Geometric ADTs

Scalars, Points and Vectors are members of mathematical sets

Abstract spaces for representing and manipulating these sets of objects

Linear Vector Space – scalars & vectors

Affine Space – adds the point Euclidean Space – add concept of

distance and angle

Page 9: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 9

Geometric ADTs Operations that relate points and

vectors Subtraction of two points yields a

vector:v = P – Q

Point-vector addition yields a point:

P = v + Q

Page 10: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 10

Geometric ADTs: Lines Consider all points of the form

P () = P0 + dwhere P0 is an arbitrary point, d is an arbitrary vector, and is a scalar

P () is a point for any value of Called the parametric form of the line Generate points on the line by

varying the parameter For non-negative values, we get

a ray emanating from P0 in the direction of d

d

P 0

P (a )

Page 11: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 11

Geometric ADTs: Affine Sums

For any point Q, vector v, and positive scalar ,

P = Q + vdescribes all points on the line from Q in the direction of v

Affine addition is characterized by the addition of two arbitrary points and multiplication of a point by a scalar,

P = R + Q where 1 + 2 = 1

v

Q

P () = 1R

= 0

Page 12: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 12

Geometric ADTs: Dot Product

We are concerned about the orientation between two vectors

Dot (Inner) Product of vectors u and v is written

u v If u v = 0, then u and v are orthogonal In Euclidean space, the square of the

magnitude of a vector is |u|2 = u u

The angle between two vectors is given byvuvu=cos

Page 13: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 13

Geometric ADTs: Cross Product

Cross Product – is determined by a third vector n that is orthogonal to two other vectors v and u. It is denoted asn = u v

Page 14: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 14

3D Primitives

Curves Surfaces Volume Objects

Page 15: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 15

3D Primitves

Objects With Good Characteristics Described by their surfaces;

thought to be hollow Specified through a set of vertices

in 3D Composed of or approximated by

flat convex polygons

Page 16: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 16

Coordinate Systems

Given a frame (P0, v1, v2, v3), a vector w:

And in the same frame a point P:

3322110 vvvPP =

332211 vvvw =

Page 17: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 17

Changes of Basis

How do we represent the vector if we change the basis?

Suppose the {v1,v2,v3} and {u1,u2,u3} are two bases.

Basis vector in second set can be represented in terms of the first basis

Page 18: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 18

Change of Basis in Linear Space

3332321313

3232221212

3132121111

vvvu

vvvu

vvvu

===

=

333231

232221

131111

M

U = MV

Page 19: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 19

Change of Basis

=

31

21

11

a

=

31

21

11

b

=

333231

232221

131111

M

bMa T=

In V basis, the vector is represented by a, and in U by b

U=MV, b’U=b’MV=a’V, a’=b’M, a=M’b

aMAab T 1)( ==

Page 20: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 20

Homogeneous CoordinatesRepresent a point at (x,y,z) wrt a 3D frame determined by (P0, v1, v2, v3 ) with a column matrix

Where x,y,z are the components of the basis vectors for this point, so that

and represent a vector in the same form

=

z

y

x

p

3322110 vzvyvxPP =

=

3

2

1

w

Page 21: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 21

Homogeneous Coordinates Maintain distinction between

points and vectors Use four dimensional column

matrices to represent both points and vectors in three dimensions

If we assume a frame specified by (v1, v2, v3, P0), then any point P can be written

0332211 PvvvP =

Page 22: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 22

Homogeneous Coordinates …and if we define multiplication of

a point by the scalars 0 and 1 as0 ·P = 0,1 . P = P,

then we can use a matrix product to express this relation formally as

=

0

3

2

1

321 1

P

v

v

v

P

homogeneous-coordinate representation

Page 23: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 23

Homogeneous Coordinates

We carry out operations on points and vectors using their homogeneous-coordinate representation and ordinary matrix algebra

=

13

2

1

p

=

03

2

1

a

Point Vector

Page 24: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 24

Homogeneous Coordinates

=

0

3

2

1

0

3

2

1

P

v

v

v

Q

u

u

u

M

=

1

0

0

0

434241

333231

232221

131211

M

bMa T=

All affine transformations can be represented as matrix multiplications in homogeneous coordinates

two frames change of framesmatrix representation

aMAab T 1)( ==

Page 25: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 25

Frames In OpenGL We use two frames: the camera frame and the

world frame We regard the camera frame as fixed The model-view matrix positions the world frame

relative to the camera frame Perform homogeneous coordinate

transformations on object in other frames to define new frames relative to the camera frame

Model-view Matrix: translate along z, to separate the two frames, so object could be in camera’s field of view

Page 26: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 26

Frames In OpenGL

Page 27: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 27

Modeling

Select modeling (local) coordiante system best suited for modeling the object

Define objects in terms of vertices Pass vertices through a number of

transformations using homogeneous coordinates

Page 28: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 28

Affine Transformations A map f () is linear iff, for any scalars and , and any

vectors p and q,f(p+ q) = f(p)+ f(p)

Affine maps preserve affine combinations of points f(P+ Q) = f(P)+ f(Q), where + =1 are linear in homogenious coordinates ( i.e. represented by

4x4 matrix, last row (0,0,0,1), act as matrix multiplications). the transf. of affine combinations of points is same affine

combination of the transformed points can be represented as a composition of translations,

rotations, and scalings

Page 29: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 29

Transformations in Homogeneous Coordinates

Each affine transformation is represented by a 4 x 4 matrix of the form

=

100034333231

24232221

14131211

M

Page 30: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 30

Graphics Pipeline

Pipeline endpoints (in homogeneous coordinates) through affine transformations to generate the rastered image

Page 31: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 31

Concatenation of Transformations

We can multiply together sequences of transformations – concatenating

Works well with pipeline architecture e.g., three successive transformations

on a point p creates a new point qq = CBAp

Page 32: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 32

Concatenation of Transformations

If we have a lot of points to transform, then we can calculate

M = CBAand then we use this matrix on each point

q = Mp

Page 33: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 33

Translation

Translation is an operation that displace points by a fixed distance in a given direction

Only need to specify a displacement vector d

Transformed points are given by P = P + d

Page 34: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 34

Translation

Page 35: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 35

Rotation about a pivot point P in 2D

R(P;u)=T(-P)R(O;u)T(P)

Page 36: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 36

Rigid Body Transformation•Rotation and translation are rigid-body transformations•No combination of transformations can alter the shape of an object

Non-rigid-body transformations

Page 37: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 37

Scaling

non-uniform

uniform

Page 38: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 38

Rotation About Axis Parrallel to z-axis

Move the cube to the originApply Rz()Move back to original position

)()()( fzf pTRpTM =

Page 39: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 39

Instance Transformation

objectprototype

instance

Page 40: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 40

Instance Transformation

Page 41: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 41

Current Transformation Matrix

Current Transformation Matrix (CTM) – matrix that is applied to any vertex that is defined subsequent to setting the CTM

Changing the CTM, alters the state of the system

4x4 matrix that can be altered by a set of functions provided by the graphics package

Common to most systems. Part of the pipeline If p is a vertex, the pipeline produces Cp

Page 42: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 42

Current Transformation Matrix

Let C denote the CTM. It is set to the 4x4 identity matrix, initially. The symbol denotes replacement

Initialization operation:C I

Three transformations about the fixed point of the origin: translation, rotation, scaling

Set: Postmultiplication:C T C CTC R C CRC S C CS

Page 43: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 43

Current Transformation Matrix

The matrix the is applied to all primitives is the product of the model-view matrix (GL_MODELVIEW) and the projection matrix (GL_PROJECTION)

The CTM is the product of these matrices!

Page 44: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 44

Current Transformation Matrix

The matrix that is applied to all primitives is the product of the model-view matrix (GL_MODELVIEW) and the projection matrix (GL_PROJECTION)

The CTM is the product of these matrices

We select the desired matrix of each with glMatrixMode then alter the selected matrix through postmultiplication using:

glLoadIdentity( );glRotatef(angle, vx, vy, vz);glTranslatef(dx, dy, dz);glScalef(sx, sy, sz);

Page 45: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 45

Order of Transformations Transformation specified most

recently is the one applied firstglMatrixModel(GL_MODELVIEW)glLoadIdentity( );glTranslatef(4.0, 5.0, 6.0);glRotatef(45.0, 1.0, 2.0, 3.0);glTranslatef(-4.0, -5.0, -6.0);

Page 46: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 46

Summary: Affine Maps

Composition of translations, rotations, scalings

Preserve affine combination of points

If object is modeled as affine combination from vertices, under affine map, the transformed object is the same affine combination of the transformed vertices.

Page 47: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 47

Summary: Affine Maps

Liner maps in homogeneous coordinates, represented by matrices

Composition of affine maps is represented by a matrix which is product of the matrices of the individual maps.

Page 48: Review: Math (Ch 4)

2/7/2001 Hofstra University – CSC290B 48

Fundamental Operations

Transformation – changes in coordinate systems through matrix operations

Clipping – adjusting our view of the world Projection – from 3D to 2D Rasterization – pixels in the frame buffer


Recommended