This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

Last Time

• Compositing

• Painterly Rendering

• Intro to 3D Graphics

• Homework 3 due Oct 12 in class

10/5/04 © University of Wisconsin, CS559 Fall 2004

Today

• Composing transformations

• 3D Transformations

• Homogeneous coordinates

• Intro to Viewing

10/5/04 © University of Wisconsin, CS559 Fall 2004

2D Rotation

• Rotate counter-clockwise about the origin by an angle u

(

¸

(

¸

+

(

¸

(

¸

(

¸

(

¸

÷

=

(

¸

(

¸

'

'

0

0

cos sin

sin cos

y

x

y

x

u u

u u

x

y

x

y

u

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rotating About An Arbitrary Point

• What happens when you apply a rotation transformation to

an object that is not at the origin?

x

y

?

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rotating About An Arbitrary

Point

• What happens when you apply a rotation transformation to

an object that is not at the origin?

– It translates as well

x

y

x

10/5/04 © University of Wisconsin, CS559 Fall 2004

How Do We Fix it?

• How do we rotate an about an arbitrary point?

– Hint: we know how to rotate about the origin of a coordinate system

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rotating About An Arbitrary Point

x

y

x

y

x

y

x

y

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rotate About Arbitrary Point

• Say you wish to rotate about the point (a,b)

• You know how to rotate about (0,0)

• Translate so that (a,b) is at (0,0)

– x’=x–a, y’=y–b

• Rotate

– x”=(x-a)cosu-(y-b)sinu, y”=(x-a)sinu+(y-b)cosu

• Translate back again

– x

f

=x”+a, y

f

=y”+b

10/5/04 © University of Wisconsin, CS559 Fall 2004

Scaling an Object not at the Origin

• What happens if you apply the scaling transformation to an

object not at the origin?

• Based on the rotating about a point composition, what

should you do to resize an object about its own center?

10/5/04 © University of Wisconsin, CS559 Fall 2004

Back to Rotation About a Pt

• Say R is the rotation matrix to apply, and p is the point

about which to rotate

• Translation to Origin:

• Rotation:

• Translate back:

• The translation component of the composite transformation

involves the rotation matrix. What a mess!

p x x ÷ =

'

Rp Rx p x R x R x ÷ = ÷ =

'

=

' '

) (

( ) p Rp Rx p x x + ÷ + = +

' '

=

' ' '

10/5/04 © University of Wisconsin, CS559 Fall 2004

Homogeneous Coordinates

• Use three numbers to represent a point

• (x,y)=(wx,wy,w) for any constant w=0

– Typically, (x,y) becomes (x,y,1)

– To go backwards, divide by w

• Translation can now be done with matrix multiplication!

(

(

(

¸

(

¸

(

(

(

¸

(

¸

=

(

(

(

¸

(

¸

'

'

1 1 0 0 1

y

x

b a a

b a a

y

x

y yy yx

x xy xx

10/5/04 © University of Wisconsin, CS559 Fall 2004

Basic Transformations

• Translation: Rotation:

• Scaling:

(

(

(

¸

(

¸

1 0 0

1 0

0 1

y

x

b

b

(

(

(

¸

(

¸

1 0 0

0 0

0 0

y

x

s

s

(

(

(

¸

(

¸

÷

1 0 0

0 cos sin

0 sin cos

u u

u u

10/5/04 © University of Wisconsin, CS559 Fall 2004

Homogeneous Transform

Advantages

• Unified view of transformation as matrix multiplication

– Easier in hardware and software

• To compose transformations, simply multiply matrices

– Order matters: AB is generally not the same as BA

• Allows for non-affine transformations:

– Perspective projections!

– Bends, tapers, many others

10/5/04 © University of Wisconsin, CS559 Fall 2004

Directions vs. Points

• We have been talking about transforming points

• Directions are also important in graphics

– Viewing directions

– Normal vectors

– Ray directions

• Directions are represented by vectors, like points, and can

be transformed, but not like points

(1,1)

(-2,-1)

10/5/04 © University of Wisconsin, CS559 Fall 2004

Transforming Directions

• Say I define a direction as the difference of two points:

d=a–b

– This represents the direction of the line between two points

• Now I translate the points by the same amount: a’=a+t,

b’=b+t

• How should I transform d?

10/5/04 © University of Wisconsin, CS559 Fall 2004

Homogeneous Directions

• Translation does not affect directions!

• Homogeneous coordinates give us a very clean way of

handling this

• The direction (x,y) becomes the homogeneous direction

(x,y,0)

• The correct thing happens for rotation and scaling also

– Scaling changes the length of the vector, but not the direction

– Normal vectors are slightly different – we’ll see more later

(

(

(

¸

(

¸

=

(

(

(

¸

(

¸

(

(

(

¸

(

¸

0 0 1 0 0

1 0

0 1

y

x

y

x

b

b

y

x

10/5/04 © University of Wisconsin, CS559 Fall 2004

3D Transformations

• Homogeneous coordinates: (x,y,z)=(wx,wy,wz,w)

• Transformations are now represented as 4x4 matrices

• Typical graphics packages allow for specification of

translation, rotation, scaling and arbitrary matrices

– OpenGL: glTranslate[fd], glRotate[fd], glScale[fd],

glMultMatrix[fd]

10/5/04 © University of Wisconsin, CS559 Fall 2004

3D Translation

(

(

(

(

¸

(

¸

(

(

(

(

¸

(

¸

=

(

(

(

(

¸

(

¸

'

'

'

1 1 0 0 0

1 0 0

0 1 0

0 0 1

1

z

y

x

t

t

t

z

y

x

z

y

x

10/5/04 © University of Wisconsin, CS559 Fall 2004

3D Rotation

• Rotation in 3D is about an axis in 3D space passing through

the origin

• Using a matrix representation, any matrix with an

orthonormal top-left 3x3 sub-matrix is a rotation

– Rows are mutually orthogonal (0 dot product)

– Determinant is 1

– Implies columns are also orthogonal, and that the transpose is equal

to the inverse

10/5/04 © University of Wisconsin, CS559 Fall 2004

3D Rotation

. , 0 , 0 , 0 , 0 then

1 1 0 0 0

0

0

0

if and

1 1 0 0 0

0

0

0

1

1 1 3 2 3 1 2 1

3

2

1

etc

z

y

x

R

z

y

x

r r r

r r r

r r r

z

y

x

zz zy zx

yz yy yx

xz xy xx

= - = - = - = -

(

(

(

(

¸

(

¸

(

(

(

(

¸

(

¸

÷ ÷

÷ ÷

÷ ÷

=

(

(

(

(

¸

(

¸

(

(

(

(

¸

(

¸

=

(

(

(

(

¸

(

¸

'

'

'

r r r r r r r r

r

r

r

10/5/04 © University of Wisconsin, CS559 Fall 2004

Problems with Rotation

Matrices

• Specifying a rotation really only requires 3 numbers

– Axis is a unit vector, so requires 2 numbers

– Angle to rotate is third number

• Rotation matrix has a large amount of redundancy

– Orthonormal constraints reduce degrees of freedom back down to 3

– Keeping a matrix orthonormal is difficult when transformations are

combined

• Rotations are a very complex subject, and a detailed

discussion is way beyond the scope of this course

10/5/04 © University of Wisconsin, CS559 Fall 2004

Alternative Representations

• Specify the axis and the angle (OpenGL method)

– Hard to compose multiple rotations

• Euler angles: Specify how much to rotate about X, then

how much about Y, then how much about Z

– Hard to think about, and hard to compose

– Any three axes will do e.g. X,Y,X

• Specify the axis, scaled by the angle

– Only 3 numbers, called the exponential map

• Quaternions

10/5/04 © University of Wisconsin, CS559 Fall 2004

Quaternions

• 4-vector related to axis and angle, unit magnitude

– Rotation about axis (n

x

,n

y

,n

z

) by angle u:

• Reasonably easy to compose

• Reasonably easy to go to/from rotation matrix

• Only normalized quaternions represent rotations, but you

can normalize them just like vectors, so it isn’t a problem

• Easy to perform spherical interpolation

( ) ( ) ( ) ( ) ( ) 2 / sin , 2 / cos , 2 / cos , 2 / cos u u u u

z y x

n n n

10/5/04 © University of Wisconsin, CS559 Fall 2004

Other Rotation Issues

• Rotation is about an axis at the origin

– For rotation about an arbitrary axis, use the same trick as in 2D:

Translate the axis to the origin, rotate, and translate back again

• Rotation is not commutative

– Rotation order matters

– Experiment to convince yourself of this

10/5/04 © University of Wisconsin, CS559 Fall 2004

Transformation Leftovers

• Scale, shear etc extend naturally from 2D to 3D

• Rotation and Translation are the rigid-body

transformations:

– Do not change lengths or angles, so a body does not deform when

transformed

10/5/04 © University of Wisconsin, CS559 Fall 2004

Modeling 101

• For the moment assume that all geometry consists of points,

lines and faces

• Line: A segment between two endpoints

• Face: A planar area bounded by line segments

– Any face can be triangulated (broken into triangles)

10/5/04 © University of Wisconsin, CS559 Fall 2004

Modeling and OpenGL

• In OpenGL, all geometry is specified by stating which type

of object and then giving the vertices that define it

• glBegin(…) …glEnd()

• glVertex[34][fdv]

– Three or four components (regular or homogeneous)

– Float, double or vector (eg float[3])

• Chapter 2 of the red book

10/5/04 © University of Wisconsin, CS559 Fall 2004

Rendering

• Generate an image showing the contents of some region of

space

– The region is called the view volume, and it is defined by the user

• Determine where each object should go in the image

– Viewing, Projection

• Determine which pixels should be filled

– Rasterization

• Determine which object is in front at each pixel

– Hidden surface elimination, Hidden surface removal, Visibility

• Determine what color it is

– Lighting, Shading

10/5/04 © University of Wisconsin, CS559 Fall 2004

Graphics Pipeline

• Graphics hardware employs a sequence of coordinate

systems

– The location of the geometry is expressed in each coordinate system

in turn, and modified along the way

– The movement of geometry through these spaces is considered a

pipeline

Local

Coordinate

Space

World

Coordinate

Space

View

Space

Canonical

View

Volume

Display

Space

- Abbott Ministry
- Greek Immortals
- 74LS86
- Magazine Power Fault Opi
- Hi18 (Lt2) Notes
- Book Prepositions (1)
- CV - Anders Bergman
- Nitrous Oxide Poems
- hdkf
- przepiękny język na ktory trzeba sie uczyc
- CRCRLP6848-13-19-02-2014
- Lista de Verbos en Ingles..
- VPIT Status and Activity Report for December 2015
- List of Contents
- Gas Absorption
- Semiologic Features and Their Lateralizating And
- Yearly Lesson Plan Science Intervention Class 2011
- vote datadictionary
- UK-Character-Animation-Course
- perlembagaan etnik
- Whitehorn Shawn Resume
- Stories From the Papers
- BK2 Chapters 1 2
- 3-DMMintrographics
- IPCC Working Group II IPCC. Fifth Assessment Report, 2014
- TM-3
- Business Plan OutlineF-1!8!04
- مجموہ مناجات
- Rambutan - Slides 6pp
- Mission and Vision

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd