Class Mat4d
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
4x4 Matrix Math Open in GitHub
public class Mat4d
- Inheritance
-
Mat4d
- Inherited Members
- Extension Methods
Methods
Adjoint(double[], double[])
Calculates the adjugate of a mat4
public static double[] Adjoint(double[] output, double[] a)
Parameters
Returns
- double[]
{mat4} out
CloneIt(double[])
Creates a new mat4 initialized with values from an existing matrix
public static double[] CloneIt(double[] a)
Parameters
adouble[]a matrix to clone
Returns
- double[]
{mat4} a new 4x4 matrix
Copy(double[], double[])
Copy the values from one mat4 to another
public static double[] Copy(double[] output, double[] a)
Parameters
Returns
- double[]
{mat4} out
Create()
Creates a new identity mat4 0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15
public static double[] Create()
Returns
- double[]
{mat4} a new 4x4 matrix
Determinant(double[])
Calculates the determinant of a mat4
public static double Determinant(double[] a)
Parameters
adouble[]{mat4} a the source matrix
Returns
- double
{Number} determinant of a
FromQuat(double[], double[])
Calculates a 4x4 matrix from the given quaternion
public static double[] FromQuat(double[] output, double[] q)
Parameters
outputdouble[]{mat4} out mat4 receiving operation result
qdouble[]{quat} q Quaternion to create matrix from
Returns
- double[]
{mat4} out
FromRotationTranslation(double[], double[], double[])
Creates a matrix from a quaternion rotation and vector translation This is equivalent to (but much faster than): mat4.identity(dest); mat4.translate(dest, vec); var quatMat = mat4.create(); quat4.toMat4(quat, quatMat); mat4.multiply(dest, quatMat);
public static double[] FromRotationTranslation(double[] output, double[] q, double[] v)
Parameters
outputdouble[]{mat4} out mat4 receiving operation result
qdouble[]{quat4} q Rotation quaternion
vdouble[]{vec3} v Translation vector
Returns
- double[]
{mat4} out
Frustum(double[], double, double, double, double, double, double)
Generates a frustum matrix with the given bounds
public static double[] Frustum(double[] output, double left, double right, double bottom, double top, double near, double far)
Parameters
outputdouble[]{mat4} out mat4 frustum matrix will be written into
leftdouble{Number} left Left bound of the frustum
rightdouble{Number} right Right bound of the frustum
bottomdouble{Number} bottom Bottom bound of the frustum
topdouble{Number} top Top bound of the frustum
neardouble{Number} near Near bound of the frustum
fardouble{Number} far Far bound of the frustum
Returns
- double[]
{mat4} out
Identity(double[])
Set a mat4 to the identity matrix
public static double[] Identity(double[] output)
Parameters
outputdouble[]{mat4} out the receiving matrix
Returns
- double[]
{mat4} out
Invert(double[], double[])
Inverts a mat4
public static double[] Invert(double[] output, double[] a)
Parameters
Returns
- double[]
{mat4} out
IsTranslationOnly(double[])
If we have a translation-only matrix - one with no rotation or scaling - return true.
If the matrix includes some scaling or rotation components, return false.
The identity matrix returns true here because there is no scaling or rotation, even though the translation is zero in that special case.
public static bool IsTranslationOnly(double[] matrix)
Parameters
matrixdouble[]
Returns
- bool
true if a simple translation matrix was found, otherwise false
LookAt(double[], double[], double[], double[])
Generates a look-at matrix with the given eye position, focal point, and up axis
public static double[] LookAt(double[] output, double[] eye, double[] center, double[] up)
Parameters
outputdouble[]{mat4} out mat4 frustum matrix will be written into
eyedouble[]{vec3} eye Position of the viewer
centerdouble[]{vec3} center Point the viewer is looking at
updouble[]{vec3} up vec3 pointing up
Returns
- double[]
{mat4} out
Mul(double[], double[], double[])
mat4.multiply
public static double[] Mul(double[] output, double[] a, double[] b)
Parameters
Returns
- double[]
Mul(double[], float[], double[])
mat4.multiply
public static double[] Mul(double[] output, float[] a, double[] b)
Parameters
Returns
- double[]
MulWithVec4(double[], double[])
Multiply the matrix with a vec4. Reference: http://mathinsight.org/matrix_vector_multiplication Returns a new vec4 vector
public static double[] MulWithVec4(double[] matrix, double[] vec4)
Parameters
Returns
- double[]
MulWithVec4(double[], double[], Vec4d)
Multiply the matrix with a vec4. Reference: http://mathinsight.org/matrix_vector_multiplication
public static void MulWithVec4(double[] matrix, double[] vec4, Vec4d outVal)
Parameters
MulWithVec4(double[], Vec4d, Vec4d)
Multiply the matrix with a vec4. Reference: http://mathinsight.org/matrix_vector_multiplication
public static void MulWithVec4(double[] matrix, Vec4d inVal, Vec4d outVal)
Parameters
Multiply(double[], double[], double[])
Multiplies two mat4's
public static double[] Multiply(double[] output, double[] a, double[] b)
Parameters
outputdouble[]{mat4} out the receiving matrix
adouble[]{mat4} a the first operand
bdouble[]{mat4} b the second operand
Returns
- double[]
{mat4} out
Multiply(double[], float[], double[])
Multiplies two mat4's
public static double[] Multiply(double[] output, float[] a, double[] b)
Parameters
outputdouble[]{mat4} out the receiving matrix
afloat[]{mat4} a the first operand
bdouble[]{mat4} b the second operand
Returns
- double[]
{mat4} out
Ortho(double[], double, double, double, double, double, double)
Generates a orthogonal projection matrix with the given bounds
public static double[] Ortho(double[] output, double left, double right, double bottom, double top, double near, double far)
Parameters
outputdouble[]{mat4} out mat4 frustum matrix will be written into
leftdouble{number} left Left bound of the frustum
rightdouble{number} right Right bound of the frustum
bottomdouble{number} bottom Bottom bound of the frustum
topdouble{number} top Top bound of the frustum
neardouble{number} near Near bound of the frustum
fardouble{number} far Far bound of the frustum
Returns
- double[]
{mat4} out
Perspective(double[], double, double, double, double)
Generates a perspective projection matrix with the given bounds
public static double[] Perspective(double[] output, double fovy, double aspect, double near, double far)
Parameters
outputdouble[]{mat4} out mat4 frustum matrix will be written into
fovydouble{number} fovy Vertical field of view in radians
aspectdouble{number} aspect Aspect ratio. typically viewport width/height
neardouble{number} near Near bound of the frustum
fardouble{number} far Far bound of the frustum
Returns
- double[]
{mat4} out
Rotate(double[], double[], double, double, double, double)
Rotates a mat4 by the given angle
public static double[] Rotate(double[] output, double[] a, double rad, double x, double y, double z)
Parameters
Returns
- double[]
Rotate(double[], double[], double, double[])
Rotates a mat4 by the given angle
public static double[] Rotate(double[] output, double[] a, double rad, double[] axis)
Parameters
outputdouble[]{mat4} out the receiving matrix
adouble[]{mat4} a the matrix to rotate
raddouble{Number} rad the angle to rotate the matrix by
axisdouble[]{vec3} axis the axis to rotate around
Returns
- double[]
{mat4} out
RotateX(double[], double[], double)
Rotates a matrix by the given angle around the X axis
public static double[] RotateX(double[] output, double[] a, double rad)
Parameters
outputdouble[]{mat4} out the receiving matrix
adouble[]{mat4} a the matrix to rotate
raddouble{Number} rad the angle to rotate the matrix by
Returns
- double[]
{mat4} out
RotateY(double[], double[], double)
Rotates a matrix by the given angle around the Y axis
public static double[] RotateY(double[] output, double[] a, double rad)
Parameters
outputdouble[]{mat4} out the receiving matrix
adouble[]{mat4} a the matrix to rotate
raddouble{Number} rad the angle to rotate the matrix by
Returns
- double[]
{mat4} out
RotateZ(double[], double[], double)
Rotates a matrix by the given angle around the Z axis
public static double[] RotateZ(double[] output, double[] a, double rad)
Parameters
outputdouble[]{mat4} out the receiving matrix
adouble[]{mat4} a the matrix to rotate
raddouble{Number} rad the angle to rotate the matrix by
Returns
- double[]
{mat4} out
Scale(double[], double, double, double)
public static void Scale(double[] matrix, double x, double y, double z)
Parameters
Scale(double[], double[], double[])
Scales the mat4 by the dimensions in the given vec3
public static double[] Scale(double[] output, double[] a, double[] v)
Parameters
outputdouble[]{mat4} out the receiving matrix
adouble[]{mat4} a the matrix to scale
vdouble[]{vec3} v the vec3 to scale the matrix by
Returns
- double[]
{mat4} out
ToMat4f(float[], double[])
public static float[] ToMat4f(float[] output, double[] input)
Parameters
Returns
- float[]
Translate(double[], double[], double, double, double)
Translate a mat4 by the given vector
public static double[] Translate(double[] output, double[] input, double x, double y, double z)
Parameters
outputdouble[]{mat4} out the receiving matrix
inputdouble[]{mat4} a the matrix to translate
xdouble{vec3} v vector to translate by
ydoublezdouble
Returns
- double[]
{mat4} out
Translate(double[], double[], double[])
Translate a mat4 by the given vector
public static double[] Translate(double[] output, double[] input, double[] translate)
Parameters
outputdouble[]{mat4} out the receiving matrix
inputdouble[]{mat4} a the matrix to translate
translatedouble[]{vec3} v vector to translate by
Returns
- double[]
{mat4} out
Transpose(double[], double[])
Transpose the values of a mat4
public static double[] Transpose(double[] output, double[] a)
Parameters
Returns
- double[]
{mat4} out