Class: Matrix4

ALMath.Matrix4

new Matrix4()

Class that represent a 4x4 matrix.
Author:
  • Ángel Luis Perales Gómez
Source:

Methods

clone() → {ALMath.Matrix4}

Function clone a matrix.
Source:
Returns:
- A copy of this.
Type
ALMath.Matrix4

divideByScalar(n) → {ALMath.Vector4}

Function to divide by scalar n.
Parameters:
Name Type Description
n number Scalar to divide.
Source:
Throws:
Division by zero.
Returns:
- this that is the division between this and scalar n.
Type
ALMath.Vector4

equals() → {boolean}

Function compare two matrices.
Source:
Returns:
- true if this and v are equals, false otherwise.
Type
boolean

getInverse() → {ALMath.Matrix4}

Function to compute matrix inverse.
Source:
Returns:
- this that is the invert matrix.
Type
ALMath.Matrix4

getNormalMatrix() → {ALMath.Matrix4}

Function to get a matrix that can be used to transform normals on the shaders.
Source:
Returns:
- Matrix that can be used in the shader to transform normals.
Type
ALMath.Matrix4

identity() → {ALMath.Matrix4}

Function to set this matrix to the identity matrix.
Source:
Returns:
Identity Matrix.
Type
ALMath.Matrix4

lookAt() → {ALMath.Matrix4}

Function to create a lookAt matrix.
Source:
Returns:
- A lookAt matrix.
Type
ALMath.Matrix4

multiplyByScalar(n) → {ALMath.Matrix4}

Function to multiply by scalar n.
Parameters:
Name Type Description
n number Scalar to multiply.
Source:
Returns:
- this that is the multiplication between this and scalar n.
Type
ALMath.Matrix4

multiplyByVector(v) → {ALMath.Vector3}

Function to multiply by vector v.
Parameters:
Name Type Description
v ALMath.Vector3 Vector to multiply.
Source:
Returns:
- A new vector which is the multiplication between the matrix this and the vector v.
Type
ALMath.Vector3

multiplyByVector4(v) → {ALMath.Vector4}

Function to multiply by vector v.
Parameters:
Name Type Description
v ALMath.Vector4 Vector to multiply.
Source:
Returns:
- A new vector which is the multiplication between the matrix this and the vector v.
Type
ALMath.Vector4

orthographicProjection() → {ALMath.Matrix4}

Function to create a orthographic projection matrix.
Source:
Returns:
- A orthographic projection matrix.
Type
ALMath.Matrix4

perspectiveProjection() → {ALMath.Matrix4}

Function to create a perspective projection matrix.
Source:
Returns:
- A perspective projection matrix.
Type
ALMath.Matrix4

rotate(x, y, z) → {ALMath.Matrix4}

Function to create a rotation matrix on (X,Y,Z) axis.
Parameters:
Name Type Description
x number rotation angle in degrees on X axis.
y number rotation angle in degrees on Y axis.
z number rotation angle in degrees on Z axis.
Source:
Returns:
- A rotation matrix on (X,Y,Z) axis.
Type
ALMath.Matrix4

rotateX(theta) → {ALMath.Matrix4}

Function to create a rotation matrix on X axis.
Parameters:
Name Type Description
theta number rotation angle in degrees on X axis.
Source:
Returns:
- A rotation matrix on X axis.
Type
ALMath.Matrix4

rotateY(theta) → {ALMath.Matrix4}

Function to create a rotation matrix on Y axis.
Parameters:
Name Type Description
theta number rotation angle in degrees on Y axis.
Source:
Returns:
- A rotation matrix on Y axis.
Type
ALMath.Matrix4

rotateZ(theta) → {ALMath.Matrix4}

Function to create a rotation matrix on Z axis.
Parameters:
Name Type Description
theta number rotation angle in degrees on Z axis.
Source:
Returns:
- A rotation matrix on Z axis.
Type
ALMath.Matrix4

scale(x, y, z) → {ALMath.Matrix4}

Function to create a scale matrix.
Parameters:
Name Type Description
x number scale factor on X axis.
y number scale factor on Y axis.
z number scale factor on Z axis.
Source:
Returns:
- A scale matrix.
Type
ALMath.Matrix4

set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44)

Function to set each component. Set the component in row major order.
Parameters:
Name Type Description
n11 number component for row 1 column 1.
n12 number component for row 1 column 2.
n13 number component for row 1 column 3.
n14 number component for row 1 column 4.
n21 number component for row 2 column 1.
n22 number component for row 2 column 2.
n23 number component for row 2 column 3.
n24 number component for row 2 column 4.
n31 number component for row 3 column 1.
n32 number component for row 3 column 2.
n33 number component for row 3 column 3.
n34 number component for row 3 column 4.
n41 number component for row 4 column 1.
n42 number component for row 4 column 2.
n43 number component for row 4 column 3.
n44 number component for row 4 column 4.
Source:

transformPoint(v) → {ALMath.Vector4}

Function to transform a vector v by matrix this. The difference between transformPoint and multiplyByVector is that transformPoint do the perspective division
Parameters:
Name Type Description
v ALMath.Vector4 Vector to multiply.
Source:
Returns:
- A new vector which is the multiplication between the matrix this and the vector v.
Type
ALMath.Vector4

translate(x, y, z) → {ALMath.Matrix4}

Function to create a translation matrix.
Parameters:
Name Type Description
x number X component of translation matrix.
y number Y component of translation matrix.
z number Z component of translation matrix.
Source:
Returns:
- A translation matrix.
Type
ALMath.Matrix4

transpose() → {ALMath.Matrix4}

Function to transpose matrix.
Source:
Returns:
- this that is the transpose matrix.
Type
ALMath.Matrix4