Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

gl::matrix4 Class Reference

A 4x4 matrix for use with OpenGL. More...

#include <gl_matrix.h>

Inheritance diagram for gl::matrix4:

Inheritance graph
[legend]
Collaboration diagram for gl::matrix4:

Collaboration graph
[legend]
List of all members.

Public Methods

 matrix4 (void)
 Default Constructor.

 matrix4 (real_t d00, real_t d01, real_t d02, real_t d10, real_t d11, real_t d12, real_t d20, real_t d21, real_t d22)
 Rotation Set Constructor. More...

 matrix4 (real_t d00, real_t d01, real_t d02, real_t d03, real_t d10, real_t d11, real_t d12, real_t d13, real_t d20, real_t d21, real_t d22, real_t d23, real_t d30, real_t d31, real_t d32, real_t d33)
 Full Matrix Constructor. More...

virtual ~matrix4 (void)
 Destructor.

void build_frustum (const GLfloat left, const GLfloat right, const GLfloat bottom, const GLfloat top, const GLfloat near, const GLfloat far)
 Create an OpenGL frustum matrix. More...

void build_perspective (const GLfloat field_of_view, const GLfloat aspect_ratio, const GLfloat near, const GLfloat far)
 Create an OpenGL prespective matrix. More...

void build_look_at (const math::vector3 eye, const math::vector3 center, const math::vector3 up)
 Create an OpenGL view matrix. More...

gl::matrix4 & operator= (const math::matrix4 &m)
 Assignment from the base class.

 operator const GLfloat * (void)
 Cast operator to GLfloat*. More...

math::vector3 operator * (const math::vector3 &v) const
 Matrix Vector Mulitplication. More...

math::matrix4 operator * (const math::matrix4 &rhs) const
 Matrix Multiplication.

 operator const real_t * (void) const
 Cast operator to real_t*. More...

void set (real_t d00, real_t d01, real_t d02, real_t d10, real_t d11, real_t d12, real_t d20, real_t d21, real_t d22)
 Sets rotation part of matrix. More...

void set (real_t d00, real_t d01, real_t d02, real_t d03, real_t d10, real_t d11, real_t d12, real_t d13, real_t d20, real_t d21, real_t d22, real_t d23, real_t d30, real_t d31, real_t d32, real_t d33)
 Sets the matrix. More...

void set (unsigned int row, unsigned int col, real_t x)
 Set the element at row, col to x. More...

real_t operator() (unsigned int row, unsigned int col) const
 Get the element at row, col. More...

real_toperator() (unsigned int row, unsigned int col)
 Return a reference to the element at row, col. More...

math::matrix4 operator+ (const math::matrix4 &rhs) const
 Matrix Addition.

math::matrix4 operator- (const math::matrix4 &rhs) const
 Matrix Subtraction.

void transpose (void)
 Transposes the matrix. More...

void set_identity ()
 Sets the matirx to the identity matrix. More...

void from_angle_axis (real_t radians, const math::vector3 &axis)
 Creates a rotation matrix given around an arbitrary axis. More...

math::matrix4 get_inverted_rotation (void) const
 Computes the inverse of the rotation matrix. More...

void set_translation (const math::vector3 &trans)
 Sets the translation part of the matrix. More...

math::vector3 get_translation (void) const
 Returns a vector describing the translation part of the matrix.


Static Public Attributes

const math::matrix4 IDENTITY
 The identity matrix. More...

const math::matrix4 ZERO
 The zero matrix. More...


Protected Attributes

real_t m_transposed_data [4][4]
real_t m_data [4][4]
 Actual matrix data.


Friends

math::vector3 operator * (const math::vector3 &v, const math::matrix4 &m)
 Vector Matrix Mulitplication. More...

std::ostream & operator<< (std::ostream &o, const math::matrix4 &m)
 stream output operator.


Detailed Description

A 4x4 matrix for use with OpenGL.

Definition at line 17 of file gl_matrix.h.


Constructor & Destructor Documentation

gl::matrix4::matrix4 real_t    d00,
real_t    d01,
real_t    d02,
real_t    d10,
real_t    d11,
real_t    d12,
real_t    d20,
real_t    d21,
real_t    d22
[inline]
 

Rotation Set Constructor.

Sets the matrix as follows:

Reimplemented from math::matrix4.

Definition at line 39 of file gl_matrix.h.

References real_t.

gl::matrix4::matrix4 real_t    d00,
real_t    d01,
real_t    d02,
real_t    d03,
real_t    d10,
real_t    d11,
real_t    d12,
real_t    d13,
real_t    d20,
real_t    d21,
real_t    d22,
real_t    d23,
real_t    d30,
real_t    d31,
real_t    d32,
real_t    d33
[inline]
 

Full Matrix Constructor.

Sets the matrix as follows:

Reimplemented from math::matrix4.

Definition at line 61 of file gl_matrix.h.

References real_t.


Member Function Documentation

void gl::matrix4::build_frustum const GLfloat    left,
const GLfloat    right,
const GLfloat    bottom,
const GLfloat    top,
const GLfloat    near,
const GLfloat    far
 

Create an OpenGL frustum matrix.

Creates a matrix for a perspective view frustum. (left , bottom, -near) and (right, top, -near) specify the (x, y, z) coordinates of the lower left and upper right corners of the near clipping plane. near and far give the distances from the viewpoint to the near and far clipping planes

Definition at line 9 of file gl_matrix.cpp.

References math::matrix4::m_data.

Referenced by build_perspective.

void gl::matrix4::build_look_at const math::vector3    eye,
const math::vector3    center,
const math::vector3    up
 

Create an OpenGL view matrix.

Creates a viewing matrix.

Parameters:
eye  is the location of the viewpoint.
center  is any point along the desired line of sight.
up  indicates which direction is up.

Definition at line 57 of file gl_matrix.cpp.

References math::matrix4::m_data, math::vector3::normalize, math::vector3::x, math::vector3::y, and math::vector3::z.

void gl::matrix4::build_perspective const GLfloat    field_of_view,
const GLfloat    aspect_ratio,
const GLfloat    near,
const GLfloat    far
 

Create an OpenGL prespective matrix.

Creates a matrix for a symmetric perspective view frustum.

Parameters:
field_of_view  is the the angle of the field of view in the yz-plane; it must be in the range [0-180].
aspect_ratio  is the aspect ratio for the frustum.
near  and
far  are the distances from the viewpoint to the near and far clipping planes

Definition at line 45 of file gl_matrix.cpp.

References build_frustum.

void math::matrix4::from_angle_axis real_t    radians,
const math::vector3   axis
[inherited]
 

Creates a rotation matrix given around an arbitrary axis.

Given an axis and an angle, this method will create and set this matrix as the rotation matrix that describes the rotation around the axis by angle.

Note:
Rotations are right-handed.
Parameters:
radians  A real number in radians.
axis  A unit length vector describing the axis to rotate around.

Definition at line 247 of file matrix.cpp.

References math::matrix4::m_data, real_t, math::vector3::x, math::vector3::y, and math::vector3::z.

math::matrix4 math::matrix4::get_inverted_rotation void    const [inherited]
 

Computes the inverse of the rotation matrix.

Inverts the rotation part of this matrix.

Note:
All translation, scaling, etc. info is lost in the matrix. This method only inverts the rotation part of the matrix.
Returns:
A new matrix containing the inverted rotation of this matrix.

Definition at line 280 of file matrix.cpp.

References math::equals, math::matrix4::IDENTITY, math::matrix4::m_data, and real_t.

math::vector3 math::matrix4::operator * const math::vector3   v const [inherited]
 

Matrix Vector Mulitplication.

Multiplies the matrix m by vector v. The operation is defined as:

Definition at line 163 of file matrix.cpp.

References math::matrix4::m_data, math::vector3::x, math::vector3::y, and math::vector3::z.

gl::matrix4::operator const GLfloat * void   
 

Cast operator to GLfloat*.

Returns:
a read-only pointer to the matrix data in column major order.

Definition at line 110 of file gl_matrix.cpp.

References math::matrix4::m_data.

math::matrix4::operator const real_t * void    const [inline, inherited]
 

Cast operator to real_t*.

Returns:
A read-only pointer to the internal matrix data.

Definition at line 126 of file matrix.h.

real_t& math::matrix4::operator() unsigned int    row,
unsigned int    col
[inline, inherited]
 

Return a reference to the element at row, col.

Note:
abort( ) may be called if row or col is not one of 0, 1, 2, or 3.

Definition at line 196 of file matrix.h.

References real_t.

real_t math::matrix4::operator() unsigned int    row,
unsigned int    col
const [inline, inherited]
 

Get the element at row, col.

Note:
abort( ) may be called if row or col is not one of 0, 1, 2, or 3.

Definition at line 186 of file matrix.h.

References real_t.

void math::matrix4::set unsigned int    row,
unsigned int    col,
real_t    x
[inline, inherited]
 

Set the element at row, col to x.

Note:
abort( ) may be called if row or col is not one of 0, 1, 2, or 3.

Definition at line 176 of file matrix.h.

References real_t.

void math::matrix4::set real_t    d00,
real_t    d01,
real_t    d02,
real_t    d03,
real_t    d10,
real_t    d11,
real_t    d12,
real_t    d13,
real_t    d20,
real_t    d21,
real_t    d22,
real_t    d23,
real_t    d30,
real_t    d31,
real_t    d32,
real_t    d33
[inherited]
 

Sets the matrix.

Sets the matrix as follows:

Definition at line 134 of file matrix.cpp.

References math::matrix4::m_data, and real_t.

void math::matrix4::set real_t    d00,
real_t    d01,
real_t    d02,
real_t    d10,
real_t    d11,
real_t    d12,
real_t    d20,
real_t    d21,
real_t    d22
[inherited]
 

Sets rotation part of matrix.

Sets the matrix as follows:

Definition at line 106 of file matrix.cpp.

References math::matrix4::m_data, and real_t.

Referenced by math::quaternion::get_rotation_matrix, and math::quaternion::get_transposed_rotation_matrix.

void math::matrix4::set_identity   [inline, inherited]
 

Sets the matirx to the identity matrix.

Sets the matrix to:

Definition at line 255 of file matrix.h.

References math::matrix4::IDENTITY.

void math::matrix4::set_translation const math::vector3   trans [inline, inherited]
 

Sets the translation part of the matrix.

Sets the matrix as follows:

Note:
This method does not add to existing translations. This method sets the translation part of the matrix.
Parameters:
trans  A vector describing the new translation.

Definition at line 292 of file matrix.h.

References math::vector3::x, math::vector3::y, and math::vector3::z.

void math::matrix4::transpose void    [inherited]
 

Transposes the matrix.

Sets the matrix to .

Definition at line 221 of file matrix.cpp.

References math::matrix4::m_data, and math::swap.


Friends And Related Function Documentation

math::vector3 operator * const math::vector3   v,
const math::matrix4   m
[friend, inherited]
 

Vector Matrix Mulitplication.

Multiplies the vector v by the matrix m. The operation is defined as:

Definition at line 232 of file matrix.cpp.


Member Data Documentation

const math::matrix4 math::matrix4::IDENTITY [static, inherited]
 

The identity matrix.

The identity matrix is defined as:

Referenced by math::matrix4::get_inverted_rotation, and math::matrix4::set_identity.

const math::matrix4 math::matrix4::ZERO [static, inherited]
 

The zero matrix.

The zero matrix is defined as:


Generated on Tue Feb 11 18:49:47 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002