Implement missing members & documentation for Matrix4x4
All checks were successful
Build Docs With Doxygen / Explore-Gitea-Actions (push) Successful in 1m28s
All checks were successful
Build Docs With Doxygen / Explore-Gitea-Actions (push) Successful in 1m28s
This commit is contained in:
@@ -24,25 +24,30 @@ namespace J3ML::LinearAlgebra {
|
||||
* You can access m_yx using the double-bracket notation m[y][x]
|
||||
*/
|
||||
class Matrix4x4 {
|
||||
public:
|
||||
// TODO: Implement assertions to ensure matrix bounds are not violated!
|
||||
public: /// Constant Values
|
||||
enum { Rows = 4 };
|
||||
enum { Cols = 4 };
|
||||
|
||||
public: /// Constant Members
|
||||
/// A constant matrix that has zeroes in all its entries
|
||||
static const Matrix4x4 Zero;
|
||||
/// A constant matrix that is the identity.
|
||||
/** The identity matrix looks like the following:
|
||||
1 0 0 0
|
||||
0 1 0 0
|
||||
0 0 1 0
|
||||
0 0 0 1
|
||||
Transforming a vector by the identity matrix is like multiplying a number by one, i.e. the vector is not changed */
|
||||
static const Matrix4x4 Identity;
|
||||
|
||||
/// A compile-time constant float4x4 which has NaN in each element.
|
||||
/// For this constant, each element has the value of quet NaN, or Not-A-Number.
|
||||
/// Never compare a matrix to this value. Due to how IEEE floats work, "nan == nan" returns false!
|
||||
/// @note Never compare a matrix to this value. Due to how IEEE floats work, "nan == nan" returns false!
|
||||
static const Matrix4x4 NaN;
|
||||
|
||||
/// Creates a new float4x4 with uninitialized member values.
|
||||
public: /// Constructors
|
||||
/// Creates a new Matrix4x4 with uninitialized member values.
|
||||
Matrix4x4() {}
|
||||
Matrix4x4(const Matrix4x4 &rhs) = default; // {Set(rhs);}
|
||||
Matrix4x4(float val);
|
||||
/// Constructs this float4x4 to represent the same transformation as the given float3x3.
|
||||
/// Constructs this Matrix4x4 to represent the same transformation as the given float3x3.
|
||||
/** This function expands the last row and column of this matrix with the elements from the identity matrix. */
|
||||
Matrix4x4(const Matrix3x3&);
|
||||
explicit Matrix4x4(const float* data);
|
||||
@@ -65,6 +70,7 @@ namespace J3ML::LinearAlgebra {
|
||||
position of the local space pivot. */
|
||||
Matrix4x4(const Vector4& r1, const Vector4& r2, const Vector4& r3, const Vector4& r4);
|
||||
|
||||
/// Constructs this Matrix4x4 from the given quaternion.
|
||||
explicit Matrix4x4(const Quaternion& orientation);
|
||||
|
||||
/// Constructs this float4x4 from the given quaternion and translation.
|
||||
@@ -102,6 +108,64 @@ namespace J3ML::LinearAlgebra {
|
||||
@see RotateFromTo(). */
|
||||
static Matrix4x4 LookAt(const Vector3& localFwd, const Vector3& targetDir, const Vector3& localUp, const Vector3& worldUp);
|
||||
|
||||
/// Creates a new Matrix4x4 that rotates about one of the principal axes.
|
||||
/** Calling RotateX, RotateY, or RotateZ is slightly faster than calling the more generic RotateAxisAngle function.
|
||||
@param radians The angle to rotate by, in radians. For example, Pi/4.f equals 45 degrees.
|
||||
@param pointOnAxis If specified, the rotation is performed about an axis that passes through this point,
|
||||
and not through the origin. The returned matrix will not be a pure rotation matrix, but will also contain translation.
|
||||
*/
|
||||
static Matrix4x4 RotateX(float radians, const Vector3 &pointOnAxis);
|
||||
/// [similarOverload: RotateX] [hideIndex]
|
||||
static Matrix4x4 RotateX(float radians);
|
||||
/// [similarOverload: RotateX] [hideIndex]
|
||||
static Matrix4x4 RotateY(float radians, const Vector3 &pointOnAxis);
|
||||
/// [similarOverload: RotateX] [hideIndex]
|
||||
static Matrix4x4 RotateY(float radians);
|
||||
/// [similarOverload: RotateX] [hideIndex]
|
||||
static Matrix4x4 RotateZ(float radians, const Vector3 &pointOnAxis);
|
||||
/// [similarOverload: RotateX] [hideIndex]
|
||||
static Matrix4x4 RotateZ(float radians);
|
||||
|
||||
/// Creates a new Matrix4x4 that rotates about the given axis.
|
||||
/** @param axisDirection The axis to rotate about. This vector must be normalized.
|
||||
@param angleRadians The angle to rotate by, in radians.
|
||||
@param pointOnAxis If specified, the rotation is performed about an axis that passes through this point,
|
||||
and not through the origin. The returned matrix will not be a pure rotation matrix, but will also contain translation. */
|
||||
static Matrix4x4 RotateAxisAngle(const Vector3 &axisDirection, float angleRadians, const Vector3& pointOnAxis);
|
||||
static Matrix4x4 RotateAxisAngle(const Vector3 &axisDirection, float angleRadians);
|
||||
|
||||
/// Creates a new Matrix4x4 that rotates sourceDirection vector to coincide with the targetDirection vector.
|
||||
/** @note There are infinite such rotations - this function returns the rotation that has the shortest angle
|
||||
(when decomposed to axis-angle notation)
|
||||
@param sourceDirection The 'from' direction vector. This vector must be normalized.
|
||||
@param targetDirection The 'to' direction vector. This vector must be normalized.
|
||||
@param centerPoint If specified, rotation is performed using this point as the coordinate space origin.
|
||||
If omitted, the rotation is performed about the coordinate system origin (0,0,0).
|
||||
@return A new rotation matrix R for which R*sourceDirection == targetDirection */
|
||||
static Matrix4x4 RotateFromTo(const Vector3 &sourceDirection, const Vector3 &targetDirection, const Vector3 ¢erPoint);
|
||||
static Matrix4x4 RotateFromTo(const Vector3 &sourceDirection, const Vector3 &targetDirection);
|
||||
static Matrix4x4 RotateFromTo(const Vector4 &sourceDirection, const Vector4 &targetDirection);
|
||||
|
||||
/// Creates a new Matrix4x4 that rotates one coordinate system to coincide with another.
|
||||
/** This function rotates the sourceDirection vector to coincide with the targetDirection vector, and then
|
||||
rotates sourceDirection2 (which was transformed by 1.) to targetDirection2, but keeping the constraint that
|
||||
sourceDirection must look at targetDirection. */
|
||||
/** @param sourceDirection The first 'from' direction. This vector must be normalized.
|
||||
@param targetDirection The first 'to' direction. This vector must be normalized.
|
||||
@param sourceDirection2 The second 'from' direction. This vector must be normalized.
|
||||
@param targetDirection2 The second 'to' direction. This vector must be normalized.
|
||||
@param centerPoint If specified, rotation is performed using this point as the coordinate space origin.
|
||||
@return The returned matrix maps sourceDirection to targetDirection. Additionally, the returned matrix
|
||||
rotates sourceDirection2 to point towards targetDirection2 as closely as possible, under the previous constriant.
|
||||
The returned matrix is a rotation matrix, i.e. it is orthonormal with a determinant of +1, and optionally
|
||||
has a translation component if the rotation is not performed w.r.t. the coordinate system origin */
|
||||
static Matrix4x4 RotateFromTo(const Vector3& sourceDirection, const Vector3 &targetDirection,
|
||||
const Vector3 &sourceDirection2, const Vector3 &targetDirection2,
|
||||
const Vector3 ¢erPoint);
|
||||
static Matrix4x4 RotateFromTo(const Vector3& sourceDirection, const Vector3 &targetDirection,
|
||||
const Vector3 &sourceDirection2, const Vector3 &targetDirection2);
|
||||
|
||||
|
||||
/// Returns the translation part.
|
||||
/** The translation part is stored in the fourth column of this matrix.
|
||||
This is equivalent to decomposing this matrix in the form M = T * M', i.e. this translation is applied last,
|
||||
|
Reference in New Issue
Block a user