56
Transformations With Transformations With OpenGL OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Embed Size (px)

Citation preview

Page 1: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations With OpenGLTransformations With OpenGL

Courtesy of Drs. Carol O’Sullivan / Yann Morvan

Trinity College Dublin

Page 2: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Object RepresentationObject RepresentationObjects are represented as a closed mesh of polygons

The finer the mesh the more detail can be captured

Page 3: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Open GL Primitives Open GL Primitives

Page 4: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

OpenGLOpenGL

• To create a red polygon with 4 vertices:

• glBegin defines a geometric primitive:– GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_TRIANGLES, GL_QUADS, GL_POLYGON…

• All vertices are 3D and defined using glVertex*

glColor3f(1.0, 0.0, 0.0);glBegin(GL_POLYGON); glVertex3f(0.0, 0.0, 3.0); glVertex3f(1.0, 0.0, 3.0); glVertex3f(1.0, 1.0, 3.0); glVertex3f(0.0, 1.0, 3.0);glEnd();

Page 5: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

OpenGLOpenGL

• We can use per-vertex information.• To create the RG colour square:

glShadeModel(GL_SMOOTH);glBegin(GL_POLYGON); glColor3f(1.0, 0.0, 0.0); // Red glVertex3f(0.0, 0.0, 3.0); glColor3f(0.0, 0.0, 0.0); // Black glVertex3f(1.0, 0.0, 3.0); glColor3f(0.0, 1.0, 0.0); // Green glVertex3f(1.0, 1.0, 3.0); glColor3f(1.0, 1.0, 0.0); // Yellow glVertex3f(0.0, 1.0, 3.0);glEnd();

Page 6: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Geometric TransformationsGeometric Transformations• Many geometric transformations are linear and can be

represented as a matrix multiplication.• Function f is linear iff:

• Implications: to transform a line we transform the end-points. Points between are affine combinations of the transformed endpoints.

Given line defined by points P and Q, points along transformed line are affine combinations of transformed P and Q

yfxfyxf

PQtPtL

PQtPtL

Page 7: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Homogeneous Co-ordinatesHomogeneous Co-ordinates

• Basis of the homogeneous co-ordinate system is the set of n basis vectors and the origin position:

• All points and vectors are therefore compactly represented using their ordinates:

w

z

y

x

a

a

a

o

n

usually moreor

1

on P and 21 vvv ,,,

Page 8: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Co-ordinate FrameCo-ordinate Frame• A Frame is a point P0 (the origin) and a set of vectors vn

which define the basis for the vector space (the axes).• Vectors of the frame take the form:

• Points defined using the frame are given as:

• Vectors are uniquely defined using the ordinates an but points require extra information (i.e. the origin)

• In computer graphics we use homogeneous co-ordinates to express vector and affine quantities and transformations.

nnaaa vvvu 2211

nnaaaPP vvv 22110

Page 9: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Homogeneous Co-ordinatesHomogeneous Co-ordinates

• Vectors have no positional information and are represented using ao = 0 whereas points are represented with ao = 1:

• Examples:

onn

nn

PaaP

aav

vv

vv

11

11 0

0

0.0

0.1

0.1

0

2.2

3.1

2.0

1

0.0

0.1

0.1

1

2.2

3.1

2.0

Points Associated vectors

Page 10: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

ScaleScale• all vectors are scaled from the origin:

Original scale all axes scale Y axis

offset from origin distance from origin also scales

Page 11: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

RotationRotation• Rotations are anti-clockwise about the origin:

rotation of 45o about the Z axis

offset from origin rotation

Page 12: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

RotationRotation

sin

cos

sin

cos

r

r

r

rvv

original

rota

ted

cossinsincos

sinsincoscos expand

rry

rrx

cossin

sincos

sin

cos

yxy

yxx

ry

rx

but

Page 13: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

• 2D rotation of about origin:

• 3D homogeneous rotations:

• Note:

• If M-1 = MT then M is orthonormal. All orthonormal matrices are rotations about the origin.

y

x

y

x

cossin

sincos

1000

00

00

0001

cossin

sincosxR

1000

0100

00

00

cossin

sincos

zR

1000

00

0010

00

cossin

sincos

yR

TRRR

1

sinsin

coscos

RotationRotation

Page 14: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

ScaleScale

Svv

z

y

x

s

s

s

zs

ys

xs

z

y

x

z

y

x

z

y

x

00

00

00

We would also like to scale points thus we need ahomogeneous transformation for consistency:

w

z

y

x

s

s

s

w

zs

ys

xs

w

z

y

x

z

y

x

z

y

x

1000

000

000

000

1000

0100

0010

0001

1

z

y

x

s

s

s

S

Page 15: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

ShearShear• We shear along an axis

according to another axis – Shearing along X axis

preserves y and z values.– Shearing along Y axis

preserves x and z values– Shearing along Z axis

preserves x and y values

• Point are stretched along the shear axis in proportion to the distance of the point along another axis.

• Example: shearing along X according to Y

w

z

y

x

w

z

y

x

1000

0100

0010

00cot1

cotyxx

Page 16: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

ShearShear

original shear along x (by y) shear along x (by z)

Page 17: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

czz

byy

axx

11000

100

010

001

11

z

y

x

c

b

a

cz

by

ax

z

y

x

TranslationTranslation• Translation only applies to points, we never translate

vectors.• Remember: points have homogeneous co-ordinate w = 1

translate along y

Page 18: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Affine TransformationsAffine Transformations

• All affine transformations are combinations of rotations, scaling and translations.

• Shear = rotation followed by a scale:

• Affine transformations preserve– Collinearity– Ratios of distances along a

line (therefore parallelism)

Page 19: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformation CompositionTransformation Composition

• More complex transformations can be created by concatenating or composing individual transformations together.

• Matrix multiplication is non-commutative order is vital• We can create an affine transformation representing rotation about a

point PR:

= translate to origin, rotate about origin, translate back to original location

MvTvSRTvTRSTTSRTM

RR PP TRTM

Page 20: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformation CompositionTransformation Composition

Page 21: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformation CompositionTransformation Composition

1000

0100

0

0

1000

0100

010

001

1000

0100

00

00

1000

0100

010

001

cossincossin

sincossincos

cossin

sincos

yxy

yxx

y

x

y

x

PPP

PPP

P

P

P

P

PP TRTM

Rotation in XY plane by q degrees anti-clockwise about point P

Page 22: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Euler AnglesEuler Angles• Euler angles represent the angles of rotation about the co-ordinate

axes required to achieve a given orientation (x, y, z)

• The resulting matrix is:• Any required rotation may be described (though not uniquely) as a

composition of 3 rotations about the coordinate axes. • Remember rotation does not commute order is important• A frequent requirement is to determine the matrix for rotation about an

given axis.• Such rotations have 3 degrees of freedom (DOF):

– 2 for spherical angles specifying axis orientation

– 1 for twist about the rotation axis

zyx RRRM

Page 23: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Rotational DOFRotational DOF

Sometimes known as roll, pitch and yaw

Page 24: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Rotation about an axisRotation about an axis

Page 25: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Rotation about an axisRotation about an axis

• Assume axis is defined by points P and Q therefore pivot point is P and rotation axis vector is:

• First we translate the pivot point to the origin T(-P)• Now we determine a series of rotations to achieve the

required rotation about the desired vector.• This is conceptually simpler if we first rotate the axis and

object so that the axis lines up with z say R(y)R(x)• Now we rotate about z by the required angle R()

QP

QP

v

Page 26: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Rotation about an axisRotation about an axis

• Then we undo the first 2 rotations to bring us back to the original orientation R(-x)R(-y)

• Finally we translate back to the original position T(P)• The final rotation matrix is:

• We need to determine Euler angles x and y which will orient the rotation axis along the z axis.

• We determine these using simple trigonometry.

PP yxxy TRRRRRTM

Page 27: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Aligning axis with Aligning axis with zz

x

y

vxvz

y

22zx vvr

vy

yx

x

v

r

sin

cos

r

vr

v

xy

zy

sin

cos

vzvx

x

z

y

vp

r vz

vx

y

Page 28: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Aligning axis with zAligning axis with z• Note that as shown the rotation about the x axis is anti-

clockwise but the y axis rotation is clockwise.

• Therefore the required y axis rotation is -y

1000

00

0010

00

1000

00

0010

00

1000

00

00

0001

1000

00

00

0001

rv

rv

rv

rv

rv

rv

rv

rv

rv

vr

rv

vr

zx

xz

yzx

xz

y

y

yx

y

yx

RR

RR

PP yxxy TRRRRRTM

Page 29: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Spherical Co-ordinatesSpherical Co-ordinates• The set of all normal vectors define a unit sphere which is

usually used to encode the set of all directions.• Each normal vector now has only 2 degrees of freedom

usually denoted using spherical co-ordinates (angles) = (, )

Page 30: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Normal VectorsNormal Vectors

• It is frequently useful to determine the relationship between the spherical co-ordinate and the vector:

sincos

sin

coscos

v

Page 31: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations and OpenGLTransformations and OpenGL®®

• glRotatef(angle, vx, vy, vz)– rotates about axis (vx, vy, vz) by angle (specified in degrees)

• glTranslate(dx, dy, dz)

– translates by displacement vector (dx, dy, dz)• glScalef(sx, sy, sz)

– apply scaling of sx in x direction, sy in y direction and sz in z direction (note that these values specify the diagonal of a required matrix)

• glLoadIdentity()

– creates an identity matrix (used for clearing all transformations)• glLoadMatrixf(matrixptr)

– loads a user specified transformation matrix where matrixptr is defined as GLfloat matrixptr[16];

Page 32: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations and OpenGLTransformations and OpenGL®®

• OpenGL defines 3 matrices for manipulation of 3D scenes:– GL_MODELVIEW: manipulates the view and models simultaneously– GL_PROJECTION: performs 3D 2D projection for display– GL_TEXTURE: for manipulating textures prior to mapping on objects

• Each acts as a state parameter; once set it remains until altered.• Having defined a GL_MODELVIEW matrix, all subsequent vertices are

created with the specified transformation.• Matrix transformation operations apply to the currently selected

system matrix:– use glMatrixMode(GL_MODELVIEW) to select modeling matrix

Page 33: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations and OpenGLTransformations and OpenGL®®

MODELVIEWmatrix

PROJECTIONmatrix

perspectivedivision

viewporttransformation

w

z

y

x

eye

eye

eye

eye

w

z

y

x

1dev

dev

y

x

proj

proj

proj

w

y

x

win

win

y

x

Vertex Geometry Pipeline

originalvertex

vertex in theeye coordinate

space

2d projectionof vertex ontoviewing plane

normalised devicecoordinates

(foreshortened)

final windowcoordinates

Page 34: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations and OpenGLTransformations and OpenGL®®

• The MODELVIEW matrix is a 4x4 affine transformation matrix and therefore has 12 degrees of freedom:

• The MODELVIEW matrix is used for both the model and the camera transformation– rotating the model is equivalent to rotating the camera in the opposite

direction OpenGL uses the same transformation matrix– this sometimes causes confusion!

1000z

y

x

tihg

tfed

tcba

Page 35: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations and OpenGLTransformations and OpenGL®®

• Each time an OpenGL transformation M is called the current MODELVIEW matrix C is altered:

Cvv CMvv

glTranslatef(1.5, 0.0, 0.0);glRotatef(45.0, 0.0, 0.0, 1.0);

CTRvv

Page 36: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Transformations and OpenGLTransformations and OpenGL®®

• Transformations are applied in the order specified (with respect to the vertex) which appears to be in reverse:

glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(1.5, 0.0, 0.0);glRotatef(45.0, 0.0, 0.0, 1.0);glVertex3f(1.0, 0.0, 0.0);

original rotate translate

Page 37: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Camera & Model Camera & Model TransformationsTransformations

• Given that camera and model transformations are specified using a single matrix we must consider the effect of these transformations on the coordinate frames of the camera and models.

• Assume we wish to orbit an object at a fixed orientation:– translate object away from camera– rotate around X to look at top of object– then pivot around object’s Y in order to

orbit properly.

Page 38: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Camera & Model Camera & Model TransformationsTransformations

• If the GL_MODELVIEW matrix is an identity matrix then the camera frame and the model frame are the same.– i.e. they are specified using the same co-ordinate system

• If we issue command glTranslatef(0.0, 0.0, -10.0) and then create the model:– a vertex at [0, 0, 0] in the model will be at [0, 0, -10] in the camera

frame– i.e. we have moved the object away from the camera

• This may be viewed conceptually in 2 ways:– we have positioned the object with respect to the world frame– we have moved the world-frame with respect to the camera frame

Page 39: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Camera & Model Camera & Model TransformationsTransformations

translate

rotate

object’s new Y

Page 40: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Camera & Model Camera & Model TransformationsTransformations

• A “local frame view” is usually adopted as it extends naturally to the specification of hierarchical model frames.

• This allows creation of jointed assemblies– articulated figures (animals, robots etc.)

• In the hierarchical model, each sub-component has its own local frame.

• Changes made to the parent frame are propagated down to the child frames (thus all models in a branch are globally controlled by the parent).

• This simplifies the specification of animation.

Page 41: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Aside: Display ListsAside: Display Lists• It is often expensive to compute or create a model for display.• we would prefer not to have to recalculate it each time for each new

animation frame.• Display lists allow the creation of an object in memory, where it

resides until destroyed.• Objects are drawn by issuing a request to the server to display a

given display list.

list = glGenLists(1);glNewList(list, GL_COMPILE);create_model();glEndList();

glCallList(list);

glDeleteLists(list, 1);

number of list IDs to create

GLint of firstlist ID user specified model code

used later to display the list

begin specification of the list

delete when finished(specifying number of lists)

Page 42: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Model TransformationsModel Transformations

• As the MODELVIEW matrix is changed objects are created with respect to a changing transformation.

• This is often termed the current transformation matrix or CTM.

• The CTM behaves like a 3D pointer, selecting new positions and orientations for the creation of geometries.

• The only complication with this view is that each new CTM is derived from a previous CTM, i.e. all CTMs are specified relative to previous versions.

• A scaling transformation can cause some confusion.

Page 43: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Scaling Transformation and the CTMScaling Transformation and the CTM

glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(3, 0, 0);glTranslatef(1, 0, 0);

gluCylinder(…);

glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(3, 0, 0);glScalef(0.5, 0.5, 0.5);glScalef(0.5, 0.5, 0.5);glTranslatef(1, 0, 0);

gluCylinder(…);

Page 44: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Hierarchical TransformationsHierarchical Transformations

• For geometries with an implicit hierarchy we wish to associate local frames with sub-objects in the assembly.

• Parent-child frames are related via a transformation.

• Transformation linkage is described by a tree:

• Each node has its own local co-ordinate system.

Page 45: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Hierarchical TransformationsHierarchical Transformations

Hierarchical transformation allow independent control over sub-parts of an assembly

R

R

RT

Page 46: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

translate base rotate joint1

rotate joint2 complex hierarchical transformation

Page 47: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

OpenGLOpenGL®® Implementation ImplementationglMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(bx, by, bz); create_base();glTranslatef(0, j1y, 0);glRotatef(joint1_orientation); create_joint1();glTranslatef(0, uay, 0); create_upperarm();glTranslatef(0, j2y);glRotatef(joint2_orientation); create_joint2();glTranslatef(0, lay, 0); create_lowerarm();glTranslatef(0, py, 0);glRotatef(pointer_orientation); create_pointer();

Page 48: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Hierarchical TransformationsHierarchical Transformations

• The previous example had simple one-to-one parent-child linkages.

• In general there may be many child frames derived from a single parent frame.

• we need some mechanism to remember the parent frame and return to it when creating new children.

• OpenGL provide a matrix stack for just this purpose:– glPushMatrix() saves the CTM– glPopMatrix() returns to the last saved CTM

Page 49: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Hierarchical TransformationsHierarchical Transformations

Each finger is a child of the parent (wrist) independent control over the orientation of the fingers relative to the wrist

Page 50: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Hierarchical TransformationsHierarchical Transformations

Page 51: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(bx, by, bz); create_base();glTranslatef(0, jy, 0);glRotatef(joint1_orientation); create_joint1();glTranslatef(0, ay, 0); create_upperarm();glTranslatef(0, wy);glRotatef(wrist_orientation); create_wrist();glPushMatrix();glPushMatrix(); // save frame glTranslatef(-xf, fy0, 0); glRotatef(lowerfinger1_orientation); glTranslatef(0, fy1, 0); create_lowerfinger1(); glTranslatef(0, fy2, 0); glRotatef(upperfinger1_orientation); create_fingerjoint1(); glTranslatef(0, fy3, 0); create_upperfinger1();glPopMatrix();glPopMatrix(); // restore frameglPushMatrix();glPushMatrix(); // do finger 2...glPopMatrix();glPopMatrix();glPushMatrix();glPushMatrix(); // do finger 3...glPopMatrix();glPopMatrix();

Finger1

Page 52: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

• GLU provides functionality for the creation of quadric surfaces– spheres, cones, cylinders, disks

• A quadric surface is defined by the following implicit equation:

OpenGLOpenGL®® Objects: GLU Objects: GLU

0222 jizhygxfxzeyzdxyczbyax

ihg

fed

cba

z

y

x

xjxxT QQ and where0

GLUquadricObj* gluNewQuadric(void);gluDeleteQuadric(GLYquadricObj *obj);

use to initialise a quadric

delete when finished

Page 53: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

OpenGLOpenGL®® Objects: GLU Spheres Objects: GLU Spheresvoid gluSphere(GLUquadricObj *obj, double radius, int slices, int stacks);

gluSphere(obj, 1.0, 5, 5);

gluSphere(obj, 1.0, 10, 10);

gluSphere(obj, 1.0, 20, 20);

Page 54: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Other GLU QuadricsOther GLU Quadricsvoid gluCylinder(GLUquadricObj *obj, double base_radius, double top_radius,

double height, int slices, int stacks);

gluCylinder(obj, 1.0, 1.0, 2.0, 20, 8);

gluCylinder(obj, 1.0, 1.0, 2.0, 8, 8);

gluCylinder(obj, 1.0, 0.3, 2.0, 20, 8);

Page 55: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

Other GLU QuadricsOther GLU Quadricsvoid gluDisk(GLUquadricObj *obj, double inner_radius, double outer_radius,

int slices, int rings);

gluCylinder(obj, 1.0, 0.0, 2.0, 20, 8);

gluDisk(obj, 0.0, 2.0, 10, 3);

gluDisk(obj, 0.5, 2.0, 10, 3);

Page 56: Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin

OpenGLOpenGL®® Objects: GLUT Objects: GLUT

glutWireTeapot(1.0)

glutSolidTeapot(1.0)

size

glutSolidDodecahedron()

void glutSolidTorus(double inner_radius, double outer_radius,int nsides, int rings);

glutWireTorus(0.3, 1.5,20, 20);

glutSolidTorus(0.3, 1.5,20, 20);