cs 445 645 introductory computer graphics l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CS 445 / 645: Introductory Computer Graphics PowerPoint Presentation
Download Presentation
CS 445 / 645: Introductory Computer Graphics

Loading in 2 Seconds...

play fullscreen
1 / 44

CS 445 / 645: Introductory Computer Graphics - PowerPoint PPT Presentation


  • 113 Views
  • Uploaded on

CS 445 / 645: Introductory Computer Graphics. Geometric Transforms. Matrix Manipulation - Example. Drawing a car with wheels and lugnuts. draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( );

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CS 445 / 645: Introductory Computer Graphics' - donkor


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2

Matrix Manipulation - Example

  • Drawing a car with wheels and lugnuts

draw_wheel( );

for (j=0; j<5; j++) {

glPushMatrix ();

glRotatef(72.0*j, 0.0, 0.0, 1.0);

glTranslatef (3.0, 0.0, 0.0);

draw_bolt ( );

glPopMatrix ( );

slide3

Matrix Manipulation - Example

draw_wheel( );

for (j=0; j<5; j++) {

glPushMatrix ();

glRotatef(72.0*j, 0.0, 0.0, 1.0);

glTranslatef (3.0, 0.0, 0.0);

draw_bolt ( );

glPopMatrix ( );

Global – Bottom Up

Start

Rot

Trans

slide4

Matrix Manipulation - Example

draw_wheel( );

for (j=0; j<5; j++) {

glPushMatrix ();

glRotatef(72.0*j, 0.0, 0.0, 1.0);

glTranslatef (3.0, 0.0, 0.0);

draw_bolt ( );

glPopMatrix ( );

Local – Top Down

Start

Rot

Trans

translation matrices
Translation Matrices?
  • We can composite scale matrices just as we did rotation matrices
  • But how to represent translation as a matrix?
  • Answer: with homogeneous coordinates
homogeneous coordinates
Homogeneous Coordinates
  • Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector

(Note that typically w = 1 in object coordinates)

homogeneous coordinates7
Homogeneous Coordinates
  • Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
  • Our transformation matrices are now 4x4:
homogeneous coordinates8
Homogeneous Coordinates
  • Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
  • Our transformation matrices are now 4x4:
homogeneous coordinates9
Homogeneous Coordinates
  • Homogeneous coordinates seem unintuitive, but they make graphics operations mucheasier
  • Our transformation matrices are now 4x4:
homogeneous coordinates10
Homogeneous Coordinates
  • Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
  • Our transformation matrices are now 4x4:
homogeneous coordinates11
Homogeneous Coordinates
  • How can we represent translation as a 4x4 matrix?
  • A: Using the rightmost column:
translation matrices12
Translation Matrices
  • Now that we can represent translation as a matrix, we can composite it with other transformations
  • Ex: rotate 90° about X, then 10 units down Z:
translation matrices13
Translation Matrices
  • Now that we can represent translation as a matrix, we can composite it with other transformations
  • Ex: rotate 90° about X, then 10 units down Z:
translation matrices14
Translation Matrices
  • Now that we can represent translation as a matrix, we can composite it with other transformations
  • Ex: rotate 90° about X, then 10 units down Z:
translation matrices15
Translation Matrices
  • Now that we can represent translation as a matrix, we can composite it with other transformations
  • Ex: rotate 90° about X, then 10 units down Z:
transformation commutativity
Transformation Commutativity
  • Is matrix multiplication, in general, commutative? Does AB = BA?
  • What about rotation, scaling, and translation matrices?
    • Does RxRy = RyRx?
    • Does RAS = SRA ?
    • Does RAT = TRA ?
more on homogeneous coords
More On Homogeneous Coords
  • What effect does the following matrix have?
  • Conceptually, the fourth coordinate wis a bit like a scale factor
homogenous coordinates
Homogenous Coordinates
  • In particular, increasing w makes things smaller
  • We think of homogenous coordinates as defining a projective space
    • Increasing w “getting further away”
  • Will come in handy for projection matrices
projection matrix
Projection Matrix
  • We talked about geometric transforms, focusing on modeling transforms
    • Ex: translation, rotation, scale, gluLookAt()
    • These are encapsulated in the OpenGL modelview matrix
  • Can also express projection as a matrix
  • Next few slides: representing orthographic and perspective projection with the projection matrix
orthographic projection
Orthographic Projection
  • Simple OrthographicTransformation
  • Original world units are preserved
    • Pixel units are preferred
orthographic screen space transformation
Orthographic: Screen Space Transformation

left =10 m

right = 20 m

top=20 m

(max pixx, max pixy)

(height in pixels)

(0, 0)

bottom=10 m

(width in pixels)

orthographic screen space transformation22
Orthographic: Screen Space Transformation
  • left, right, top, bottom refer to the viewing frustum in modeling coordinates
  • width and height are in pixel units
  • This matrix scales and translates to accomplish the transition in units
perspective transformation
Perspective Transformation
  • First discovered by Donatello, Brunelleschi, and DaVinci during Renaissance
  • Objects closer to viewer look larger
  • Parallel lines appear to converge to single point
perspective projection
Perspective Projection
  • In the real world, objects exhibit perspective foreshortening: distant objects appear smaller
  • The basic situation:
perspective projection25

How tall shouldthis bunny be?

Perspective Projection
  • When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world:
perspective projection26

Viewplane

X

P (x, y, z)

x’ = ?

(0,0,0)

Z

Perspective Projection
  • The geometry of the situation is that of similar triangles. View from above:
  • What is x’ ?

d

perspective projection27
Perspective Projection
  • Desired result for a point [x, y, z, 1]T projected onto the view plane:
  • What could a matrix look like to do this?
a perspective projection matrix29
A Perspective Projection Matrix
  • Example:
  • Or, in 3-D coordinates:
perspective projection30
Perspective Projection
  • Translate model units to pixel units
projection matrices
Projection Matrices
  • Now that we can express perspective foreshortening as a matrix, we can composite it onto our other matrices with the usual matrix multiplication
  • End result: a single matrix encapsulating modeling, viewing, and projection transforms
a 3d scene
A 3D Scene
  • Notice the presence ofthe camera, theprojection plane, and the worldcoordinate axes
  • Viewing transformations define how to acquire the image on the projection plane
viewing transformations
Viewing Transformations
  • Create a camera-centered view
  • Camera is at origin
  • Camera is looking along negative z-axis
  • Camera’s ‘up’ is aligned with y-axis
2 basic steps
2 Basic Steps
  • Align the two coordinate frames by rotation
2 basic steps35
2 Basic Steps
  • Translate to align origins
creating camera coordinate space
Creating Camera Coordinate Space
  • Specify a point where the camera is located in world space, the eye point
  • Specify a point in world space that we wish to become the center of view, the lookat point
  • Specify a vector in worldspace that we wish to point up in camera image, the up vector
  • Intuitive camera movement
constructing viewing transformation v
Constructing Viewing Transformation, V
  • Create a vector from eye-point to lookat-point
  • Normalize the vector
  • Desired rotation matrix should map this vector to [0, 0, -1]T Why?
constructing viewing transformation v38
Constructing Viewing Transformation, V
  • Construct another important vector from the cross product of the lookat-vector and the vup-vector
  • This vector, when normalized, should align with [1, 0, 0]TWhy?
constructing viewing transformation v39
Constructing Viewing Transformation, V
  • One more vector to define…
  • This vector, when normalized, should align with [0, 1, 0]T
  • Now let’s composite the results
compositing vectors to form v
Compositing Vectors to Form V
  • We know the three world axis vectors (x, y, z)
  • We know the three camera axis vectors (u, v, n)
  • Viewing transformation, V, must convert from world to camera coordinate systems
compositing vectors to form v41
Compositing Vectors to Form V
  • Remember
    • Each camera axis vector is unit length.
    • Each camera axis vector is perpendicular to others
  • Camera matrix is orthogonal and normalized
    • Orthonormal
  • Therefore, M-1 = MT
compositing vectors to form v42
Compositing Vectors to Form V
  • Therefore, rotation component of viewing transformation is just transpose of computed vectors
compositing vectors to form v43
Compositing Vectors to Form V
  • Translation component too
  • Multiply it through
final viewing transformation v
Final Viewing Transformation, V
  • To transform vertices, use this matrix:
  • And you get this: