Antiprism 0.23
Public Member Functions | Static Public Member Functions

mat3d Class Reference

Matrix for transformations in 3D. More...

#include <mat3d.h>

List of all members.

Public Member Functions

 mat3d ()
 Constructor.
 mat3d (const vec3d &r1, const vec3d &r2, const vec3d &r3)
 Constructor.
 mat3d (const vec4d &r1, const vec4d &r2, const vec4d &r3, vec4d r4=vec4d(0, 0, 0, 1))
 Constructor.
mat3dset_cols (const vec3d &c1, const vec3d &c2, const vec3d &c3, const vec3d &c4=vec3d(0, 0, 0))
 Set the columns.
double operator[] (int idx) const
 Read access to the element array.
double & operator[] (int idx)
 Write access to the element array.
const double * get_m ()
 Read access to the start of the element array.
mat3doperator*= (const mat3d &mat)
 Multiply this matrix by another matrix.
mat3dtranspose ()
 Transpose the matrix.
mat3dset_inverse ()
 Set to the inverse of the matrix.
double det () const
 Determinant.
mat3dto_unit ()
 Set the matrix to the unit matrix.
mat3dto_zero ()
 Set the matrix to zero.
mat3dset_rot (double x_ang, double y_ang, double z_ang)
 Set a rotation by rotating around the coordinate axes.
mat3dset_rot (vec3d angles)
 Set a rotation by rotating around the coordinate axes.
mat3dset_rot (vec3d axis, double angle)
 Set a rotation by axis and angle.
mat3dset_rot (vec3d v_from, vec3d v_to)
 Set a rotation by rotating one direction vector onto another.
mat3dset_transl (vec3d trans)
 Set a translation.
mat3dset_refl (vec3d norm)
 Set a reflection.
mat3dset_scale (double scal)
 Set a uniform scaling.
mat3dset_scale (double x_scal, double y_scal, double z_scal)
 Set a scaling by components.
mat3dset_scale (vec3d dir, double scal)
 Set a scaling in a single direction.
mat3dset_inversion ()
 Set an inversion.
mat3dset_alignment (vec3d from1, vec3d from2, vec3d to1, vec3d to2)
 Set a transformation that aligns two pairs of vectors.
mat3dset_alignment (vec3d from1, vec3d from2, vec3d from3, vec3d to1, vec3d to2, vec3d to3)
 Set a transformation that aligns two sets of three points.
mat3dset_alignment (vector< vec3d > from, vector< vec3d > to)
 Set a transformation that aligns two sets of one, two or three points.
mat3dset_trans_by_angles (double yz_ang, double zx_ang, double xy_ang, bool *valid=0)
 Set a transformation that makes particular angles between mapped axes.
vec3d get_transl () const
 Get the translation vector.
vec4d get_quaternion () const
 Get quaternion.
vec3d get_euler () const
 Get Euler angles.
void dump (const char *var="", FILE *file=stderr) const
 Debugging print of a matrix.

Static Public Member Functions

static mat3d inverse (const mat3d &mat)
 Get the inverse of a matrix.
static mat3d unit ()
 Get a unit matrix.
static mat3d zero ()
 Get a zero matrix.
static mat3d rot (double x_ang, double y_ang, double z_ang)
 Get a rotation by rotating around the coordinate axes.
static mat3d rot (vec3d angles)
 Get a rotation by rotating around the coordinate axes.
static mat3d rot (vec3d axis, double angle)
 Get a rotation by axis and angle.
static mat3d rot (vec3d v_from, vec3d v_to)
 Get a rotation by rotating one direction vector onto another.
static mat3d transl (vec3d trans)
 Get a translation.
static mat3d refl (vec3d norm)
 Get a reflection.
static mat3d scale (double scal)
 Get a uniform scaling.
static mat3d scale (double x_scal, double y_scal, double z_scal)
 Get a scaling by components.
static mat3d scale (vec3d dir, double scal)
 Get a scaling in a single direction.
static mat3d inversion ()
 Get an inversion.
static mat3d alignment (vec3d from1, vec3d from2, vec3d to1, vec3d to2)
 Get a transformation that aligns two pairs of vectors.
static mat3d alignment (vec3d from1, vec3d from2, vec3d from3, vec3d to1, vec3d to2, vec3d to3)
 Get a transformation that aligns two sets of three points.
static mat3d alignment (vector< vec3d > from, vector< vec3d > to)
 Get a transformation that aligns two sets of one, two or three points.
static mat3d trans_by_angles (double yz_ang, double zx_ang, double xy_ang, bool *valid=0)
 Get a transformation that makes particular angles between mapped axes.

Detailed Description

Matrix for transformations in 3D.


Constructor & Destructor Documentation

mat3d::mat3d ( ) [inline]

Constructor.

Initialises to the identity.

mat3d::mat3d ( const vec3d r1,
const vec3d r2,
const vec3d r3 
) [inline]

Constructor.

Initialise the rows of the rotation part.

Parameters:
r1first row.
r2second row.
r3third row.
mat3d::mat3d ( const vec4d r1,
const vec4d r2,
const vec4d r3,
vec4d  r4 = vec4d(0,0,0,1) 
) [inline]

Constructor.

Initialise the rows.

Parameters:
r1first row.
r2second row.
r3third row.
r4fourth row.

Member Function Documentation

double mat3d::det ( ) const [inline]

Determinant.

Returns:
The determinant of the matrix.
void mat3d::dump ( const char *  var = "",
FILE *  file = stderr 
) const

Debugging print of a matrix.

Parameters:
vara string to identify the matrix variable.
filefile stream to print the variable.
vec3d mat3d::get_euler ( ) const

Get Euler angles.

Returns:
A vector representing rotations about the X, Y and Z axis, in that order.
const double* mat3d::get_m ( ) [inline]

Read access to the start of the element array.

Returns:
The start of the array.
vec4d mat3d::get_quaternion ( ) const

Get quaternion.

Convert the rotation part of the matrix into a quaterinon.

Returns:
A vector representing a quaternion (components X, Y, Z, and W.)
mat3d mat3d::inverse ( const mat3d mat) [inline, static]

Get the inverse of a matrix.

Parameters:
mata matrix to get the inverse of.
Returns:
The inverse of mat.
mat3d mat3d::inversion ( ) [inline, static]

Get an inversion.

Inversion through the origin.

Returns:
A matrix with the inversion set.
mat3d & mat3d::operator*= ( const mat3d mat)

Multiply this matrix by another matrix.

Parameters:
matthe matrix to multiply.
Returns:
A reference to the result, held in this matrix.
double mat3d::operator[] ( int  idx) const [inline]

Read access to the element array.

Parameters:
idxindex into the 16 element array.
Returns:
The element.
double& mat3d::operator[] ( int  idx) [inline]

Write access to the element array.

Parameters:
idxindex into the 16 element array.
Returns:
The element.
mat3d mat3d::refl ( vec3d  norm) [inline, static]

Get a reflection.

Reflect in a mirror plane passing through the origin.

Parameters:
norma normal to the mirror plane.
Returns:
A matrix with the reflection set.
mat3d mat3d::rot ( vec3d  angles) [inline, static]

Get a rotation by rotating around the coordinate axes.

Rotate around the x-axis, y-axis then z-axis.

Parameters:
anglesa vector whose components are the the angles in radians to rotate around he x-axis, y-axis and z-axis.
Returns:
A matrix with the resulting rotation set.
mat3d mat3d::rot ( vec3d  axis,
double  angle 
) [inline, static]

Get a rotation by axis and angle.

Rotate around an arbitrary axis through the origin.

Parameters:
axisthe axis o rotate around.
anglethe angle to rotate, in radians.
Returns:
A matrix with the resulting rotation set.
mat3d mat3d::rot ( vec3d  v_from,
vec3d  v_to 
) [inline, static]

Get a rotation by rotating one direction vector onto another.

Parameters:
v_fromthe direction vector to rotate.
v_tothe direction v_from should point after the rotation.
Returns:
A reference to this matrix with the resulting rotation set.
mat3d mat3d::rot ( double  x_ang,
double  y_ang,
double  z_ang 
) [inline, static]

Get a rotation by rotating around the coordinate axes.

Rotate around the x-axis, y-axis and then z-axis.

Parameters:
x_angangle in radians to rotate around x-axis.
y_angangle in radians to rotate around y-axis.
z_angangle in radians to rotate around z-axis.
Returns:
A matrix with the resulting rotation set.
mat3d mat3d::scale ( double  scal) [inline, static]

Get a uniform scaling.

Scale uniformly in all directions, away from the origin.

Parameters:
scalthe amount to scale.
Returns:
A matrix with the scaling set.
mat3d mat3d::scale ( double  x_scal,
double  y_scal,
double  z_scal 
) [inline, static]

Get a scaling by components.

Scale in the direction of the coordinate axes, away from the origin.

Parameters:
x_scalthe amount to scale in the direction of the x-axis.
y_scalthe amount to scale in the direction of the y-axis.
z_scalthe amount to scale in the direction of the z-axis.
Returns:
A reference to this matrix with the scaling set.
mat3d mat3d::scale ( vec3d  dir,
double  scal 
) [inline, static]

Get a scaling in a single direction.

Scale in a single arbitrary direction, away from the origin.

Parameters:
dirthe direction to scale.
scalthe amount to scale.
Returns:
A matrix with the scaling set.
mat3d & mat3d::set_cols ( const vec3d c1,
const vec3d c2,
const vec3d c3,
const vec3d c4 = vec3d(0,0,0) 
) [inline]

Set the columns.

Initialise the top three rows by columns

Parameters:
c1first column.
c2second column.
c3third column.
c4fourth column.
mat3d & mat3d::set_inverse ( )

Set to the inverse of the matrix.

Returns:
A reference to this matrix set to its inverse.
mat3d & mat3d::set_inversion ( ) [inline]

Set an inversion.

Inversion through the origin.

Returns:
A reference to this matrix with the inversion set.
mat3d & mat3d::set_refl ( vec3d  norm)

Set a reflection.

Reflect in a mirror plane passing through the origin.

Parameters:
norma normal to the mirror plane.
Returns:
A reference to this matrix with the reflection set.
mat3d & mat3d::set_rot ( double  x_ang,
double  y_ang,
double  z_ang 
) [inline]

Set a rotation by rotating around the coordinate axes.

Rotate around the x-axis, y-axis and then z-axis.

Parameters:
x_angangle in radians to rotate around x-axis.
y_angangle in radians to rotate around y-axis.
z_angangle in radians to rotate around z-axis.
Returns:
A reference to this matrix with the resulting rotation set.
mat3d & mat3d::set_rot ( vec3d  v_from,
vec3d  v_to 
)

Set a rotation by rotating one direction vector onto another.

Parameters:
v_fromthe direction vector to rotate.
v_tothe direction v_from should point after the rotation.
Returns:
A reference to this matrix with the resulting rotation set.
mat3d & mat3d::set_rot ( vec3d  axis,
double  angle 
)

Set a rotation by axis and angle.

Rotate around an arbitrary axis through the origin.

Parameters:
axisthe axis o rotate around.
anglethe angle to rotate, in radians.
Returns:
A reference to this matrix with the resulting rotation set.
mat3d & mat3d::set_rot ( vec3d  angles) [inline]

Set a rotation by rotating around the coordinate axes.

Rotate around the x-axis, y-axis then z-axis.

Parameters:
anglesa vector whose components are the the angles in radians to rotate around he x-axis, y-axis and z-axis.
Returns:
A reference to this matrix with the resulting rotation set.
mat3d & mat3d::set_scale ( vec3d  dir,
double  scal 
) [inline]

Set a scaling in a single direction.

Scale in a single arbitrary direction, away from the origin.

Parameters:
dirthe direction to scale.
scalthe amount to scale.
Returns:
A reference to this matrix with the scaling set.
mat3d & mat3d::set_scale ( double  x_scal,
double  y_scal,
double  z_scal 
) [inline]

Set a scaling by components.

Scale in the direction of the coordinate axes, away from the origin.

Parameters:
x_scalthe amount to scale in the direction of the x-axis.
y_scalthe amount to scale in the direction of the y-axis.
z_scalthe amount to scale in the direction of the z-axis.
Returns:
A reference to this matrix with the scaling set.
mat3d & mat3d::set_scale ( double  scal) [inline]

Set a uniform scaling.

Scale uniformly in all directions, away from the origin.

Parameters:
scalthe amount to scale.
Returns:
A reference to this matrix with the scaling set.
mat3d & mat3d::set_trans_by_angles ( double  yz_ang,
double  zx_ang,
double  xy_ang,
bool *  valid = 0 
)

Set a transformation that makes particular angles between mapped axes.

The x-axis is left unchanged. The y-axis is mapped to the y'-axis in the xy-plane. The z-axis is mapped to the z'-axis.

Parameters:
yz_angthe angle between the y'-axis and the z'axis.
zx_angthe angle between the z'-axis and the x-axis.
xy_angthe angle between the x-axis and the y'-axis.
validto return whether a transformation based on the angles is valid.
Returns:
A reference to this matrix with the transformation set.
mat3d & mat3d::set_transl ( vec3d  trans) [inline]

Set a translation.

Parameters:
transthe vector to translate by.
Returns:
A reference to this matrix with the translation set.
mat3d mat3d::trans_by_angles ( double  yz_ang,
double  zx_ang,
double  xy_ang,
bool *  valid = 0 
) [inline, static]

Get a transformation that makes particular angles between mapped axes.

The x-axis is left unchanged. The y-axis is mapped to the y'-axis in the xy-plane. The z-axis is mapped to the z'-axis.

Parameters:
zx_angthe angle between the z'-axis and the x-axis.
xy_angthe angle between the x-axis and the y'-axis.
yz_angthe angle between the y'-axis and the z'axis.
validto return whether a transformation based on the angles is valid.
Returns:
A matrix with the transformation set.
mat3d mat3d::transl ( vec3d  trans) [inline, static]

Get a translation.

Parameters:
transthe vector to translate by.
Returns:
A matrix with the translation set.

The documentation for this class was generated from the following files: