CUGL  2.0
Functions
Miscellaneous functions

Functions

double cugl::radians (double angle)
 
double cugl::degrees (double angle)
 
double cugl::sqr (double x)
 
unsigned int cugl::randInt (unsigned int max)
 
int cugl::randSym (unsigned int max)
 
double cugl::randReal ()
 
void cugl::triStripNormals (Point points[], Vector normals[], int numPoints, bool neg=false)
 
void cugl::revolve (int numSteps, GLfloat coor[][2], int numSlices, bool drawNormals=false)
 
void cugl::lookAt (Point eye)
 
void cugl::lookAt (Point eye, Point model)
 
void cugl::lookAt (Point eye, Point model, Vector up)
 

Detailed Description

Function Documentation

double cugl::degrees ( double  angle)
inline

Convert radians to degrees.

Definition at line 2323 of file cugl.h.

References cugl::PI.

void cugl::lookAt ( Point  eye)
inline

Call gluLookAt() looking at the origin of the model (0,0,0) with 'up' vector (0,1,0).

Parameters
eyeis the position of the viewer's eye.

Definition at line 2418 of file cugl.h.

void cugl::lookAt ( Point  eye,
Point  model 
)
inline

Call gluLookAt() with 'up' vector (0,1,0).

Parameters
eyeis the position of the viewer's eye in model coordinates.
modelis the point at the centre of the view in model coordinates.

Definition at line 2433 of file cugl.h.

void cugl::lookAt ( Point  eye,
Point  model,
Vector  up 
)
inline

Call gluLookAt().

Parameters
eyeis the position of the viewer's eye in model coordinates.
modelis the point at the centre of the view in model coordinates.
upis a vector giving the upwards direction in the model.

Definition at line 2449 of file cugl.h.

double cugl::radians ( double  angle)
inline

Convert degrees to radians.

Definition at line 2315 of file cugl.h.

References cugl::PI.

unsigned int cugl::randInt ( unsigned int  max)
inline

Return a random integer in [0, max).

Definition at line 2335 of file cugl.h.

Referenced by cugl::randReal(), and cugl::randSym().

double cugl::randReal ( )
inline

Return a random double in [0, 1).

Definition at line 2356 of file cugl.h.

References cugl::randInt().

int cugl::randSym ( unsigned int  max)
inline

Return a random integer in [-max, max].

Definition at line 2350 of file cugl.h.

References cugl::randInt().

void cugl::revolve ( int  numSteps,
GLfloat  coor[][2],
int  numSlices,
bool  drawNormals = false 
)

Constructs a surface of revolution. Constructs and renders a surface of revolution obtained by rotating a curve about the Y axis.

Parameters
numStepsis the number of points in the array coor
cooris the 2D coordinates of points of the profile
numSlicesis the number of pie-shaped slices used to render the surface.
drawNormalsdetermines whether normals are generated. By default, normals are not generated.

For example, if numSlices = 20, points will be constructed at 360/20 = 18 degree intervals.

This function constructs an array of points in 3D space and then issues calls to glVertex(). If drawNormals is true, it also issues calls to glNormal(). The effect of these calls is to define a 3D mesh. It is up to the caller to set the OpenGL state for rendering: this includes setting material properties and defining rules for polygon shading.

The normals generated by revolve() are obtained by averaging the normals of the polygons that meet at each vertex. Consequently, if GL_SMOOTH shading is used and enough points are specified, the object should look fairly smooth.

Note
This function has been replaced by class Revolute, which provides more functionality and is more efficient.
double cugl::sqr ( double  x)
inline

Return the square of the argument.

Definition at line 2329 of file cugl.h.

void cugl::triStripNormals ( Point  points[],
Vector  normals[],
int  numPoints,
bool  neg = false 
)

Construct normals for OpenGL triangle strips. Given a set of vertexes definining a triangle strip in OpenGL format, this functions constructs a normal corresponding to each vertex.

Parameters
pointsis an array of points giving the vertex coordinates.
normalsis an array of vectors in which the vertex normals will be stored.
numPointsis the number of vertexes provided and the number of normals that will be calculated.
negspecifies negated normals, if true. The default is false.
Note
To avoid allocation and deallocation overhead, this function uses a a fixed amount of workspace that allows up to 100 vertexes to be processed. If numPoints > 100, the function will have no effect.
For efficiency, it is better to compute the normals during initialization rather than each time the model is displayed.