CUGL  2.0
Classes | Typedefs | Enumerations | Functions | Variables
cugl Namespace Reference

Classes

class  Point
 
class  Line
 
class  Plane
 
class  Vector
 
class  Matrix
 
class  Quaternion
 
class  BaseCamera
 
class  Camera
 
class  Interpolator
 
class  PixelMap
 
class  Revolute
 

Typedefs

typedef GLfloat GL_Matrix [4][4]
 
typedef GLfloat * GLfloatArray
 

Enumerations

enum  CUGLErrorType {
  NO_ERROR = 0, BAD_INDEX, BAD_MATRIX_MODE, BAD_ROTATION_MATRIX,
  SINGULAR_MATRIX, ZERO_DIVISOR, ZERO_NORM, BAD_INTERPOLATOR_ARG,
  OPEN_FAILED, NOT_BMP_FILE, NOT_24_BITS, COMPRESSED_BMP_FILE,
  NOT_ENOUGH_MEMORY, NO_PIX_MAP, BAD_PLANE, BAD_LINE,
  TOO_MANY_MATERIALS, TOO_MANY_POINTS
}
 
enum  MATERIAL {
  BLACK, WHITE, RED, GREEN,
  BLUE, METAL, GLASS, BRASS,
  BRONZE, POLISHED_BRONZE, CHROME, COPPER,
  POLISHED_COPPER, GOLD, POLISHED_GOLD, PEWTER,
  SILVER, POLISHED_SILVER, EMERALD, JADE,
  OBSIDIAN, PEARL, RUBY, TURQUOISE,
  BLACK_PLASTIC, BLACK_RUBBER, LAST_VALUE
}
 

Functions

CUGLErrorType getError ()
 
const char * getErrorString (CUGLErrorType err)
 
void checkCUGLStatus ()
 
void checkOpenGLStatus ()
 
const Vector I (1, 0, 0)
 
const Vector J (0, 1, 0)
 
const Vector K (0, 0, 1)
 
double radians (double angle)
 
double degrees (double angle)
 
double sqr (double x)
 
unsigned int randInt (unsigned int max)
 
int randSym (unsigned int max)
 
double randReal ()
 
void triStripNormals (Point points[], Vector normals[], int numPoints, bool neg=false)
 
void revolve (int numSteps, GLfloat coor[][2], int numSlices, bool drawNormals=false)
 
void lookAt (Point eye)
 
void lookAt (Point eye, Point model)
 
void lookAt (Point eye, Point model, Vector up)
 
void axes (GLfloat size=1)
 
void buildPlane (bool shadow=false)
 
GLuint makePlaneList (bool shadow=false)
 
void setMaterial (const int m, GLenum face=GL_FRONT)
 
int addMaterial (GLfloat ambR, GLfloat ambG, GLfloat ambB, GLfloat ambA, GLfloat difR, GLfloat difG, GLfloat difB, GLfloat difA, GLfloat speR, GLfloat speG, GLfloat speB, GLfloat speA, GLfloat shine)
 
int addMaterial (GLfloat params[])
 
Point operator+ (const Point &p, const Vector &v)
 
Point operator+ (const Vector &v, const Point &p)
 
Point operator* (const Point &p, GLfloat s)
 
Point operator* (GLfloat s, const Point &p)
 
bool operator== (const Point &p, const Point &q)
 
bool operator!= (const Point &p, const Point &q)
 
GLfloat dist (const Point &p, const Plane &s)
 
GLfloat dist (const Plane &s, const Point &p)
 
bool operator== (const Line &m, const Line &n)
 
bool operator!= (const Line &m, const Line &n)
 
bool operator== (const Plane &p, const Plane &q)
 
bool operator!= (const Plane &p, const Plane &q)
 
Vector operator- (const Point &p, const Point &q)
 
Vector operator+ (const Vector &u, const Vector &v)
 
Vector operator- (const Vector &u, const Vector &v)
 
Vector operator* (const Vector &v, GLfloat s)
 
Vector operator* (GLfloat s, const Vector &v)
 
Vector cross (const Vector &u, const Vector &v)
 
Vector operator* (const Vector &u, const Vector &v)
 
GLfloat dot (const Vector &u, const Vector &v)
 
bool operator== (const Vector &u, const Vector &v)
 
bool operator!= (const Vector &u, const Vector &v)
 
Matrix operator+ (const Matrix &m, const Matrix &n)
 
Matrix operator- (const Matrix &m, const Matrix &n)
 
Matrix operator* (const Matrix &m, const Matrix &n)
 
bool operator== (const Matrix &m, const Matrix &n)
 
bool operator!= (const Matrix &m, const Matrix &n)
 
Matrix operator* (GLfloat s, const Matrix &m)
 
Matrix operator* (const Matrix &m, GLfloat s)
 
Matrix operator/ (const Matrix &m, GLfloat s)
 
GLfloat dot (const Quaternion &q, const Quaternion &r)
 
Quaternion operator+ (const Quaternion &q, const Quaternion &r)
 
Quaternion operator- (const Quaternion &q, const Quaternion &r)
 
Quaternion operator* (const Quaternion &q, const Quaternion &r)
 
Quaternion operator* (const Vector &v, const Quaternion &q)
 
Quaternion operator* (const Quaternion &q, const Vector &v)
 
Quaternion operator* (const Quaternion &q, GLfloat a)
 
Quaternion operator* (GLfloat a, const Quaternion &q)
 
bool operator== (const Quaternion &q, const Quaternion &r)
 
bool operator!= (const Quaternion &q, const Quaternion &r)
 

Variables

const char version [] = "CUGL V2 2009.11.24"
 
const double PI = 4 * atan(1.0)
 

Detailed Description

Extensions

Todo:

Quaternion += and -=

Matrix operator*=(Matrix) - done

bool isVisible(Point) - harder than it looks

Typedef Documentation

typedef GLfloat cugl::GL_Matrix[4][4]

The type of OpenGL projection and model view matrices. It is tempting to write CUGL as a template llibrary, but the fixed type of OpenGL matrices makes this difficult to do effectively.

Definition at line 62 of file cugl.h.

typedef GLfloat* cugl::GLfloatArray

The type of an array of GLfloats.

Definition at line 2176 of file cugl.h.

Function Documentation

Vector cugl::cross ( const Vector &  u,
const Vector &  v 
)
inline

Return cross product of vectors u and v.

Definition at line 2859 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

GLfloat cugl::dist ( const Point &  p,
const Plane &  s 
)
inline

Return the distance between a Point and a Plane. The result has the correct magnitude only if the Point and the Plane are both in normal form. In particular, the result is incorrect if the Point is at infinity. However, the sign of the result is correct in all cases, and so it is not necessary to provide normalized arguments if only the sign is important.

Definition at line 2673 of file cugl.h.

References cugl::Plane::a, cugl::Plane::b, cugl::Plane::c, cugl::Plane::d, cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.

GLfloat cugl::dist ( const Plane &  s,
const Point &  p 
)
inline

Return the distance between a Point and a Plane. The result has the correct magnitude only if the Point and the Plane are both in normal form. In particular, the result is incorrect if the Point is at infinity. However, the sign of the result is correct in all cases, and so it is not necessary to provide normalized arguments if only the sign is important.

Definition at line 2678 of file cugl.h.

References cugl::Plane::a, cugl::Plane::b, cugl::Plane::c, cugl::Plane::d, cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.

GLfloat cugl::dot ( const Vector &  u,
const Vector &  v 
)
inline

Return dot product of vectors u and v.

Definition at line 2875 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

Referenced by dot().

GLfloat cugl::dot ( const Quaternion &  q,
const Quaternion &  r 
)
inline

The 'logarithm' of a unit quaternion is a vector. This function is defined because it appears in descriptions of quaternions. Although the name 'ln' is appropriate in some ways, this function must be used with caution because it may not have the properties you expect of a logarithm. For example, ln(q1)+ln(q2) makes sense only if q1 and q2 have the same axis.

Precondition
The quaternion must be a unit quaternion. The 'exponent' of a vector is a unit quaternion. Although the name 'exp' is appropriate in some ways, this function must be used with caution because it may not have the properties you expect of an exponent. For example, exp(v1+v2)=exp(v1)*exp(v2) only if v1 and v2 have the same direction. Return the dot product of quaternions q and r. The dot product of (s,u) and (t,v) is st+dot(u,v) where dot(u,v) denotes the vector dot product of u and v.
Returns
the dot product of quaternions q and r.

Definition at line 3219 of file cugl.h.

References dot(), cugl::Quaternion::s, and cugl::Quaternion::v.

const Vector cugl::I ( ,
,
 
)

Unit vector parallel to X axis.

const Vector cugl::J ( ,
,
 
)

Unit vector parallel to Y axis.

const Vector cugl::K ( ,
,
 
)

Unit vector parallel to Z axis.

bool cugl::operator!= ( const Point &  p,
const Point &  q 
)
inline

Compare two points. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2668 of file cugl.h.

bool cugl::operator!= ( const Line &  m,
const Line &  n 
)
inline

Compare two lines. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2701 of file cugl.h.

bool cugl::operator!= ( const Plane &  p,
const Plane &  q 
)
inline

Compare two planes. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2722 of file cugl.h.

bool cugl::operator!= ( const Vector &  u,
const Vector &  v 
)
inline

Compare two vectors. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2885 of file cugl.h.

bool cugl::operator!= ( const Matrix &  m,
const Matrix &  n 
)
inline

Compare two matrices. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3088 of file cugl.h.

bool cugl::operator!= ( const Quaternion &  q,
const Quaternion &  r 
)
inline

Compare two quaternions. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3296 of file cugl.h.

Point cugl::operator* ( const Point &  p,
GLfloat  s 
)
inline

Scale a point.

Returns
Point at (p.x + p.w*v.x, p.y + p.w*v.y, p.z + p.w*v.z).

Definition at line 2653 of file cugl.h.

References cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.

Point cugl::operator* ( GLfloat  s,
const Point &  p 
)
inline

Scale a point. Multiply each of the components of the Point by s. In homogeneous coordinates, this operation does not change the ``position'' of the Point. However, it may be used, for example, to normalize a Point.

Returns
The scaled Point.

Definition at line 2658 of file cugl.h.

References cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.

Vector cugl::operator* ( const Vector &  v,
GLfloat  s 
)
inline

Return Vector s*v.

Definition at line 2849 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

Vector cugl::operator* ( GLfloat  s,
const Vector &  v 
)
inline

Return Vector s*v.

Definition at line 2854 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

Vector cugl::operator* ( const Vector &  u,
const Vector &  v 
)
inline

Return cross product of vectors u and v.

Definition at line 2867 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

Matrix cugl::operator* ( const Matrix &  m,
const Matrix &  n 
)
inline

Multiply two matrices.

Definition at line 3057 of file cugl.h.

Matrix cugl::operator* ( GLfloat  s,
const Matrix &  m 
)
inline

Multiply scalar and matrix.

Definition at line 3097 of file cugl.h.

Matrix cugl::operator* ( const Matrix &  m,
GLfloat  s 
)
inline

Multiply matrix and scalar.

Definition at line 3106 of file cugl.h.

Quaternion cugl::operator* ( const Quaternion &  q,
const Quaternion &  r 
)
inline

Return the quaternion product q*r. If q and r represent rotations, then q*r represents the rotation q followed by the rotation r.

Note
Quaternion multiplication is not commutative: q*r is not equal to r*q.
Returns
the Quaternion product q*r.

Definition at line 3234 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Quaternion cugl::operator* ( const Vector &  v,
const Quaternion &  q 
)
inline

Promote the vector v to a quaternion qv and return the quaternion product qv*q.

Definition at line 3245 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Quaternion cugl::operator* ( const Quaternion &  q,
const Vector &  v 
)
inline

Promote the vector v to a quaternion qv and return the quaternion product q*qv.

Definition at line 3256 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Quaternion cugl::operator* ( const Quaternion &  q,
GLfloat  a 
)
inline

Return the quaternion a*q, where a is a scalar. a is a scalar and a*(s,v) = (a*s, a*v).

Returns
the Quaternion a*q.

Definition at line 3281 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Quaternion cugl::operator* ( GLfloat  a,
const Quaternion &  q 
)
inline

Return the quaternion a*q, where a is a scalar. a is a scalar and a*(s,v) = (a*s, a*v).

Returns
the Quaternion a*q.

Definition at line 3286 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Point cugl::operator+ ( const Point &  p,
const Vector &  v 
)
inline

Displace a Point with a Vector. The components of the Vector are added to the corresponding components of the Point. If the Point is not in normal form, the Vector is implicitly scaled.

Returns
Point at (p.x+p.w*v.x, p.y+p.w*v.y, p.z+p.w*v.z, p.w).

Definition at line 2643 of file cugl.h.

References cugl::Point::w, cugl::Point::x, cugl::Vector::x, cugl::Point::y, cugl::Vector::y, cugl::Point::z, and cugl::Vector::z.

Point cugl::operator+ ( const Vector &  v,
const Point &  p 
)
inline

Displace a Point with a Vector. The components of the Vector are added to the corresponding components of the Point. If the Point is not in normal form, the Vector is implicitly scaled.

Returns
Point at (p.x+p.w*v.x, p.y+p.w*v.y, p.z+p.w*v.z, p.w).

Definition at line 2648 of file cugl.h.

References cugl::Point::w, cugl::Point::x, cugl::Vector::x, cugl::Point::y, cugl::Vector::y, cugl::Point::z, and cugl::Vector::z.

Vector cugl::operator+ ( const Vector &  u,
const Vector &  v 
)
inline

Return Vector u+v.

Definition at line 2839 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

Matrix cugl::operator+ ( const Matrix &  m,
const Matrix &  n 
)
inline

Add two matrices.

Definition at line 3029 of file cugl.h.

Quaternion cugl::operator+ ( const Quaternion &  q,
const Quaternion &  r 
)
inline

Return the quaternion q+r.

Note
The sum of two unit quaternions is not in general a unit quaternion. However, it occasionally appears in expressions such as k q1 + (1 - k) q2, which does yield a unit quaternion.
Returns
the Quaternion q+r.

Definition at line 3224 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Vector cugl::operator- ( const Point &  p,
const Point &  q 
)
inline

Return the vector corresponding to the displacement between the two points. This is the vector (p.x/p.w - q.x/q.w, p.y/p.w - q.y/q.w, p.z/p.w - q.z/q.w). If p or q is a point at infinity, return the zero vector.

Returns
the Vector corresponding to the displacement between the two points.

Definition at line 2831 of file cugl.h.

References cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.

Vector cugl::operator- ( const Vector &  u,
const Vector &  v 
)
inline

Return Vector u-v.

Definition at line 2844 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

Matrix cugl::operator- ( const Matrix &  m,
const Matrix &  n 
)
inline

Subtract two matrices.

Definition at line 3044 of file cugl.h.

Quaternion cugl::operator- ( const Quaternion &  q,
const Quaternion &  r 
)
inline

Return the quaternion q-r.

Note
The difference of two unit quaternions is not in general a unit quaternion.
Returns
the Quaternion q-r.

Definition at line 3229 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.

Matrix cugl::operator/ ( const Matrix &  m,
GLfloat  s 
)
inline

Divide by scalar.

Definition at line 3115 of file cugl.h.

bool cugl::operator== ( const Point &  p,
const Point &  q 
)
inline

Compare two points. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2663 of file cugl.h.

References cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.

bool cugl::operator== ( const Line &  m,
const Line &  n 
)
inline

Compare two lines. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2696 of file cugl.h.

References cugl::Line::f, and cugl::Line::s.

bool cugl::operator== ( const Plane &  p,
const Plane &  q 
)
inline

Compare two planes. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2717 of file cugl.h.

References cugl::Plane::a, cugl::Plane::b, cugl::Plane::c, and cugl::Plane::d.

bool cugl::operator== ( const Vector &  u,
const Vector &  v 
)
inline

Compare two vectors. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2880 of file cugl.h.

References cugl::Vector::x, cugl::Vector::y, and cugl::Vector::z.

bool cugl::operator== ( const Matrix &  m,
const Matrix &  n 
)
inline

Compare two matrices. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3079 of file cugl.h.

bool cugl::operator== ( const Quaternion &  q,
const Quaternion &  r 
)
inline

Compare two quaternions. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3291 of file cugl.h.

References cugl::Quaternion::s, and cugl::Quaternion::v.