Represents a 4x4 matrix. The elements are stored in a Float32Array
in column-major order to optimise handoff to WebGL.
Name | Description |
---|---|
Matrix4
|
Constructs a new 4x4 matrix. |
Name | Description |
---|---|
elements
|
The matrix elements. |
Name | Description |
---|---|
clone
|
Duplicates the current Matrix4 instance. |
createFromAxisAngle
|
static
Creates a matrix that can be used to rotate vectors around an arbitrary axis. |
createIdentity
|
static
Creates an identity matrix. |
createOrthographicOffCenter
|
static
Creates an orthographic projection matrix. |
createRotationX
|
static
Creates a matrix that can be used to rotate vectors around the x-axis. |
createRotationY
|
static
Creates a matrix that can be used to rotate vectors around the y-axis. |
createRotationZ
|
static
Creates a matrix that can be used to rotate vectors around the z-axis. |
createScale
|
static
Creates a scaling matrix. |
createTranslation
|
static
Creates a matrix that can be used to translate vectors. |
createUniformScale
|
static
Creates a uniform scaling matrix. |
decompose
|
Extracts the scale, rotation, and translation components of the current Matrix4 instance. Assumes this is a transform matrix. |
determinant
|
Calculates the determinant of the current Matrix4 instance. |
getTranslation
|
Gets the translation component of the current transformation matrix. |
invert
|
static
Inverts a matrix. If the determinant is zero, then the matrix cannot be inverted and an exception will be thrown. |
multiply
|
static
Multiplies a matrix by another matrix. |
multiplyByScalar
|
static
Multiplies a matrix by a scalar value. |
setTranslation
|
Sets the translation component of the current transformation matrix. |
transpose
|
static
Transposes a matrix. |
new Zia.Matrix4
(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)
constructor
Constructs a new 4x4 matrix. Parameters are supplied in row-major order to aid readability. If called with no parameters, all matrix elements are initialised to 0. If called with any parameters, make sure you supply all 16 values.
Name | Type | Description |
---|---|---|
m11 |
Number |
optional
The value for row 0, column 0. Defaults to0.0 .
|
m12 |
Number |
optional
The value for row 0, column 1. Defaults to0.0 .
|
m13 |
Number |
optional
The value for row 0, column 2. Defaults to0.0 .
|
m14 |
Number |
optional
The value for row 0, column 3. Defaults to0.0 .
|
m21 |
Number |
optional
The value for row 1, column 0. Defaults to0.0 .
|
m22 |
Number |
optional
The value for row 1, column 1. Defaults to0.0 .
|
m23 |
Number |
optional
The value for row 1, column 2. Defaults to0.0 .
|
m24 |
Number |
optional
The value for row 1, column 3. Defaults to0.0 .
|
m31 |
Number |
optional
The value for row 2, column 0. Defaults to0.0 .
|
m32 |
Number |
optional
The value for row 2, column 1. Defaults to0.0 .
|
m33 |
Number |
optional
The value for row 2, column 2. Defaults to0.0 .
|
m34 |
Number |
optional
The value for row 2, column 3. Defaults to0.0 .
|
m41 |
Number |
optional
The value for row 3, column 0. Defaults to0.0 .
|
m42 |
Number |
optional
The value for row 3, column 1. Defaults to0.0 .
|
m43 |
Number |
optional
The value for row 3, column 2. Defaults to0.0 .
|
m44 |
Number |
optional
The value for row 3, column 3. Defaults to0.0 .
|
The matrix elements.
Duplicates the current Matrix4 instance.
Name | Type | Description |
---|---|---|
result |
Zia.Matrix4 |
The object in which to store the result. |
The modified result parameter.
Creates a matrix that can be used to rotate vectors around an arbitrary axis.
Name | Type | Description |
---|---|---|
axis |
Zia.Vector3 |
The axis to rotate around. |
angle |
Number |
The amount, in radians, by which to rotate around the vector. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createFromAxisAngle(
new Zia.Vector3(1, 0, 1).normalize(), Math.PI,
new Zia.Matrix4());
Creates an identity matrix.
Name | Type | Description |
---|---|---|
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createIdentity(new Zia.Matrix4());
createOrthographicOffCenter
(left, right, bottom, top, near, far, result)
→ Zia.Matrix4
method
static
Creates an orthographic projection matrix.
Name | Type | Description |
---|---|---|
left |
Number |
The minimum x value of the view volume. |
right |
Number |
The maximum x value of the view volume. |
bottom |
Number |
The minimum y value of the view volume. |
top |
Number |
The maximum y value of the view volume. |
near |
Number |
The minimum z value of the view volume. |
far |
Number |
The maximum z value of the view volume. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createOrthographicOffCenter(
-100, 100, -40, 40, -100, 100,
new Zia.Matrix4());
Creates a matrix that can be used to rotate vectors around the x-axis.
Name | Type | Description |
---|---|---|
angle |
Number |
The amount, in radians, by which to rotate around the x-axis. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createRotationX(Math.PI, new Zia.Matrix4());
Creates a matrix that can be used to rotate vectors around the y-axis.
Name | Type | Description |
---|---|---|
angle |
Number |
The amount, in radians, by which to rotate around the y-axis. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createRotationY(Math.PI, new Zia.Matrix4());
Creates a matrix that can be used to rotate vectors around the z-axis.
Name | Type | Description |
---|---|---|
angle |
Number |
The amount, in radians, by which to rotate around the z-axis. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createRotationZ(Math.PI, new Zia.Matrix4());
Creates a scaling matrix.
Name | Type | Description |
---|---|---|
scale |
Zia.Vector3 |
Amounts to scale by on the x, y and z axes. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createScale(
new Zia.Vector3(1.5, 1, 2),
new Zia.Matrix4());
Creates a matrix that can be used to translate vectors.
Name | Type | Description |
---|---|---|
translation |
Zia.Vector3 |
Amounts to translate by on the x, y and z axes. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createTranslation(
new Zia.Vector3(1, 2, -5),
new Zia.Matrix4());
Creates a uniform scaling matrix.
Name | Type | Description |
---|---|---|
scale |
Number |
Amount to scale by on all axes. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.createUniformScale(2, new Zia.Matrix4());
Extracts the scale, rotation, and translation components of the current Matrix4 instance. Assumes this is a transform matrix.
Name | Type | Description |
---|---|---|
scale |
Zia.Vector3 |
The scale component of the transform matrix. |
rotation |
Zia.Quaternion |
The rotation component of the transform matrix. |
translation |
Zia.Vector3 |
The translation component of the transform matrix. |
Boolean
-
True if the matrix can be decomposed, otherwise false.
Calculates the determinant of the current Matrix4 instance.
Number
-
The determinant.
Gets the translation component of the current transformation matrix.
Inverts a matrix. If the determinant is zero, then the matrix cannot be inverted and an exception will be thrown.
Name | Type | Description |
---|---|---|
matrix |
Zia.Matrix4 |
The matrix to invert. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.invert(
Zia.Matrix4.createUniformScale(2, new Zia.Matrix4()),
new Zia.Matrix4());
Multiplies a matrix by another matrix.
Name | Type | Description |
---|---|---|
left |
Zia.Matrix4 |
The first matrix. |
right |
Zia.Matrix4 |
The second matrix. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.multiply(
Zia.Matrix4.createUniformScale(2, new Zia.Matrix4()),
Zia.Matrix4.createRotationX(Math.PI, new Zia.Matrix4(),
new Zia.Matrix4());
Multiplies a matrix by a scalar value.
Name | Type | Description |
---|---|---|
matrix |
Zia.Matrix4 |
The matrix. |
scalar |
Number |
The scalar value. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.multiplyByScalar(
Zia.Matrix4.createUniformScale(2, new Zia.Matrix4()), 0.5,
new Zia.Matrix4());
Sets the translation component of the current transformation matrix.
Transposes a matrix.
Name | Type | Description |
---|---|---|
matrix |
Zia.Matrix4 |
The matrix to transpose. |
result |
Zia.Matrix4 |
The object in which to place the calculated result. |
The modified result parameter.
var result = Zia.Matrix4.transpose(
Zia.Matrix4.createRotationX(Math.PI, new Zia.Matrix4()),
new Zia.Matrix4());