Implement Matrix4x4::RandomGeneral()
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Matrices.inl>
|
||||
|
||||
#include <J3ML/Algorithm/RNG.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace J3ML::Algorithm;
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
||||
template <typename Matrix>
|
||||
@@ -218,6 +220,11 @@ namespace J3ML::LinearAlgebra {
|
||||
@see RotateFromTo(). */
|
||||
static Matrix4x4 LookAt(const Vector3& localFwd, const Vector3& targetDir, const Vector3& localUp, const Vector3& worldUp);
|
||||
|
||||
/// Returns a random 4x4 matrix with each entry randomized between the range [minElem, maxElem]
|
||||
/** Warning: The matrices returned by this function do not represent well-formed 3D transformations.
|
||||
This function is mostly used for testing and debugging purposes only. */
|
||||
static Matrix4x4 RandomGeneral(RNG& rng, float minElem, float maxElem);
|
||||
|
||||
/// 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.
|
||||
@@ -293,25 +300,33 @@ namespace J3ML::LinearAlgebra {
|
||||
/// Identical to D3DXMatrixPerspectiveLH, except transposed to account for Matrix * vector convention used in J3ML.
|
||||
/// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb205352(v=vs.85).aspx
|
||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||
static Matrix4x4 D3DPerspProjLH(float n, float f, float h, float v);
|
||||
static Matrix4x4 D3DPerspProjLH(float nearPlane, float farPlane, float hViewportSize, float vViewportSize);
|
||||
/// Identical to D3DXMatrixPerspectiveRH, except transposed to account for Matrix * vector convention used in J3ML.
|
||||
/// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb205355(v=vs.85).aspx
|
||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||
static Matrix4x4 D3DPerspProjRH(float n, float f, float h, float v);
|
||||
static Matrix4x4 D3DPerspProjRH(float nearPlane, float farPlane, float hViewportSize, float vViewportSize);
|
||||
|
||||
/// Computes a left-handled orthographic projection matrix for OpenGL.
|
||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||
static Matrix4x4 OpenGLOrthoProjLH(float n, float f, float h, float v);
|
||||
static Matrix4x4 OpenGLOrthoProjLH(float nearPlane, float farPlane, float hViewportSize, float vViewportSize);
|
||||
/// Computes a right-handled orthographic projection matrix for OpenGL.
|
||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||
static Matrix4x4 OpenGLOrthoProjRH(float n, float f, float h, float v);
|
||||
static Matrix4x4 OpenGLOrthoProjRH(float nearPlane, float farPlane, float hViewportSize, float vViewportSize);
|
||||
|
||||
/// Computes a left-handed perspective projection matrix for OpenGL.
|
||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||
/// @param n Near-plane
|
||||
/// @param f Far-plane
|
||||
/// @param h Horizontal FOV
|
||||
/// @param v Vertical FOV
|
||||
static Matrix4x4 OpenGLPerspProjLH(float n, float f, float h, float v);
|
||||
/// Identical to http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml , except uses viewport sizes instead of FOV to set up the
|
||||
/// projection matrix.
|
||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||
// @param n Near-plane
|
||||
/// @param f Far-plane
|
||||
/// @param h Horizontal FOV
|
||||
/// @param v Vertical FOV
|
||||
static Matrix4x4 OpenGLPerspProjRH(float n, float f, float h, float v);
|
||||
|
||||
/// Creates a new transformation matrix that translates by the given offset.
|
||||
@@ -604,7 +619,7 @@ namespace J3ML::LinearAlgebra {
|
||||
/// If a matrix is of form M=T*R*S, where T is an affine translation matrix
|
||||
/// R is a rotation matrix and S is a diagonal matrix with non-zero but pote ntially non-uniform scaling
|
||||
/// factors (possibly mirroring), then the matrix M is column-orthogonal and this function can be used to compute the inverse.
|
||||
/// Calling this function is faster than the calling the generic matrix Inverse() function.
|
||||
/// Calling this function is faster than the calling the generic matrix Inverted() function.
|
||||
/// Returns true on success. On failure, the matrix is not modified. This function fails if any of the
|
||||
/// elements of this vector are not finite, or if the matrix contains a zero scaling factor on X, Y, or Z.
|
||||
/// This function may not be called if this matrix contains any projection (last row differs from (0 0 0 1)).
|
||||
@@ -618,7 +633,7 @@ namespace J3ML::LinearAlgebra {
|
||||
/// If a matrix is of form M = T*R*S, where T is an affine translation matrix,
|
||||
/// R is a rotation matrix and S is a diagonal matrix with non-zero and uniform scaling factors (possibly mirroring),
|
||||
/// then the matrix M is both column- and row-orthogonal and this function can be used to compute this inverse.
|
||||
/// This function is faster than calling InverseColOrthogonal() or the generic Inverse().
|
||||
/// This function is faster than calling InverseColOrthogonal() or the generic Inverted().
|
||||
/// Returns true on success. On failure, the matrix is not modified. This function fails if any of the
|
||||
/// elements of this vector are not finite, or if the matrix contains a zero scaling factor on X, Y, or Z.
|
||||
/// This function may not be called if this matrix contains any shearing or nonuniform scaling.
|
||||
@@ -628,7 +643,7 @@ namespace J3ML::LinearAlgebra {
|
||||
/// Inverts a matrix that is a concatenation of only translate and rotate operations.
|
||||
/// If a matrix is of form M = T*R*S, where T is an affine translation matrix, R is a rotation
|
||||
/// matrix and S is either identity or a mirroring matrix, then the matrix M is orthonormal and this function can be used to compute the inverse.
|
||||
/// This function is faster than calling InverseOrthogonalUniformScale(), InverseColOrthogonal(), or the generic Inverse().
|
||||
/// This function is faster than calling InverseOrthogonalUniformScale(), InverseColOrthogonal(), or the generic Inverted().
|
||||
/// This function may not be called if this matrix contains any scaling or shearing, but it may contain mirroring.
|
||||
/// This function may not be called if this matrix contains any projection (last row differs from (0 0 0 1)).
|
||||
void InverseOrthonormal();
|
||||
|
Reference in New Issue
Block a user