Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mlib::Mat4< M, P, V, L, Q > Class Template Reference

A 4x4 matrix class with double precision floating point elements.

Mat4 is a 4x4 matrix class that can be used to perform general affine or projective transformations in 3D space. More...

#include <mat4.H>

Inheritance diagram for mlib::Mat4< M, P, V, L, Q >:

Inheritance graph
[legend]
Collaboration diagram for mlib::Mat4< M, P, V, L, Q >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Constructors
 Mat4 ()
 Default constructor. Creates an identity matrix.
 Mat4 (Vec4 row0, Vec4 row1, Vec4 row2, Vec4 row3, bool perspec=false)
 Constructor that creates a matrix with rows equal to the vectors givens as arguments. Perspective can also be set.
 Mat4 (const P &origin, const V &x_dir, const V &y_dir, const V &z_dir)
 This constructor creates a rigid motion transform from an origin and directions of x, y and z axes.
 Mat4 (const V &col0, const V &col1, const V &col2)
 This constructor creates a linear map (no translation) whose columns are the given vectors.
 Mat4 (const P &origin, const V &xDir, const V &yDir)
 This constructor creates a rigid motion transform from an origin and direction of x and y axis. If yDir is not perpendicular to xDir, yDir will be adjusted.
 Mat4 (const L &axis)
 This constructor creates a rigid motion transform from an origin (axis.point) and the direction of the z axis (axis.vector). The directions of the x and y axes are determined according to an arbitrary axis algorithm.
 Mat4 (const P &origin)
 The constructor creates a rigid motion transform from an origin. The x, y and z axis are aligned with the world x, y and z axis.
Element Access Functions
Functions that allow you to get or set the elements of the matrix in various different ways.

double & operator() (int i1, int i2)
 Returns a reference to the cell (i1, i2) in the matrix. No bounds checking is performed in this function.
double operator() (int i1, int i2) const
 Returns the value in the cell (i1, i2) in the matrix. No bounds checking is performed in this function.
Vec4operator[] (int i)
 Returns a reference to row i as a Vec4. No bounds checking is performed in this function.
Vec4 operator[] (int i) const
 Returns the value of row i as a Vec4. No bounds checking is performed in this function.
get_scale () const
void get_coord_system (P &o, V &x, V &y, V &z) const
X () const
 Returns the x-axis of the coordinate system defined by the matrix as a vector.
Y () const
 Returns the y-axis of the coordinate system defined by the matrix as a vector.
Z () const
 Returns the z-axis of the coordinate system defined by the matrix as a vector.
origin () const
 Returns the origin of the coordinate system defined by the matrix as a point.
const double * matrix () const
 Returns the elements of the matrix as a 1D array (in row major layout).
void set_X (const V &x)
 Set the x-axis of the coordinate system defined by the matrix.
void set_Y (const V &y)
 Set the y-axis of the coordinate system defined by the matrix.
void set_Z (const V &z)
 Set the z-axis of the coordinate system defined by the matrix.
void set_origin (const P &o)
 Set the origin of the coordinate system defined by the matrix.
rotation () const
 Returns the rotation part of the transform.
Matrix Operations
transpose () const
 Return the transpose of the matrix.
double det () const
 Return the determinant of the matrix.
double trace () const
 Return the trace of the matrix.
adjoint () const
 Return the adjoint of the matrix.
unscaled () const
 Return a copy of the matrix with the axes of the coordinate system it defines normalized.
normalized_basis () const
 Returns a normalized basis version of the matrix.
orthogonalized () const
 Returns a orthogonalized version of the matrix.
inverse (bool debug=false) const
 Returns the inverse of the matrix.
double inverse (Mat4< M, P, V, L, Q > &inv) const
 Matrix inversion code for 4x4 matrices using Gaussian elimination with partial pivoting. This is a specialized version of a procedure originally due to Paul Heckbert <ph@cs.cmu.edu>.
derivative (const P &p) const
 Returns the derivative of the matrix at point p.
Matrix Property Queries
Functions that check various properties of the matrix.

void set_perspective (bool p)
 Set whether this matrix represents a perspective transform or not.
bool is_perspective () const
 Does this matrix represent a perspective transform?
bool is_valid () const
 Is the matrix valid?
bool is_identity () const
 Is the matrix equal to the identity matrix?
bool is_orthogonal () const
 Is the matrix orthogonal (no shearing)?
bool is_equal_scaling_orthogonal () const
 Is the matrix equal_scaling orthogonal (no shearing, no nonequal scaling)?
bool is_orthonormal () const
 Is the matrix orthonormal (orthogonal, no scaling)?
Overloaded Operators
Overloaded mathematical and logical operators.

int operator== (const M &m) const
 Overloaded equality operator. Only checks to see if top 3 rows are equal.

Static Public Member Functions

Special Transform Constructors
Static functions to create matrices that perform special transformations.

static M rotation (const Q &quat)
 Create a matrix that does the rotation described by the quaternion quat.
static M rotation (const L &axis, double angle)
 Create a matrix that rotates angle radians about the axis described by line axis.
static M rotation (const V &axis, double angle)
 Create a matrix that rotates angle radians about the axis described by vector axis.
static M shear (const V &normal, const V &shear_vec)
 Create a matrix that performs a shearing transform.
static M scaling (const P &fixed_pt, double factor)
 Create a matrix that does a uniform scale by factor along the x-, y- and z-directions, centered at the point fixed_pt.
static M scaling (const P &fixed_pt, const V &xyz_factors)
 Create a matrix that scales along x-, y- and z-axes by the amount in the corresponding component of xyz_factors and that leaves the point fixed_pt unmoved.
static M scaling (const V &xyz_factors)
 Create a matrix that scales along the x-, y- and z-axes by the amount in the corresponding component of xyz_factors.
static M scaling (double x, double y, double z)
 Create a matrix that scales by x along the x-axis, y along the y-axis and z along the z-axis.
static M scaling (double factor)
 Create a matrix that does a uniform scale by factor.
static M stretching (const L &axis)
 Create a matrix that scales along the direction of axis.vector leaving point axis.point unmoved.
static M translation (const V &vec)
 Create a matrix that does a translation along the vector vec.
static M anchor_scale_rot (const P &anchor, const P &old_pt, const P &new_pt)
 Contruct a rotation / non-uniform scale matrix that maps the line segment joining anchor and old_pt to the segment joining anchor and new-pt.
static M align (const P &src1, const P &src2, const P &src3, const P &dst1, const P &dst2, const P &dst3)
 Map a triple of points (src1,src2,src3) to a triple of points (dst1,dst2,dst3). Point src1 maps to dst1, line (src1,src2) maps to line (dst1,dst2) and plane (src1,src2,src3) maps to plane (dst1,dst2,dst3).
static M align (const P &src1, const V &src2, const V &src3, const P &dst1, const V &dst2, const V &dst3)
static M align (const P &src1, const V &src2, const P &dst1, const V &dst2)
static M align_and_scale (const P &o, const V &x, const V &y, const V &z)
static M glu_perspective (double fovy, double aspect, double zmin=0.0, double zmax=0.0)
 Creates a matrix that performs a perspective transformation exactly like gluPerspective.
static M glu_lookat (const V &from, const V &at, const V &up)
 Creates a matrix that performs a transformation exactly like gluLookAt.
static M gl_viewport (double w, double h)
 Creates a matrix that performs the OpenGL viewport transformation.

Protected Attributes

Vec4 row [4]
 Rows of the matrix stored as 4D vectors.
bool perspective
 Is this matrix a perspective transform?

Related Functions

(Note that these are not member functions.)

operator * (const Mat4< M, P, V, L, Q > &m, const Mat4< M, P, V, L, Q > &m2)
 Mat4 by Mat4 multiplication.
operator * (const Mat4< M, P, V, L, Q > &m, const P &p)
 Mat4 by 3D point multiplication.
operator * (const Mat4< M, P, V, L, Q > &m, const Vec3< V > &v)
 Mat4 by 3D vector multiplication.
operator * (const Mat4< M, P, V, L, Q > &m, const Line< L, P, V > &l)
 Mat4 by 3D line multiplication.
operator+ (const Mat4< M, P, V, L, Q > &n, const Mat4< M, P, V, L, Q > &m)
 Component wise matrix addition.
operator- (const Mat4< M, P, V, L, Q > &n, const Mat4< M, P, V, L, Q > &m)
 Component wise matrix subtraction.
operator- (const Mat4< M, P, V, L, Q > &n)
 Component wise matrix negation.
operator * (double s, const Mat4< M, P, V, L, Q > &m)
 Scalar by matrix multiplication.
operator * (const Mat4< M, P, V, L, Q > &m, double s)
 Matrix by scalar multiplication.
operator/ (const Mat4< M, P, V, L, Q > &m, double s)
 Matrix by scalara division.
std::ostream & operator<< (std::ostream &os, const Mat4< M, P, V, L, Q > &x)
 Stream insertion operator for Mat4 class.

Detailed Description

template<typename M, typename P, typename V, typename L, typename Q>
class mlib::Mat4< M, P, V, L, Q >

A 4x4 matrix class with double precision floating point elements.

Mat4 is a 4x4 matrix class that can be used to perform general affine or projective transformations in 3D space.

To transform a point or a vector, PREmultiply it by a Mat4 instance.

libgfx References:
Mat4 uses some code from the Mat4 class in libgfx.
Todo:
Add eigenvector and eigenvalue finding functions.

Definition at line 30 of file mat4.H.


Constructor & Destructor Documentation

template<typename M, typename P, typename V, typename L, typename Q>
mlib::Mat4< M, P, V, L, Q >::Mat4  )  [inline]
 

Default constructor. Creates an identity matrix.

Definition at line 43 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
mlib::Mat4< M, P, V, L, Q >::Mat4 Vec4  row0,
Vec4  row1,
Vec4  row2,
Vec4  row3,
bool  perspec = false
[inline]
 

Constructor that creates a matrix with rows equal to the vectors givens as arguments. Perspective can also be set.

Definition at line 52 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE mlib::Mat4< M, P, V, L, Q >::Mat4 const P &  origin,
const V &  x_dir,
const V &  y_dir,
const V &  z_dir
 

This constructor creates a rigid motion transform from an origin and directions of x, y and z axes.

Construct a rigid motion transformation from given coordinate system (origin,x_dir,y_dir,z_dir). This transformation will transform points from (origin,x_dir,y_dir,z_dir) to world.

Parameters:
[in] origin The origin of the coordinate system that will be defined by the new matrix.
[in] x_dir The direction of the x-axis of the coordinate system that will be defined by the new matrix.
[in] y_dir The direction of the y-axis of the coordinate system that will be defined by the new matrix.
[in] z_dir The direction of the z-axis of the coordinate system that will be defined by the new matrix.
Todo:
Change use of temp matrix to direct access to the this pointer.

Definition at line 31 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE mlib::Mat4< M, P, V, L, Q >::Mat4 const V &  col0,
const V &  col1,
const V &  col2
 

This constructor creates a linear map (no translation) whose columns are the given vectors.

Construct a matrix whose columns are the given vectors.

Parameters:
[in] col0 Becomes the first 3 rows of the first column of the matrix.
[in] col1 Becomes the first 3 rows of the second column of the matrix.
[in] col2 Becomes the first 3 rows of the third column of the matrix.
Todo:
Change use of temp matrix to direct access to the this pointer.

Definition at line 72 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE mlib::Mat4< M, P, V, L, Q >::Mat4 const P &  origin,
const V &  x_dir,
const V &  y_dir
 

This constructor creates a rigid motion transform from an origin and direction of x and y axis. If yDir is not perpendicular to xDir, yDir will be adjusted.

Construct a rigid motion transformation from the coordinate system (origin,x_dir,y_dir,cross(x_dir,y_dir)). This transformation will transform points from (origin,x_dir,y_dir,cross(x_dir,y_dir)) to world.

Parameters:
[in] origin The origin of the coordinate system that will be defined by the new matrix.
[in] x_dir The direction of the x-axis of the coordinate system that will be defined by the new matrix.
[in] y_dir The direction of the y-axis of the coordinate system that will be defined by the new matrix.
Note:
y_dir is recomputed to be cross(cross(x_dir,y_dir), x_dir).

If the result of cross(x_dir,y_dir) is a null vector, then the constructed matrix will be the identity matrix.

Todo:
Change use of temp matrix to direct access to the this pointer.

Definition at line 109 of file mat4.C.

References mlib::cross(), and mlib::Vec4::normalized().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE mlib::Mat4< M, P, V, L, Q >::Mat4 const L &  axis  ) 
 

This constructor creates a rigid motion transform from an origin (axis.point) and the direction of the z axis (axis.vector). The directions of the x and y axes are determined according to an arbitrary axis algorithm.

Construct a transform that moves origin to axis.point and z-axis to axis.vector. The x and y axes are constructed according to an arbitrary axis algorithm.

Parameters:
[in] axis A line specifying the origin and z-axis of the coordinate system that will be defined by the new matrix.

Definition at line 139 of file mat4.C.

References mlib::cross().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE mlib::Mat4< M, P, V, L, Q >::Mat4 const P &  origin  ) 
 

The constructor creates a rigid motion transform from an origin. The x, y and z axis are aligned with the world x, y and z axis.

Parameters:
[in] origin The origin of the rigid motion transform.

Definition at line 162 of file mat4.C.


Member Function Documentation

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::adjoint  )  const
 

Return the adjoint of the matrix.

libgfx References:
This function was taken directly from libgfx (it was only modified to make it into a member function).

Definition at line 851 of file mat4.C.

References mlib::cross(), and mlib::Mat4< M, P, V, L, Q >::row.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::align const P &  src1,
const V &  src2,
const P &  dst1,
const V &  dst2
[static]
 

As align(src1, src2, src3, dst1, dst2, dst3), but src3 and dst3 are equal and computed to be cross(src2, dst2). If cross(src2, dst2) is the null vector, then src3 and dst3 are perpendicular to src2 (computed using an arbitrary axis algorithm) is src2 and dst2 point away from each other. Otherwise, a translation matrix from sr1 to dst1 is returned.

Definition at line 874 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::align(), mlib::cross(), and mlib::Mat4< M, P, V, L, Q >::translation().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::align const P &  src1,
const V &  src2,
const V &  src3,
const P &  dst1,
const V &  dst2,
const V &  dst3
[static]
 

The transformation maps points and vectors as follows:

point src1 --> point dst1 vec src2 --> vector dst2 plane(src1,src2,src3) --> plane(dst1,dst2,dst3)

Definition at line 909 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::align const P &  src1,
const P &  src2,
const P &  src3,
const P &  dst1,
const P &  dst2,
const P &  dst3
[static]
 

Map a triple of points (src1,src2,src3) to a triple of points (dst1,dst2,dst3). Point src1 maps to dst1, line (src1,src2) maps to line (dst1,dst2) and plane (src1,src2,src3) maps to plane (dst1,dst2,dst3).

The transformation maps points as follows:

point src1 maps to point dst1 vec (src1,src2) maps to vector (dst1,dst2) plane (src1,src2,src3) maps to plane (dst1,dst2,dst3)

Definition at line 942 of file mat4.C.

Referenced by mlib::Mat4< M, P, V, L, Q >::align().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::align_and_scale const P &  origin,
const V &  xx,
const V &  yy,
const V &  zz
[static]
 

Construct a rigid motion transformation from given coordinate system (origin,xx,yy,zz). This transformation will transform points from (origin,xx,yy,zz) to world. The axes xx, yy, and zz are not normalized before the matrix is constructed.

Definition at line 964 of file mat4.C.

Referenced by mlib::Mat4< M, P, V, L, Q >::orthogonalized().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::anchor_scale_rot const P &  anchor,
const P &  old_pt,
const P &  new_pt
[static]
 

Contruct a rotation / non-uniform scale matrix that maps the line segment joining anchor and old_pt to the segment joining anchor and new-pt.

Contruct a rotation / non-uniform scale matrix that maps the line segment joining anchor -- old_pt to the segment joining anchor -- new_pt:

new point / / / / / / / anchor ------------------- old point

Definition at line 406 of file mat4.C.

References mlib::Acos(), mlib::cross(), err_msg(), mlib::gEpsAbsMath, and mlib::Vec4::normalized().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::derivative const P &  p  )  const
 

Returns the derivative of the matrix at point p.

Returns the derivative of the map "mult by this matrix". Of course, this is only interesting for perspective matrices, since otherwise the derivative is the matrix itself. (We can ignore the translational component of the matrix since the derivative should only be multiplied with vectors, and the translational component doesn't affect them).

Parameters:
[in] p The point at which the derivative is computed.
Note:
The derivative is only computed for matrices with perspective set to true.

Definition at line 659 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::perspective.

template<typename M, typename P, typename V, typename L, typename Q>
double mlib::Mat4< M, P, V, L, Q >::det  )  const [inline]
 

Return the determinant of the matrix.

libgfx References:
This function was take directly from libgfx (it was only modified to make it into a member function).

Definition at line 234 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::inverse().

template<typename M, typename P, typename V, typename L, typename Q>
void mlib::Mat4< M, P, V, L, Q >::get_coord_system P &  o,
V &  x,
V &  y,
V &  z
const [inline]
 

Returns by reference the origin and axes of the coordinate system defined by the matrix.

Definition at line 107 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::is_orthogonal(), mlib::Mat4< M, P, V, L, Q >::normalized_basis(), mlib::Mat4< M, P, V, L, Q >::orthogonalized(), XFscaler< OBJ_TYPE, OBJ_TYPE_PTR >::tick(), and mlib::Mat4< M, P, V, L, Q >::unscaled().

template<typename M, typename P, typename V, typename L, typename Q>
V mlib::Mat4< M, P, V, L, Q >::get_scale  )  const [inline]
 

Returns a vector containing the lengths of the axes of the coordinate system defined by the matrix.

Definition at line 102 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::is_equal_scaling_orthogonal(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::is_orthonormal().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::gl_viewport double  w,
double  h
[static]
 

Creates a matrix that performs the OpenGL viewport transformation.

libgfx References:
This function was take directly from libgfx (it was only modified to make it into a static member function).

Definition at line 1053 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::scaling(), and mlib::Mat4< M, P, V, L, Q >::translation().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::glu_lookat const V &  from,
const V &  at,
const V &  v_up
[static]
 

Creates a matrix that performs a transformation exactly like gluLookAt.

libgfx References:
This function was take directly from libgfx (it was only modified to make it into a static member function).

Definition at line 1031 of file mat4.C.

References mlib::cross(), mlib::Vec4::normalized(), and mlib::Mat4< M, P, V, L, Q >::translation().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::glu_perspective double  fovy,
double  aspect,
double  zmin = 0.0,
double  zmax = 0.0
[static]
 

Creates a matrix that performs a perspective transformation exactly like gluPerspective.

libgfx References:
This function was take directly from libgfx (it was only modified to make it into a static member function).

Definition at line 997 of file mat4.C.

References Color::tan().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE double mlib::Mat4< M, P, V, L, Q >::inverse Mat4< M, P, V, L, Q > &  inv  )  const
 

Matrix inversion code for 4x4 matrices using Gaussian elimination with partial pivoting. This is a specialized version of a procedure originally due to Paul Heckbert <ph@cs.cmu.edu>.

If the matrix is singular, returns 0 and leaves trash in inv.

Parameters:
[out] inv The result of inverting the matrix. If the matrix is singular, the value of inv is undefined.
Returns:
Determinant of the matrix. If the matrix is singular, the determinant will be 0 (or very close to 0).
libgfx References:
This function was taken directly from libgfx.

Definition at line 581 of file mat4.C.

References j, and mlib::Mat4< M, P, V, L, Q >::perspective.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::inverse bool  debug = false  )  const
 

Returns the inverse of the matrix.

Convenience version of inverse that returns the inverse rather than passing it back by reference. This version also prints an error message if a singular matrix is detected (in which case the returned matrix is undefined).

Returns:
The inverse of the matrix.

Definition at line 545 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::det(), mlib::fn_gdb_will_recognize_so_i_can_set_a_fuggin_breakpoint(), and mlib::isZero().

Referenced by VIEW::eye_to_world(), GESTURE::is_ellipse(), SimplexFrame::recompute(), HalftoneShaderEx::set_uniform_variables(), and DotsShader_EX::set_uniform_variables().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE bool mlib::Mat4< M, P, V, L, Q >::is_equal_scaling_orthogonal  )  const
 

Is the matrix equal_scaling orthogonal (no shearing, no nonequal scaling)?

Definition at line 816 of file mat4.C.

References mlib::epsNorMath(), mlib::Mat4< M, P, V, L, Q >::get_scale(), and mlib::Mat4< M, P, V, L, Q >::is_orthogonal().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE bool mlib::Mat4< M, P, V, L, Q >::is_identity  )  const
 

Is the matrix equal to the identity matrix?

Definition at line 786 of file mat4.C.

References mlib::gEpsAbsMath, and mlib::Mat4< M, P, V, L, Q >::row.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE bool mlib::Mat4< M, P, V, L, Q >::is_orthogonal  )  const
 

Is the matrix orthogonal (no shearing)?

Definition at line 801 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::get_coord_system(), and mlib::Mat4< M, P, V, L, Q >::origin().

Referenced by mlib::Mat4< M, P, V, L, Q >::is_equal_scaling_orthogonal(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::is_orthonormal().

template<typename M, typename P, typename V, typename L, typename Q>
bool mlib::Mat4< M, P, V, L, Q >::is_orthonormal  )  const [inline]
 

Is the matrix orthonormal (orthogonal, no scaling)?

Definition at line 279 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
bool mlib::Mat4< M, P, V, L, Q >::is_perspective  )  const [inline]
 

Does this matrix represent a perspective transform?

Definition at line 267 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::operator *(), mlib::operator *(), mlib::Mat4< M, P, V, L, Q >::operator+(), mlib::Mat4< M, P, V, L, Q >::operator-(), and mlib::Mat4< M, P, V, L, Q >::operator/().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE bool mlib::Mat4< M, P, V, L, Q >::is_valid  )  const
 

Is the matrix valid?

Definition at line 1061 of file mat4.C.

References mlib::epsNorMath(), and mlib::Mat4< M, P, V, L, Q >::row.

template<typename M, typename P, typename V, typename L, typename Q>
const double* mlib::Mat4< M, P, V, L, Q >::matrix  )  const [inline]
 

Returns the elements of the matrix as a 1D array (in row major layout).

libgfx References:
This function is borrowed from the libgfx Mat4 class.

Definition at line 127 of file mat4.H.

Referenced by XF_DRAW::draw(), TexMemRefImage::draw_objects(), VisRefImage::draw_objects(), IDRefImage::draw_objects(), RefImage::draw_objects(), and XToonTexture::update_cam().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::normalized_basis  )  const
 

Returns a normalized basis version of the matrix.

Return a copy of the matrix with the axes of the coordinate system it defines normalized and the origin of that coordinate system replaced with the origin of the world coordinate system, (0, 0, 0).

Definition at line 702 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::get_coord_system().

template<typename M, typename P, typename V, typename L, typename Q>
double mlib::Mat4< M, P, V, L, Q >::operator() int  i1,
int  i2
const [inline]
 

Returns the value in the cell (i1, i2) in the matrix. No bounds checking is performed in this function.

Definition at line 91 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
double& mlib::Mat4< M, P, V, L, Q >::operator() int  i1,
int  i2
[inline]
 

Returns a reference to the cell (i1, i2) in the matrix. No bounds checking is performed in this function.

Definition at line 88 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
int mlib::Mat4< M, P, V, L, Q >::operator== const M &  m  )  const [inline]
 

Overloaded equality operator. Only checks to see if top 3 rows are equal.

Definition at line 290 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
Vec4 mlib::Mat4< M, P, V, L, Q >::operator[] int  i  )  const [inline]
 

Returns the value of row i as a Vec4. No bounds checking is performed in this function.

Definition at line 98 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
Vec4& mlib::Mat4< M, P, V, L, Q >::operator[] int  i  )  [inline]
 

Returns a reference to row i as a Vec4. No bounds checking is performed in this function.

Definition at line 95 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
P mlib::Mat4< M, P, V, L, Q >::origin  )  const [inline]
 

Returns the origin of the coordinate system defined by the matrix as a point.

Definition at line 121 of file mat4.H.

Referenced by XF_DRAW::draw(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_coord_system(), mlib::Mat4< M, P, V, L, Q >::is_orthogonal(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::operator==().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::orthogonalized  )  const
 

Returns a orthogonalized version of the matrix.

Creates a new matrix that defines a coordinate system with the same origin as the coordinate system defined by the original matrix, but x-axis normalized, the y-axis redefined to be perpendicular to the x-axis (and also unit length), and the z-axis redefined to be perpendicular to both (but the same length as before).

Todo:
Come up with a better description of this function.

Definition at line 724 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::align_and_scale(), mlib::cross(), mlib::Mat4< M, P, V, L, Q >::get_coord_system(), mlib::Vec4::length(), and mlib::Vec4::normalized().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::rotation const V &  axis,
double  angle
[static]
 

Create a matrix that rotates angle radians about the axis described by vector axis.

Parameters:
[in] axis A vector describing the axis to rotate about.
[in] angle The angle to rotate through (in radians).

Definition at line 203 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::rotation().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::rotation const L &  axis,
double  angle
[static]
 

Create a matrix that rotates angle radians about the axis described by line axis.

Parameters:
[in] axis A line describing the axis to rotate about.
[in] angle The angle to rotate through (in radians).

Definition at line 216 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::rotation const Q &  quat  )  [static]
 

Create a matrix that does the rotation described by the quaternion quat.

Parameters:
[in] quat A quaternion describing the rotation.

Definition at line 255 of file mat4.C.

References mlib::Acos(), angle(), and mlib::Mat4< M, P, V, L, Q >::rotation().

template<typename M, typename P, typename V, typename L, typename Q>
M mlib::Mat4< M, P, V, L, Q >::rotation  )  const [inline]
 

Returns the rotation part of the transform.

Definition at line 143 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::rotation().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::scaling double  factor  )  [static]
 

Create a matrix that does a uniform scale by factor.

Parameters:
[in] factor The amount to scale by along the x-, y- and z-axes.

Definition at line 282 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::scaling().

template<typename M, typename P, typename V, typename L, typename Q>
static M mlib::Mat4< M, P, V, L, Q >::scaling double  x,
double  y,
double  z
[inline, static]
 

Create a matrix that scales by x along the x-axis, y along the y-axis and z along the z-axis.

Definition at line 177 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::scaling const V &  xyz_factors  )  [static]
 

Create a matrix that scales along the x-, y- and z-axes by the amount in the corresponding component of xyz_factors.

Parameters:
[in] xyz_factors A vector whose components are the amount to scale by along their corresponding directions.

Definition at line 296 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::scaling().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::scaling const P &  fixed_pt,
const V &  xyz_factors
[static]
 

Create a matrix that scales along x-, y- and z-axes by the amount in the corresponding component of xyz_factors and that leaves the point fixed_pt unmoved.

Parameters:
[in] fixed_pt The point that should remain fixed after the scaling.
[in] xyz_factors A vector whose components are the amount to scale by along their corresponding directions.

Definition at line 310 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::scaling const P &  fixed_pt,
double  factor
[static]
 

Create a matrix that does a uniform scale by factor along the x-, y- and z-directions, centered at the point fixed_pt.

Parameters:
[in] fixed_pt The point that should remain fixed after the scaling.
[in] factor The amount to scale by in the x-, y- and z-directions.

Definition at line 270 of file mat4.C.

Referenced by mlib::Mat4< M, P, V, L, Q >::gl_viewport(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::scaling(), mlib::Mat4< M, P, V, L, Q >::scaling(), and mlib::Mat4< M, P, V, L, Q >::stretching().

template<typename M, typename P, typename V, typename L, typename Q>
void mlib::Mat4< M, P, V, L, Q >::set_origin const P &  o  )  [inline]
 

Set the origin of the coordinate system defined by the matrix.

Definition at line 139 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
void mlib::Mat4< M, P, V, L, Q >::set_perspective bool  p  )  [inline]
 

Set whether this matrix represents a perspective transform or not.

Definition at line 265 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
void mlib::Mat4< M, P, V, L, Q >::set_X const V &  x  )  [inline]
 

Set the x-axis of the coordinate system defined by the matrix.

Definition at line 130 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
void mlib::Mat4< M, P, V, L, Q >::set_Y const V &  y  )  [inline]
 

Set the y-axis of the coordinate system defined by the matrix.

Definition at line 133 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
void mlib::Mat4< M, P, V, L, Q >::set_Z const V &  z  )  [inline]
 

Set the z-axis of the coordinate system defined by the matrix.

Definition at line 136 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::shear const V &  normal,
const V &  shear_vec
[static]
 

Create a matrix that performs a shearing transform.

Parameters:
[in] normal Some sort of normal vector. Not sure exactly what this is (perhaps the normal vector to the plane that will be sheared?).
[in] shear_vec A vector describing the shear. Not sure exactly how this is interpreted.
Todo:
Document this function more completely.
Questions:
What are the exact meanings of the parameters?

Definition at line 339 of file mat4.C.

References mlib::epsAbsSqrdMath(), and j.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::stretching const L &  axis  )  [static]
 

Create a matrix that scales along the direction of axis.vector leaving point axis.point unmoved.

Parameters:
[in] axis A line describing the direction to stretch along and the amount to stretch as well as the point that should remain fixed after the stretching.

Definition at line 371 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::scaling().

template<typename M, typename P, typename V, typename L, typename Q>
double mlib::Mat4< M, P, V, L, Q >::trace  )  const [inline]
 

Return the trace of the matrix.

libgfx References:
This function was take directly from libgfx (it was only modified to make it into a member function).

Definition at line 239 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::translation const V &  vec  )  [static]
 

Create a matrix that does a translation along the vector vec.

Parameters:
[in] vec A vector describing the length and direction of the translation.

Definition at line 182 of file mat4.C.

Referenced by mlib::Mat4< M, P, V, L, Q >::align(), mlib::Mat4< M, P, V, L, Q >::gl_viewport(), and mlib::Mat4< M, P, V, L, Q >::glu_lookat().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::transpose  )  const
 

Return the transpose of the matrix.

Definition at line 832 of file mat4.C.

References j, and mlib::Mat4< M, P, V, L, Q >::row.

Referenced by XF_DRAW::draw(), get_quat(), and XToonTexture::update_cam().

template<typename M, typename P, typename V, typename L, typename Q>
MLIB_INLINE M mlib::Mat4< M, P, V, L, Q >::unscaled  )  const
 

Return a copy of the matrix with the axes of the coordinate system it defines normalized.

Definition at line 684 of file mat4.C.

References mlib::Mat4< M, P, V, L, Q >::get_coord_system().

template<typename M, typename P, typename V, typename L, typename Q>
V mlib::Mat4< M, P, V, L, Q >::X  )  const [inline]
 

Returns the x-axis of the coordinate system defined by the matrix as a vector.

Definition at line 112 of file mat4.H.

Referenced by mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_coord_system(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_scale(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::operator==(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::rotation().

template<typename M, typename P, typename V, typename L, typename Q>
V mlib::Mat4< M, P, V, L, Q >::Y  )  const [inline]
 

Returns the y-axis of the coordinate system defined by the matrix as a vector.

Definition at line 115 of file mat4.H.

Referenced by mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_coord_system(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_scale(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::operator==(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::rotation().

template<typename M, typename P, typename V, typename L, typename Q>
V mlib::Mat4< M, P, V, L, Q >::Z  )  const [inline]
 

Returns the z-axis of the coordinate system defined by the matrix as a vector.

Definition at line 118 of file mat4.H.

Referenced by mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_coord_system(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::get_scale(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::operator==(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::rotation().


Friends And Related Function Documentation

template<typename M, typename P, typename V, typename L, typename Q>
M operator * const Mat4< M, P, V, L, Q > &  m,
double  s
[related]
 

Matrix by scalar multiplication.

Definition at line 351 of file mat4.H.

template<typename M, typename P, typename V, typename L, typename Q>
M operator * double  s,
const Mat4< M, P, V, L, Q > &  m
[related]
 

Scalar by matrix multiplication.

Definition at line 345 of file mat4.H.

References mlib::Mat4< M, P, V, L, Q >::is_perspective().

template<typename M, typename P, typename V, typename L, typename Q>
L operator * const Mat4< M, P, V, L, Q > &  m,
const Line< L, P, V > &  l
[related]
 

Mat4 by 3D line multiplication.

Definition at line 777 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
V operator * const Mat4< M, P, V, L, Q > &  m,
const Vec3< V > &  v
[related]
 

Mat4 by 3D vector multiplication.

Definition at line 767 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
P operator * const Mat4< M, P, V, L, Q > &  m,
const P &  p
[related]
 

Mat4 by 3D point multiplication.

Definition at line 741 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
M operator * const Mat4< M, P, V, L, Q > &  m,
const Mat4< M, P, V, L, Q > &  m2
[related]
 

Mat4 by Mat4 multiplication.

Definition at line 444 of file mat4.C.

template<typename M, typename P, typename V, typename L, typename Q>
M operator+ const Mat4< M, P, V, L, Q > &  n,
const Mat4< M, P, V, L, Q > &  m
[related]
 

Component wise matrix addition.

Definition at line 325 of file mat4.H.

References mlib::Mat4< M, P, V, L, Q >::is_perspective().

template<typename M, typename P, typename V, typename L, typename Q>
M operator- const Mat4< M, P, V, L, Q > &  n  )  [related]
 

Component wise matrix negation.

Definition at line 339 of file mat4.H.

References mlib::Mat4< M, P, V, L, Q >::is_perspective().

template<typename M, typename P, typename V, typename L, typename Q>
M operator- const Mat4< M, P, V, L, Q > &  n,
const Mat4< M, P, V, L, Q > &  m
[related]
 

Component wise matrix subtraction.

Definition at line 332 of file mat4.H.

References mlib::Mat4< M, P, V, L, Q >::is_perspective().

template<typename M, typename P, typename V, typename L, typename Q>
M operator/ const Mat4< M, P, V, L, Q > &  m,
double  s
[related]
 

Matrix by scalara division.

Definition at line 357 of file mat4.H.

References mlib::Mat4< M, P, V, L, Q >::is_perspective().

template<typename M, typename P, typename V, typename L, typename Q>
std::ostream & operator<< std::ostream &  os,
const Mat4< M, P, V, L, Q > &  x
[related]
 

Stream insertion operator for Mat4 class.


Member Data Documentation

template<typename M, typename P, typename V, typename L, typename Q>
bool mlib::Mat4< M, P, V, L, Q >::perspective [protected]
 

Is this matrix a perspective transform?

Definition at line 35 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::derivative(), mlib::Mat4< M, P, V, L, Q >::inverse(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::is_perspective(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::set_perspective().

template<typename M, typename P, typename V, typename L, typename Q>
Vec4 mlib::Mat4< M, P, V, L, Q >::row[4] [protected]
 

Rows of the matrix stored as 4D vectors.

Definition at line 34 of file mat4.H.

Referenced by mlib::Mat4< M, P, V, L, Q >::adjoint(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::det(), mlib::Mat4< M, P, V, L, Q >::is_identity(), mlib::Mat4< M, P, V, L, Q >::is_valid(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::Mat4(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::matrix(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::operator()(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::operator[](), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::origin(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::set_origin(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::set_X(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::set_Y(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::set_Z(), mlib::Mat4< M, P, V, L, Q >::transpose(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::X(), mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::Y(), and mlib::Mat4< Wtransf, Wpt, Wvec, Wline, Wquat >::Z().


The documentation for this class was generated from the following files:
Generated on Mon Sep 18 11:48:10 2006 for jot by  doxygen 1.4.4