15%20March%202006 - PowerPoint PPT Presentation

About This Presentation
Title:

15%20March%202006

Description:

Chapter 4. 15 March 2006. EventPro Strategies is looking for ... Homogeneous ... Homogeneous Coordinates. Cos -sin 0 x. sin cos 0 y. 0 0 1 1. Combining 2D ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 32
Provided by: sie6
Learn more at: https://www.cs.unca.edu
Category:

less

Transcript and Presenter's Notes

Title: 15%20March%202006


1
Chapter 4
  • 15 March 2006

EventPro Strategies is looking for a part-time
programmer (any language) who knows SQL. For more
info, contact Ryan Taylor, ryan_at_eventprostrategies
.com
2
Agenda
  • Chapter 4 Math for Computer Graphics
  • GLUT solids

3
Transformations
  • 45-degree counterclockwise rotation about the
    origin around the z-axis
  • a translation down the x-axis

4
Order of transformations
glMatrixMode(GL_MODELVIEW) glLoadIdentity() glMu
ltMatrixf(N) / apply
transformation N / glMultMatrixf(M)
/ apply transformation M / glMultMatrixf(L)
/ apply transformation L
/ glBegin(GL_POINTS) glVertex3f(v)
/ draw transformed vertex v / glEnd()
  • transformed vertex is NMLv

5
Translation
  • void glTranslatefd (TYPE x, TYPE y, TYPE z)
  • Multiplies the current matrix by a matrix that
    moves (translates) an object by the given x, y,
    and z values

6
Rotation
  • void glRotatefd(TYPE angle, TYPE x, TYPE y,
    TYPE z)
  • Multiplies the current matrix by a matrix that
    rotates an object in a counterclockwise direction
    about the ray from the origin through the point
    (x, y, z). The angle parameter specifies the
    angle of rotation in degrees.

7
Scale
  • void glScalefd (TYPEx, TYPE y, TYPEz)
  • Multiplies the current matrix by a matrix that
    stretches, shrinks, or reflects an object along
    the axes.

8
Vectors
  • N tuple of real numbers (n 2 for 2D, n 3 for
    3D)
  • directed line segment
  • example
  • velocity vector (speed and direction)
  • operations
  • addition
  • multiplication by a scalar
  • dot product

9
VectorsVector and Vector Algebra
1 2 3 2 3 5 3 4 7
10
Matrices
  • Rectangular array of numbers
  • Addition
  • QuickMath

11
Matrices
  • A vector in 3 space is a n x 1 matrix or
    column vector.

12
Matrices
  • Multiplication

1 0 0 0 0 1 0 0 x 0 0 0 0 0
0 1/k 1
Cos a 0 sin a 0 0 1 0 m -sin a
0 cos a n 0 0 0 1
13
Matrix multiplication
  • A is an n x m matrix with entries aij
  • B is an m x p matrix with entries bij
  • AB is an n x p matrix with entries cij
  • m
  • cij ?ais bsj
  • s1

14
Matrix multiplication
  • m
  • cij ?ais bsj
  • s1

c11 c12 c13 c14 c21 c22 c23
c24 c31 c32 c33 c34 c41 c42 c43
c44
1 0 0 0 0 1 0 0 x 0 0 0 0 0
0 1/k 1
Cos a 0 sin a 0 0 1 0 m -sin a
0 cos a n 0 0 0 1
a
b
15
2D Transformations
  • Translation Pf T P
  • xf xo dx
  • yf yo dy
  • Rotation Pf R P
  • xf xo cos? - yo sin?
  • yf xo sin? yo cos?
  • Scale Pf S P
  • xf sx xo
  • yf sy yo

16
Homogeneous Coordinates
  • Want to treat all transforms in a consistent way
    so they can be combined easily
  • Developed in geometry (46 in Cambridge) and
    applied to graphics
  • Add a third coordinate to a point (x, y, W)
  • (x1, y1, W1) is the same point as (x2, y2, W2) if
    one is a multiple of another
  • Homogenize a point by dividing by W

17
Homogeneous Coordinates
  • 1 0 dx x
  • 0 1 dy y
  • 0 0 1 1

18
Homogeneous Coordinates
  • sx 0 0 x
  • 0 sy 0 y
  • 0 0 1 1

19
Homogeneous Coordinates
  • Cos? -sin? 0 x
  • sin? cos? 0 y
  • 0 0 1 1

20
Combining 2D Transformations
  • Rotate a house about the origin
  • Rotate the house about one of its corners
  • Translate so that a corner of the house is at the
    origin
  • Rotate the house about the origin
  • Translate so that the corner returns to its
    original position

21
GLUT Solids
  • Sphere
  • Cube
  • Cone
  • Torus
  • Dodecahedron
  • Octahedron
  • Tetrahedron
  • Icosahedron
  • Teapot

22
glutSolidSphere and glutWireSphere
  • void glutSolidSphere(GLdouble radius, GLint
    slices, GLint stacks)
  • radius - The radius of the sphere.
  • slices - The number of subdivisions around the Z
    axis (similar to lines of longitude).
  • stacks - The number of subdivisions along the Z
    axis (similar to lines of latitude).

23
glutSolidCube and glutWireCube
  • void glutSolidCube(GLdouble size)
  • size length of sides

24
glutSolidCone and glutWireCone
  • void glutSolidCone(GLdouble base, GLdouble
    height, GLint slices, GLint stacks)
  • base - The radius of the base of the cone.
  • height - The height of the cone.
  • slices - The number of subdivisions around the Z
    axis.
  • stacks - The number of subdivisions along the Z
    axis.

25
glutSolidTorus and glutWireTorus
  • void glutSolidTorus(GLdouble innerRadius,GLdouble
    outerRadius, GLint nsides,
    GLint rings)
  • innerRadius - Inner radius of the torus.
  • outerRadius - Outer radius of the torus.
  • nsides - Number of sides for each radial section.
  • rings - Number of radial divisions for the torus.

26
glutSolidDodecahedron and glutWireDodecahedron
  • void glutSolidDodecahedron(void)

27
glutSolidOctahedron and glutWireOctahedron .
  • void glutSolidOctahedron(void)

28
glutSolidTetrahedron and glutWireTetrahedron
  • void glutSolidTetrahedron(void)

29
glutSolidIcosahedron and glutWireIcosahedron
  • void glutSolidIcosahedron(void)

30
glutSolidTeapot and glutWireTeapot
  • void glutSolidTeapot(GLdouble size)
  • size - Relative size of the teapot.

31
Homework next week.
  • Study for Test on Chapters 1-4, 02/15/05
Write a Comment
User Comments (0)
About PowerShow.com