Coppercube API Documentation
Class Matrix4
A 4x4 matrix, mostly used as transformation matrix for 3d calculations.
Class Overview
Matrix4(bMakeIdentity)
A 4x4 matrix. Mostly used as transformation matrix for 3d calculations.
The matrix is a D3D style matrix, row major with translations in the 4th row.
- Parameters:
- bMakeIdentity
- {Boolean} If set to true, the matrix will initially have stored the identity matrix.
Method Attributes | Method Name and Description |
---|---|
asArray()
Returns the content of this matrix as array
|
|
buildCameraLookAtMatrixLH(position, target, upVector)
Builds a left-handed look-at matrix.
|
|
buildProjectionMatrixPerspectiveFovLH(fieldOfViewRadians, aspectRatio, zNear, zFar)
Builds a left-handed perspective projection matrix based on a field of view.
|
|
clone()
Creates a clone of this matrix
|
|
copyTo(mat)
Copies the content of this matrix to a target matrix
|
|
equals(mat)
Returns if this matrix equals another matrix, uses Core.equals as comparison operator.
|
|
getInverse(out)
Copies the inverse of this matrix into the output matrix, returns true succcessful.
|
|
Returns a new vector, rotated from the input vector by this matrix
|
|
Returns the rotation, as set by setRotation().
|
|
getScale()
Returns the scle stored in the matrix as 3d vector
|
|
returns a new transformed vector from the input vector
|
|
Translates a input vector by this matrix and returns it as new vector.
|
|
Returns the translation stored in the matrix as 3d vector
|
|
Returns if this matrix is the identity matrix
|
|
returns if only the translation is set in the matrix
|
|
Makes this matrix the identitiy matrix
|
|
Inverts this matrix, returns true if successful
|
|
multiply(m2)
Multiplies this matrix with another matrix, returns the result as a new matrix.
|
|
Multiplies this matrix with a 4D Vector (expects components X, Y, Z and W), result is stored in the input vector
|
|
rotateVect(v)
Rotates a 3d vector by this matrix.
|
|
rotateVect2(out, inp)
Rotates an input vector and stores the result in the output paramter
|
|
setByIndex(i, n)
Sets a value of the matrix by index
|
|
Make a rotation matrix from Euler angles.
|
|
setRotationRadians(rotation)
Make a rotation matrix from Euler angles.
|
|
setScale(v)
Sets the scale of the matrix
|
|
setScaleXYZ(x, y, z)
Sets the scale of the matrix
|
|
Set the translation of the current matrix.
|
|
transformBoxEx(box)
Transforms a 3d box
|
|
transformPlane(plane)
Transforms a 3d plane by this matrix
|
|
Transforms the input vector by this matrix
|
|
transformVect2(out, inp)
Transforms the input vector by this matrix and stores the result in the ouput parameter
|
|
Translates a vector by this matrix
|
Method Detail
{Array}
asArray()
Returns the content of this matrix as array
- Returns:
- {Array} array of this matrix.
buildCameraLookAtMatrixLH(position, target, upVector)
Builds a left-handed look-at matrix.
- Parameters:
- position
- target
- upVector
buildProjectionMatrixPerspectiveFovLH(fieldOfViewRadians, aspectRatio, zNear, zFar)
Builds a left-handed perspective projection matrix based on a field of view.
- Parameters:
- fieldOfViewRadians
- aspectRatio
- zNear
- zFar
clone()
Creates a clone of this matrix
copyTo(mat)
Copies the content of this matrix to a target matrix
- Parameters:
- mat
equals(mat)
Returns if this matrix equals another matrix, uses Core.equals as comparison operator.
- Parameters:
- mat
getInverse(out)
Copies the inverse of this matrix into the output matrix, returns true succcessful.
- Parameters:
- out
getRotatedVect(v)
Returns a new vector, rotated from the input vector by this matrix
- Parameters:
- v
{Vect3d}
getRotationDegrees()
Returns the rotation, as set by setRotation().
Returns a rotation that is equivalent to that set by setRotationDegrees().
- Returns:
- {Vect3d} rotation vector
{Vect3d}
getScale()
Returns the scle stored in the matrix as 3d vector
- Returns:
- {Vect3d} scale vector
getTransformedVect(v)
returns a new transformed vector from the input vector
- Parameters:
- v
getTranslatedVect(v)
Translates a input vector by this matrix and returns it as new vector.
- Parameters:
- v
{Vect3d}
getTranslation()
Returns the translation stored in the matrix as 3d vector
- Returns:
- {Vect3d} translation vector
isIdentity()
Returns if this matrix is the identity matrix
isTranslateOnly()
returns if only the translation is set in the matrix
makeIdentity()
Makes this matrix the identitiy matrix
makeInverse()
Inverts this matrix, returns true if successful
multiply(m2)
Multiplies this matrix with another matrix, returns the result as a new matrix.
- Parameters:
- m2
multiplyWith1x4Matrix(v)
Multiplies this matrix with a 4D Vector (expects components X, Y, Z and W), result is stored in the input vector
- Parameters:
- v
rotateVect(v)
Rotates a 3d vector by this matrix.
- Parameters:
- v
rotateVect2(out, inp)
Rotates an input vector and stores the result in the output paramter
- Parameters:
- out
- inp
setByIndex(i, n)
Sets a value of the matrix by index
- Parameters:
- i
- Index in the matrix, a value between 0 and 15
- n
- Value to set
setRotationDegrees(v)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
- Parameters:
- v
- {Vect3d} rotation vector
setRotationRadians(rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
- Parameters:
- rotation
- {Vect3d} rotation vector
setScale(v)
Sets the scale of the matrix
- Parameters:
- v
- {Vect3d} translation vector
setScaleXYZ(x, y, z)
Sets the scale of the matrix
- Parameters:
- x
- y
- z
setTranslation(v)
Set the translation of the current matrix. Will erase any previous values.
- Parameters:
- v
- {Vect3d} translation vector
transformBoxEx(box)
Transforms a 3d box
- Parameters:
- box
- {Box3d}
transformPlane(plane)
Transforms a 3d plane by this matrix
- Parameters:
- plane
transformVect(v)
Transforms the input vector by this matrix
- Parameters:
- v
transformVect2(out, inp)
Transforms the input vector by this matrix and stores the result in the ouput parameter
- Parameters:
- out
- inp
translateVect(v)
Translates a vector by this matrix
- Parameters:
- v