Antiprism 0.23

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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.
mat3d & | set_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.
mat3d & | operator*= (const mat3d &mat)
| Multiply this matrix by another matrix.
mat3d & | transpose ()
| Transpose the matrix.
mat3d & | set_inverse ()
| Set to the inverse of the matrix.
double | det () const
| Determinant.
mat3d & | to_unit ()
| Set the matrix to the unit matrix.
mat3d & | to_zero ()
| Set the matrix to zero.
mat3d & | set_rot (double x_ang, double y_ang, double z_ang)
| Set a rotation by rotating around the coordinate axes.
mat3d & | set_rot (vec3d angles)
| Set a rotation by rotating around the coordinate axes.
mat3d & | set_rot (vec3d axis, double angle)
| Set a rotation by axis and angle.
mat3d & | set_rot (vec3d v_from, vec3d v_to)
| Set a rotation by rotating one direction vector onto another.
mat3d & | set_transl (vec3d trans)
| Set a translation.
mat3d & | set_refl (vec3d norm)
| Set a reflection.
mat3d & | set_scale (double scal)
| Set a uniform scaling.
mat3d & | set_scale (double x_scal, double y_scal, double z_scal)
| Set a scaling by components.
mat3d & | set_scale (vec3d dir, double scal)
| Set a scaling in a single direction.
mat3d & | set_inversion ()
| Set an inversion.
mat3d & | set_alignment (vec3d from1, vec3d from2, vec3d to1, vec3d to2)
| Set a transformation that aligns two pairs of vectors.
mat3d & | set_alignment (vec3d from1, vec3d from2, vec3d from3, vec3d to1, vec3d to2, vec3d to3)
| Set a transformation that aligns two sets of three points.
mat3d & | set_alignment (vector< vec3d > from, vector< vec3d > to)
| Set a transformation that aligns two sets of one, two or three points.
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.
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:

  r1 | first row.
  r2 | second row.
  r3 | third 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:

  r1 | first row.
  r2 | second row.
  r3 | third row.
  r4 | fourth 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:

  var | a string to identify the matrix variable.
  file | file 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:

  mat | a 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:

  mat | the 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:

  idx | index into the 16 element array.

Returns:
  The element.

double& mat3d::operator[] | ( | int | idx | ) | `[inline]`

Write access to the element array.

Parameters:

  idx | index 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:

  norm | a 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:

  angles | a 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:

  axis | the axis o rotate around.
  angle | the 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_from | the direction vector to rotate.
  v_to | the 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_ang | angle in radians to rotate around x-axis.
  y_ang | angle in radians to rotate around y-axis.
  z_ang | angle 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:

  scal | the 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_scal | the amount to scale in the direction of the x-axis.
  y_scal | the amount to scale in the direction of the y-axis.
  z_scal | the 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:

  dir | the direction to scale.
  scal | the 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:

  c1 | first column.
  c2 | second column.
  c3 | third column.
  c4 | fourth 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:

  norm | a 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_ang | angle in radians to rotate around x-axis.
  y_ang | angle in radians to rotate around y-axis.
  z_ang | angle 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_from | the direction vector to rotate.
  v_to | the 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:

  axis | the axis o rotate around.
  angle | the 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:

  angles | a 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:

  dir | the direction to scale.
  scal | the 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_scal | the amount to scale in the direction of the x-axis.
  y_scal | the amount to scale in the direction of the y-axis.
  z_scal | the 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:

  scal | the 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_ang | the angle between the y'-axis and the z'axis.
  zx_ang | the angle between the z'-axis and the x-axis.
  xy_ang | the angle between the x-axis and the y'-axis.
  valid | to 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:

  trans | the 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_ang | the angle between the z'-axis and the x-axis.
  xy_ang | the angle between the x-axis and the y'-axis.
  yz_ang | the angle between the y'-axis and the z'axis.
  valid | to 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:

  trans | the vector to translate by.

Returns:
  A matrix with the translation set.

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

- base/mat3d.h
- base/mat3d.cc