Antiprism 0.23
|
Matrix for transformations in 4D. More...
#include <mat4d.h>
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. |
Matrix for transformations in 4D.
mat4d::mat4d | ( | ) | [inline] |
Constructor.
Initialises to the identity
Constructor.
Initialise the rows of the rotation part.
r1 | first row. |
r2 | second row. |
r3 | third row. |
r4 | fourth row. |
void mat4d::dump | ( | const char * | var = "" , |
FILE * | file = stderr |
||
) |
Debugging print of a matrix.
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.
mat4d & mat4d::operator*= | ( | double | n | ) | [inline] |
Multiply this matrix by a scalar.
n | the scalar. |
Multiply this matrix by another matrix.
mat | the matrix to multiply. |
Add another matrix to this matrix.
mat | the matrix to add. |
double& mat4d::operator[] | ( | int | idx | ) | [inline] |
Write access to the element array.
idx | index into the 16 element array. |
double mat4d::operator[] | ( | int | idx | ) | const [inline] |
Read access to the element array.
idx | index into the 16 element array. |
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.
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. |
Get a rotation by plane axis and angle.
Rotate around an arbitrary plane axis through the origin.
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. |
Get a rotation by rotating one direction vector onto another.
v_from | the direction vector to rotate. |
v_to | the direction v_from should point after the rotation. |
mat4d mat4d::scale | ( | double | scal | ) | [inline, static] |
Get a uniform scaling.
Scale uniformly in all directions, away from the origin.
scal | the amount to scale. |
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.
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. |
mat4d & mat4d::set_inversion | ( | ) | [inline] |
Set an inversion.
Inversion through the origin.
Set a rotation by plane axis and angle.
Rotate around an arbitrary plane axis through the origin.
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. |
Set a rotation by rotating one direction vector onto another.
v_from | the direction vector to rotate. |
v_to | the direction v_from should point after the rotation. |
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.
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. |
mat4d & mat4d::set_scale | ( | double | scal | ) | [inline] |
Set a uniform scaling.
Scale uniformly in all directions, away from the origin.
scal | the amount to scale. |
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.
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. |
Set a translation.
trans | the vector to translate by. |
Get a translation.
trans | the vector to translate by. |