Antiprism 0.23

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# mat4d Class Reference

Matrix for transformations in 4D. More...

`#include <mat4d.h>`

List of all members.

## Public Member Functions
| mat4d ()
| Constructor.
| mat4d (vec4d r1, vec4d r2, vec4d r3, vec4d r4)
| Constructor.
double | operator[] (int idx) const
| Read access to the element array.
double & | operator[] (int idx)
| Write access to the element array.
mat4d & | operator*= (const mat4d &mat)
| Multiply this matrix by another matrix.
mat4d & | operator*= (double n)
| Multiply this matrix by a scalar.
mat4d & | operator+= (const mat4d &mat)
| Add another matrix to this matrix.
mat4d & | transpose ()
| Transpose the matrix.
mat4d & | to_unit ()
| Set the matrix to the unit matrix.
mat4d & | to_zero ()
| Set the matrix to zero.
mat4d & | set_rot (vec4d u, vec4d v, double angle)
| Set a rotation by plane axis and angle.
mat4d & | set_rot (vec4d v_from, vec4d v_to)
| Set a rotation by rotating one direction vector onto another.
mat4d & | set_rot (double xy_ang, double yz_ang, double zw_ang, double wx_ang, double xz_ang, double yw_ang)
| Set a rotation by rotating around the coordinate-plane axes.
mat4d & | set_transl (vec4d trans)
| Set a translation.
mat4d & | set_scale (double scal)
| Set a uniform scaling.
mat4d & | set_scale (double x_scal, double y_scal, double z_scal, double w_scal)
| Set a scaling by components.
mat4d & | set_inversion ()
| Set an inversion.
void | dump (const char *var="", FILE *file=stderr)
| Debugging print of a matrix.
## Static Public Member Functions
static mat4d | unit ()
| Get a unit matrix.
static mat4d | zero ()
| Get a zero matrix.
static mat4d | rot (vec4d u, vec4d v, double angle)
| Get a rotation by plane axis and angle.
static mat4d | rot (vec4d v_from, vec4d v_to)
| Get a rotation by rotating one direction vector onto another.
static mat4d | rot (double xy_ang, double yz_ang, double zw_ang, double wx_ang, double xz_ang, double yw_ang)
| Get a rotation by rotating around the coordinate-plane axes.
static mat4d | transl (vec4d trans)
| Get a translation.
static mat4d | scale (double scal)
| Get a uniform scaling.
static mat4d | scale (double x_scal, double y_scal, double z_scal, double w_scal)
| Get a scaling by components.
static mat4d | inversion ()
| Get an inversion.

## Detailed Description

Matrix for transformations in 4D.

## Constructor & Destructor Documentation

mat4d::mat4d | ( |  | ) | `[inline]`

Constructor.

Initialises to the identity

mat4d::mat4d | ( | vec4d | r1,
|  | vec4d | r2,
|  | vec4d | r3,
|  | vec4d | r4
| ) |  | `[inline]`

Constructor.

Initialise the rows of the rotation part.

Parameters:

  r1 | first row.
  r2 | second row.
  r3 | third row.
  r4 | fourth row.

## Member Function Documentation

void mat4d::dump | ( | const char * | var = `""`,
|  | FILE * | file = `stderr`
| ) |  |

Debugging print of a matrix.

Parameters:

  var | a string to identify the matrix variable.
  file | file stream to print the variable.

mat4d mat4d::inversion | ( |  | ) | `[inline, static]`

Get an inversion.

Inversion through the origin.

Returns:
  A matrix with the inversion set.

mat4d & mat4d::operator*= | ( | double | n | ) | `[inline]`

Multiply this matrix by a scalar.

Parameters:

  n | the scalar.

Returns:
  A reference to the result, held in this matrix.

mat4d & mat4d::operator*= | ( | const mat4d & | mat | ) | `[inline]`

Multiply this matrix by another matrix.

Parameters:

  mat | the matrix to multiply.

Returns:
  A reference to the result, held in this matrix.

mat4d & mat4d::operator+= | ( | const mat4d & | mat | ) | `[inline]`

Add another matrix to this matrix.

Parameters:

  mat | the matrix to add.

Returns:
  A reference to the result, held in this matrix.

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

Write access to the element array.

Parameters:

  idx | index into the 16 element array.

Returns:
  The element.

double mat4d::operator[] | ( | int | idx | ) | const`[inline]`

Read access to the element array.

Parameters:

  idx | index into the 16 element array.

Returns:
  The element.

mat4d mat4d::rot | ( | double | xy_ang,
|  | double | yz_ang,
|  | double | zw_ang,
|  | double | wx_ang,
|  | double | xz_ang,
|  | double | yw_ang
| ) |  | `[inline, static]`

Get a rotation by rotating around the coordinate-plane axes.

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

Parameters:

  xy_ang | angle in radians to rotate around xy-axis.
  yz_ang | angle in radians to rotate around yz-axis.
  zw_ang | angle in radians to rotate around zw-axis.
  wx_ang | angle in radians to rotate around wx-axis.
  xz_ang | angle in radians to rotate around xz-axis.
  yw_ang | angle in radians to rotate around yw-axis.

Returns:
  A matrix with the resulting rotation set.

mat4d mat4d::rot | ( | vec4d | u,
|  | vec4d | v,
|  | double | angle
| ) |  | `[inline, static]`

Get a rotation by plane axis and angle.

Rotate around an arbitrary plane axis through the origin.

Parameters:

  u | the first basis vector of the axis plane to rotate around.
  v | the second basis vector of the axis plane to rotate around.
  angle | the angle to rotate, in radians.

Returns:
  A matrix with the resulting rotation set.

mat4d mat4d::rot | ( | vec4d | v_from,
|  | vec4d | 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 matrix with the resulting rotation set.

mat4d mat4d::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.

mat4d mat4d::scale | ( | double | x_scal,
|  | double | y_scal,
|  | double | z_scal,
|  | double | w_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.
  w_scal | the amount to scale in the direction of the z-axis.

Returns:
  A reference to this matrix with the scaling set.

mat4d & mat4d::set_inversion | ( |  | ) | `[inline]`

Set an inversion.

Inversion through the origin.

Returns:
  A reference to this matrix with the inversion set.

mat4d & mat4d::set_rot | ( | vec4d | u,
|  | vec4d | v,
|  | double | angle
| ) |  | `[inline]`

Set a rotation by plane axis and angle.

Rotate around an arbitrary plane axis through the origin.

Parameters:

  u | the first basis vector of the axis plane to rotate around.
  v | the second basis vector of the axis plane to rotate around.
  angle | the angle to rotate, in radians.

Returns:
  A reference to this matrix with the resulting rotation set.

mat4d & mat4d::set_rot | ( | vec4d | v_from,
|  | vec4d | v_to
| ) |  | `[inline]`

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.

mat4d & mat4d::set_rot | ( | double | xy_ang,
|  | double | yz_ang,
|  | double | zw_ang,
|  | double | wx_ang,
|  | double | xz_ang,
|  | double | yw_ang
| ) |  | `[inline]`

Set a rotation by rotating around the coordinate-plane axes.

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

Parameters:

  xy_ang | angle in radians to rotate around xy-axis.
  yz_ang | angle in radians to rotate around yz-axis.
  zw_ang | angle in radians to rotate around zw-axis.
  wx_ang | angle in radians to rotate around wx-axis.
  xz_ang | angle in radians to rotate around xz-axis.
  yw_ang | angle in radians to rotate around yw-axis.

Returns:
  A reference to this matrix with the resulting rotation set.

mat4d & mat4d::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.

mat4d & mat4d::set_scale | ( | double | x_scal,
|  | double | y_scal,
|  | double | z_scal,
|  | double | w_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.
  w_scal | the amount to scale in the direction of the z-axis.

Returns:
  A reference to this matrix with the scaling set.

mat4d & mat4d::set_transl | ( | vec4d | trans | ) | `[inline]`

Set a translation.

Parameters:

  trans | the vector to translate by.

Returns:
  A reference to this matrix with the translation set.

mat4d mat4d::transl | ( | vec4d | 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/mat4d.h
- base/mat4d.cc