CUGL
2.0
|
#include <cugl.h>
Public Member Functions | |
Matrix () | |
Matrix (GL_Matrix r) | |
Matrix (GLenum mode) | |
Matrix (const Vector &axis, double theta) | |
Matrix (const Plane &refl) | |
Matrix (const Point &lightPos, const Plane &plane) | |
Matrix (const Quaternion &q) | |
Matrix (const Vector &u, const Vector &v) | |
Matrix (const GLfloat m00, const GLfloat m10, const GLfloat m20, const GLfloat m30, const GLfloat m01, const GLfloat m11, const GLfloat m21, const GLfloat m31, const GLfloat m02, const GLfloat m12, const GLfloat m22, const GLfloat m32, const GLfloat m03, const GLfloat m13, const GLfloat m23, const GLfloat m33) | |
Quaternion | quaternion () const |
GLfloat * | get () |
Matrix | transpose () const |
GLfloat | trace () |
Matrix | inv () const |
Matrix | operator~ () const |
void | apply () const |
Point | apply (const Point &p) const |
Vector | apply (const Vector &v) const |
Vector | axis () const |
double | angle () const |
GLfloat & | operator() (int i, int j) |
const GLfloat & | operator() (int i, int j) const |
void | reflect (const Plane &p) |
void | shadow (const Point &lightPos, const Plane &plane) |
Matrix | operator+= (const Matrix &rhs) |
Matrix | operator-= (const Matrix &rhs) |
Matrix | operator*= (const Matrix &rhs) |
Matrix & | operator*= (GLfloat s) |
Matrix & | operator/= (GLfloat s) |
Private Attributes | |
GL_Matrix | m |
Friends | |
Matrix | operator+ (const Matrix &m, const Matrix &n) |
Matrix | operator- (const Matrix &m, const Matrix &n) |
Matrix | 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) |
bool | operator== (const Matrix &x, const Matrix &y) |
bool | operator!= (const Matrix &x, const Matrix &y) |
std::ostream & | operator<< (std::ostream &os, const Matrix &m) |
An instance is a matrix compatible with an OpenGL transformation matrix. An instance of class Matrix is a 4 by 4 matrix with components of type GLfloat
. The components are ordered in the same way as an OpenGL matrix (column-row order, for compatibility with FORTRAN).
Note that OpenGL performs matrix calculations very efficiently. As far as possible, construct transformations using sequences of OpenGL matrix operations. Construct and use the matrices here only if OpenGL does not provide the required facilities.
cugl::Matrix::Matrix | ( | ) |
Construct the identity matrix.
cugl::Matrix::Matrix | ( | GL_Matrix | r | ) |
Construct a copy of an arbitrary OpenGL matrix.
|
explicit |
Construct a copy of an OpenGL projection or model view matrix.
mode | should be GL_PROJECTION_MATRIX or GL_MODELVIEW_MATRIX . |
Report error BAD_MATRIX_MODE and construct identity matrix for other values of mode.
cugl::Matrix::Matrix | ( | const Vector & | axis, |
double | theta | ||
) |
Construct a rotation matrix.
axis | is the axis of rotation. |
theta | is the magnitude of the rotation. |
theta
should be in radians (unlike OpenGL, which uses degrees).
|
inlineexplicit |
Construct a matrix that reflects a point in the given plane. The matrix can be used to simulate a mirror in an OpenGL program. See also Matrix::reflect().
refl | is the plane of reflection. |
Definition at line 2894 of file cugl.h.
References reflect().
Construct a shadow matrix from a point light source and a plane. The matrix transforms an object into its shadow on the given plane. It is your job to ensure that the shadow has the appropriate colour, transparency, etc. The light source may be a local point (w > 0) or a point at infinity (w = 0). See also Matrix::shadow()
.
lightPos | is the position of the light source. |
plane | is the plane onto which the shadow is projected. |
Definition at line 2899 of file cugl.h.
References shadow().
|
explicit |
Construct a rotation matrix from a quaternion.
Construct the matrix that rotates one vector to another.
u | is a vector representing an initial orientation. |
v | is a vector representing the final orientation. The matrix, applied to u, will yield v. |
|
inline |
double cugl::Matrix::angle | ( | ) | const |
Return the angle (in radians) of a rotation matrix. Report error BAD_ROTATION_MATRIX
and leave result undefined, if the matrix is not a rotation.
|
inline |
Apply this matrix to a point.
Definition at line 2930 of file cugl.h.
References m, cugl::Point::w, cugl::Point::x, cugl::Point::y, and cugl::Point::z.
Vector cugl::Matrix::axis | ( | ) | const |
Return the axis of a rotation matrix. Report error BAD_ROTATION_MATRIX
and leave result undefined, if the matrix is not a rotation.
|
inline |
Matrix cugl::Matrix::inv | ( | ) | const |
Compute the inverse of this matrix using Gauss-Jordan elimination. If the matrix is singular, report SINGULAR_MATRIX
and return the zero matrix. Calculations are performed in double precision because this gives slightly better results. The prefix operator ~ has the same effect.
Referenced by operator~().
|
inline |
|
inline |
Return a reference to the element m
[i][j] of the const
matrix. This version is used for const
instances (m(i,j)
cannot appear on the left of =
).
i
and j
must be in the range [0,3]. m
[i][j] of the matrix. Definition at line 2956 of file cugl.h.
References m.
|
inline |
|
inline |
|
inline |
Quaternion cugl::Matrix::quaternion | ( | ) | const |
Return the quaternion corresponding to this matrix. This function may report BAD_ROTATION_MATRIX.
void cugl::Matrix::reflect | ( | const Plane & | p | ) |
Set the matrix so that it creates a shadow on the plane p
from a light source lightPos
. The matrix transforms an object into its shadow on the given plane. It is your job to ensure that the shadow has the appropriate colour, transparency, etc. The point p
may be either a local point (w > 0) or a point at infinity (w = 0). See also constructors for class Matrix.
lightPos | is the position of the light source causing the shadow. |
plane | is the plane upon which the shadow is cast. |
Referenced by Matrix().
|
inline |
Matrix cugl::Matrix::transpose | ( | ) | const |
Return the transpose of this matrix.
|
friend |
Write a four-line image of the matrix to the output stream. The current settings of the stream formatting parameters are used. If a width is specified with setw()
, it is applied to each element of the matrix, not the matrix as a whole.
|
private |
The elements of the matrix.
Definition at line 1121 of file cugl.h.
Referenced by apply(), get(), Matrix(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), and trace().