Antiprism 0.23
|
Matrix for transformations in 3D. More...
#include <mat3d.h>
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. |
Matrix for transformations in 3D.
mat3d::mat3d | ( | ) | [inline] |
Constructor.
Initialises to the identity.
Constructor.
Initialise the rows of the rotation part.
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.
r1 | first row. |
r2 | second row. |
r3 | third row. |
r4 | fourth row. |
double mat3d::det | ( | ) | const [inline] |
Determinant.
void mat3d::dump | ( | const char * | var = "" , |
FILE * | file = stderr |
||
) | const |
Debugging print of a matrix.
var | a string to identify the matrix variable. |
file | file stream to print the variable. |
vec3d mat3d::get_euler | ( | ) | const |
Get Euler angles.
const double* mat3d::get_m | ( | ) | [inline] |
Read access to the start of the element array.
vec4d mat3d::get_quaternion | ( | ) | const |
Get quaternion.
Convert the rotation part of the matrix into a quaterinon.
Get the inverse of a matrix.
mat | a matrix to get the inverse of. |
mat
. mat3d mat3d::inversion | ( | ) | [inline, static] |
Get an inversion.
Inversion through the origin.
Multiply this matrix by another matrix.
mat | the matrix to multiply. |
double mat3d::operator[] | ( | int | idx | ) | const [inline] |
Read access to the element array.
idx | index into the 16 element array. |
double& mat3d::operator[] | ( | int | idx | ) | [inline] |
Write access to the element array.
idx | index into the 16 element array. |
Get a reflection.
Reflect in a mirror plane passing through the origin.
norm | a normal to the mirror plane. |
Get a rotation by rotating around the coordinate axes.
Rotate around the x-axis, y-axis then z-axis.
angles | a vector whose components are the the angles in radians to rotate around he x-axis, y-axis and z-axis. |
Get a rotation by axis and angle.
Rotate around an arbitrary axis through the origin.
axis | the axis o 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. |
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.
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. |
mat3d mat3d::scale | ( | double | scal | ) | [inline, static] |
Get a uniform scaling.
Scale uniformly in all directions, away from the origin.
scal | the amount to scale. |
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.
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. |
Get a scaling in a single direction.
Scale in a single arbitrary direction, away from the origin.
dir | the direction to scale. |
scal | the amount to scale. |
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
c1 | first column. |
c2 | second column. |
c3 | third column. |
c4 | fourth column. |
mat3d & mat3d::set_inverse | ( | ) |
Set to the inverse of the matrix.
mat3d & mat3d::set_inversion | ( | ) | [inline] |
Set an inversion.
Inversion through the origin.
Set a reflection.
Reflect in a mirror plane passing through the origin.
norm | a normal to the mirror plane. |
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.
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. |
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. |
Set a rotation by axis and angle.
Rotate around an arbitrary axis through the origin.
axis | the axis o rotate around. |
angle | the angle to rotate, in radians. |
Set a rotation by rotating around the coordinate axes.
Rotate around the x-axis, y-axis then z-axis.
angles | a vector whose components are the the angles in radians to rotate around he x-axis, y-axis and z-axis. |
Set a scaling in a single direction.
Scale in a single arbitrary direction, away from the origin.
dir | the direction to scale. |
scal | the amount to scale. |
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.
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. |
mat3d & mat3d::set_scale | ( | double | scal | ) | [inline] |
Set a uniform scaling.
Scale uniformly in all directions, away from the origin.
scal | the amount to scale. |
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.
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. |
Set a translation.
trans | the vector to translate by. |
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.
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. |
Get a translation.
trans | the vector to translate by. |