Tuesday
|
Functions for generating and converting between different types of transformations.
This library has a few different ways of representing 3-dimensional rotations specifically:
vec3
(the axis) and a scalar (the angle). All functions which take an axis-angle pair as their arguments assume the axis is normalized and the angle is measured in radians counter-clockwise around the axis.vec4
. The first three components make up the axis and the fourth component represents the angle.vec3
. You could imagine it as a more-compact version of an axis-angle pair; its direction represents the axis of rotation and its magnitude the angle (again, radians counter-clockwise around the axis). You could also imagine it as the composite of three separate rotations with each component representing an angle of rotation around the corresponding principal axis. Rotation vectors are most useful when rotations need to be interpolated and/or multiplied, such as when representing angular velocity.quat
). It's kind of like an axis-angle vector, but the entire vector is assumed to be normalized instead of just the axis. This is achieved by multiplying the normalized axis by sin(angle/2)
and storing cos(angle/2)
instead of the angle itself in the fourth component. Rotation quaternions are best used when representing an orientation in 3-dimensional space or when composing multiple rotations into one. Since they're defined by trigonometric functions, computationally expensive trigonometry isn't needed when using them to rotate vectors or when generating rotation matrices.Functions | |
template<typename T > | |
vec4< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::axis_angle (const T &x, const T &y, const T &z) noexcept |
Converts a rotation vector to an axis-angle vector. More... | |
template<typename T > | |
vec4< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::axis_angle (const vec3< T > &v) noexcept |
Converts a rotation vector to an axis-angle vector. More... | |
template<typename T > | |
constexpr vec3< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_vec (const T &axis_x, const T &axis_y, const T &axis_z, const T &angle) noexcept |
Converts an axis-angle pair to a rotation vector. More... | |
template<typename T > | |
constexpr vec3< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_vec (const vec3< T > &axis, const T &angle) noexcept |
Converts an axis-angle pair to a rotation vector. More... | |
template<typename T > | |
constexpr vec3< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_vec (const vec4< T > &v) noexcept |
Converts an axis-angle vector to a rotation vector. More... | |
template<typename T > | |
quat< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_quat (const T &axis_x, const T &axis_y, const T &axis_z, const T &angle) noexcept |
Converts an axis-angle pair to a rotation quaternion. More... | |
template<typename T > | |
quat< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_quat (const vec3< T > &axis, const T &angle) noexcept |
Converts an axis-angle pair to a rotation quaternion. More... | |
template<typename T > | |
quat< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_quat (const vec4< T > &v) noexcept |
Converts an axis-angle vector to a rotation quaternion. More... | |
template<typename T > | |
quat< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_quat (const T &x, const T &y, const T &z) noexcept |
Converts a rotation vector to a rotation quaternion. More... | |
template<typename T > | |
quat< decltype(tue::math::sin(std::declval< T >)))> | tue::transform::rotation_quat (const vec3< T > &v) noexcept |
Converts a rotation vector to a rotation quaternion. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=2 &&R >=3), mat< T, C, R > > | tue::transform::translation_mat (const T &x, const T &y) noexcept |
Computes a 2D translation matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=2 &&R >=3), mat< T, C, R > > | tue::transform::translation_mat (const vec2< T > &v) noexcept |
Computes a 2D translation matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=3 &&R >=4), mat< T, C, R > > | tue::transform::translation_mat (const T &x, const T &y, const T &z) noexcept |
Computes a 3D translation matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=3 &&R >=4), mat< T, C, R > > | tue::transform::translation_mat (const vec3< T > &v) noexcept |
Computes a 3D translation matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=2 &&R >=2), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const T &angle) noexcept |
Computes a 2D rotation matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=3 &&R >=3), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const T &axis_x, const T &axis_y, const T &axis_z, const T &angle) noexcept |
Computes a 3D rotation matrix from an axis-angle pair. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=3 &&R >=3), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const vec3< T > &axis, const T &angle) noexcept |
Computes a 3D rotation matrix from an axis-angle pair. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=3 &&R >=3), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const vec4< T > &v) noexcept |
Computes a 3D rotation matrix from an axis-angle vector. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=3 &&R >=3), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const T &x, const T &y, const T &z) noexcept |
Computes a 3D rotation matrix from a rotation vector. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=3 &&R >=3), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const vec3< T > &v) noexcept |
Computes a 3D rotation matrix from a rotation vector. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t< (C >=3 &&R >=3), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::rotation_mat (const quat< T > &q) noexcept |
Computes a 3D rotation matrix from a rotation quaternion. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=2 &&R >=2), mat< T, C, R > > | tue::transform::scale_mat (const T &x, const T &y) noexcept |
Computes a 2D scale matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=2 &&R >=2), mat< T, C, R > > | tue::transform::scale_mat (const vec2< T > &v) noexcept |
Computes a 2D scale matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=3 &&R >=3), mat< T, C, R > > | tue::transform::scale_mat (const T &x, const T &y, const T &z) noexcept |
Computes a 3D scale matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t<(C >=3 &&R >=3), mat< T, C, R > > | tue::transform::scale_mat (const vec3< T > &v) noexcept |
Computes a 3D scale matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
std::enable_if_t< (C >=4 &&R >=4), mat< decltype(tue::math::sin(std::declval< T >))), C, R > > | tue::transform::perspective_mat (const T &fovy, const T &aspect, const T &n, const T &f) noexcept |
Computes a 3D perspective matrix. More... | |
template<typename T , int C = 4, int R = 4> | |
constexpr std::enable_if_t< (C >=3 &&R >=4), mat< decltype(tue::math::recip(std::declval< T >))), C, R > > | tue::transform::ortho_mat (const T &width, const T &height, const T &n, const T &f) noexcept |
Computes an orthographic projection matrix. More... | |
|
inlinenoexcept |
Converts a rotation vector to an axis-angle vector.
If the rotation vector's length is 0
, returns (0, 0, 1, 0)
.
T | The rotation vector's component type. |
x | The rotation vector's first component. |
y | The rotation vector's second component. |
z | The rotation vector's third component. |
|
inlinenoexcept |
Converts a rotation vector to an axis-angle vector.
If the rotation vector's length is 0
, returns (0, 0, 1, 0)
.
T | The rotation vector's component type. |
v | The rotation vector. |
|
inlinenoexcept |
Converts an axis-angle pair to a rotation vector.
This function assumes the axis is normalized.
T | The axis-angle component type. |
axis_x | The axis' first component. |
axis_y | The axis' second component. |
axis_z | The axis' third component. |
angle | The angle. |
|
inlinenoexcept |
Converts an axis-angle pair to a rotation vector.
This function assumes the axis is normalized.
T | The axis-angle component type. |
axis | The axis. |
angle | The angle. |
|
inlinenoexcept |
Converts an axis-angle vector to a rotation vector.
This function assumes the axis is normalized.
T | The axis-angle component type. |
v | The axis-angle vector. |
|
inlinenoexcept |
Converts an axis-angle pair to a rotation quaternion.
This function assumes the axis is normalized.
T | The axis-angle component type. |
axis_x | The axis' first component. |
axis_y | The axis' second component. |
axis_z | The axis' third component. |
angle | The angle. |
|
inlinenoexcept |
Converts an axis-angle pair to a rotation quaternion.
This function assumes the axis is normalized.
T | The axis-angle component type. |
axis | The axis. |
angle | The angle. |
|
inlinenoexcept |
Converts an axis-angle vector to a rotation quaternion.
This function assumes the axis is normalized.
T | The axis-angle component type. |
v | The axis-angle vector. |
|
inlinenoexcept |
Converts a rotation vector to a rotation quaternion.
If the rotation vector's length is 0
, returns (0, 0, 0, 1)
.
T | The rotation vector's component type. |
x | The rotation vector's first component. |
y | The rotation vector's second component. |
z | The rotation vector's third component. |
|
inlinenoexcept |
Converts a rotation vector to a rotation quaternion.
If the rotation vector's length is 0
, returns (0, 0, 0, 1)
.
T | The rotation vector's component type. |
v | The rotation vector. |
|
inlinenoexcept |
Computes a 2D translation matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The type of parameters x and y . |
C | The column count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
x | The translation along the x axis. |
y | The translation along the y axis. |
|
inlinenoexcept |
Computes a 2D translation matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The component type of v . |
C | The column count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
v | The translation vector. |
|
inlinenoexcept |
Computes a 3D translation matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The type of parameters x , y , and z . |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 4. Defaults to 4. |
x | The translation along the x axis. |
y | The translation along the y axis. |
z | The translation along the z axis. |
|
inlinenoexcept |
Computes a 3D translation matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The component type of v . |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 4. Defaults to 4. |
v | The translation vector. |
|
inlinenoexcept |
Computes a 2D rotation matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The type of parameter angle . |
C | The column count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
angle | The rotation (measured in radians counter-clockwise). |
|
inlinenoexcept |
Computes a 3D rotation matrix from an axis-angle pair.
This function assumes the axis is normalized.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The axis-angle component type. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
axis_x | The axis' first component. |
axis_y | The axis' second component. |
axis_z | The axis' third component. |
angle | The angle. |
|
inlinenoexcept |
Computes a 3D rotation matrix from an axis-angle pair.
This function assumes the axis is normalized.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The axis-angle component type. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
axis | The axis. |
angle | The angle. |
|
inlinenoexcept |
Computes a 3D rotation matrix from an axis-angle vector.
This function assumes the axis is normalized.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The axis-angle component type. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
v | The axis-angle vector. |
|
inlinenoexcept |
Computes a 3D rotation matrix from a rotation vector.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The rotation vector's component type. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
x | The rotation vector's first component. |
y | The rotation vector's second component. |
z | The rotation vector's third component. |
|
inlinenoexcept |
Computes a 3D rotation matrix from a rotation vector.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The rotation vector's component type. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
v | The rotation vector. |
|
inlinenoexcept |
Computes a 3D rotation matrix from a rotation quaternion.
This function assumes the quaternion is normalized.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The rotation quaternion's component type. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
q | The rotation quaternion. |
|
inlinenoexcept |
Computes a 2D scale matrix.
T | The type of parameters x and y . |
C | The column count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
x | The scale along the x axis. |
y | The scale along the y axis. |
|
inlinenoexcept |
Computes a 2D scale matrix.
T | The component type of v . |
C | The column count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 2, 3, or 4. Defaults to 4. |
v | The scale vector. |
|
inlinenoexcept |
Computes a 3D scale matrix.
T | The type of parameters x , y , and z . |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
x | The scale along the x axis. |
y | The scale along the y axis. |
z | The scale along the z axis. |
|
inlinenoexcept |
Computes a 3D scale matrix.
T | The component type of v . |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 3 or 4. Defaults to 4. |
v | The scale vector. |
|
inlinenoexcept |
Computes a 3D perspective matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The type of all four parameters. |
C | The column count of the returned matrix. Must be 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 4. Defaults to 4. |
fovy | The vertical field of view (measured in radians). |
aspect | The aspect ratio (width / height). |
n | The distance to the near view plane. |
f | The distance to the far view plane. |
|
inlinenoexcept |
Computes an orthographic projection matrix.
The returned matrix might be the transpose of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.
T | The type of all four parameters. |
C | The column count of the returned matrix. Must be 3 or 4. Defaults to 4. |
R | The row count of the returned matrix. Must be 4. Defaults to 4. |
width | The orthographic projection width. |
height | The orthographic projection height. |
n | The distance to the near view plane. |
f | The distance to the far view plane. |