Class: SFMatrix4f

x3dom.fields. SFMatrix4f

Represents a 4x4 matrix in row major format.

Inheritance

  • SFMatrix4f

Constructor

SFMatrix4f(_00, _01, _02, _03, _10, _11, _12, _13, _20, _21, _22, _23, _30, _31, _32, _33)

Constructor. You must either specify all argument values or no argument. In the latter case, an identity matrix will be created.

Parameters:
Name Type Argument Default Description
_00 Number <optional>
1 value at [0,0]
_01 Number <optional>
0 value at [0,1]
_02 Number <optional>
0 value at [0,2]
_03 Number <optional>
0 value at [0,3]
_10 Number <optional>
0 value at [1,0]
_11 Number <optional>
1 value at [1,1]
_12 Number <optional>
0 value at [1,2]
_13 Number <optional>
0 value at [1,3]
_20 Number <optional>
0 value at [2,0]
_21 Number <optional>
0 value at [2,1]
_22 Number <optional>
1 value at [2,2]
_23 Number <optional>
0 value at [2,3]
_30 Number <optional>
0 value at [3,0]
_31 Number <optional>
0 value at [3,1]
_32 Number <optional>
0 value at [3,2]
_33 Number <optional>
1 value at [3,3]


Methods

<static> copy(that) → {x3dom.fields.SFMatrix4f}

Returns a copy of the argument matrix.

Parameters:
Name Type Description
that x3dom.fields.SFMatrix4f the matrix to copy

Returns:
the copy

<static> identity() → {x3dom.fields.SFMatrix4f}

Returns a SFMatrix4f identity matrix.

Returns:
the new identity matrix

<static> lookAt(from, at, up) → {x3dom.fields.SFMatrix4f}

Returns a new camera matrix, using the given "look at" parameters.

Parameters:
Name Type Description
from x3dom.fields.SFVec3f eye point
at x3dom.fields.SFVec3f focus ("look at") point
up x3dom.fields.SFVec3f up vector

Returns:
the new camera matrix

<static> ortho(left, right, bottom, top, near, far, aspect) → {x3dom.fields.SFMatrix4f}

Returns a new orthogonal projection matrix.

Parameters:
Name Type Argument Default Description
left Number left border value of the view area
right Number right border value of the view area
bottom Number bottom border value of the view area
top Number top border value of the view area
near Number near clipping distance
far Number far clipping distance
aspect Number <optional>
1.0 desired aspect ratio (width / height) of the projected image

Returns:
the new projection matrix

<static> parse(str) → {x3dom.fields.SFMatrix4f}

Creates a new matrix from a X3D-conformant string representation

Parameters:
Name Type Description
str String string to parse

Returns:
the new rotation matrix

<static> parseRotation(str) → {x3dom.fields.SFMatrix4f}

Creates a new matrix from a column major string representation, with values separated by commas

Parameters:
Name Type Description
str String string to parse

Returns:
the new matrix

<static> perspective(fov, aspect, near, far) → {x3dom.fields.SFMatrix4f}

Returns a new perspective projection matrix.

Parameters:
Name Type Description
fov Number field-of-view angle in radians
aspect Number aspect ratio (width / height)
near Number near clipping distance
far Number far clipping distance

Returns:
the new projection matrix

<static> perspectiveFrustum(left, right, bottom, top, near, far)

Returns a new perspective projection frustum.

Parameters:
Name Type Description
left Number Left
right Number Right
bottom Number Bottom
top Number Top
near Number near clipping distance
far Number far clipping distance

<static> rotationX(a) → {x3dom.fields.SFMatrix4f}

Returns a new rotation matrix , rotating around the x axis.

Parameters:
Name Type Description
a x3dom.fields.SFVec3f angle in radians

Returns:
the new rotation matrix

<static> rotationY(a) → {x3dom.fields.SFMatrix4f}

Returns a new rotation matrix , rotating around the y axis.

Parameters:
Name Type Description
a x3dom.fields.SFVec3f angle in radians

Returns:
the new rotation matrix

<static> rotationZ(a) → {x3dom.fields.SFMatrix4f}

Returns a new rotation matrix , rotating around the z axis.

Parameters:
Name Type Description
a x3dom.fields.SFVec3f angle in radians

Returns:
the new rotation matrix

<static> scale(vec) → {x3dom.fields.SFMatrix4f}

Returns a new scale matrix.

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f vector containing scale factors along the three main axes

Returns:
the new scale matrix

<static> translation(vec) → {x3dom.fields.SFMatrix4f}

Returns a new translation matrix.

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f vector that describes the desired translation

Returns:
the new identity matrix

<static> zeroMatrix() → {x3dom.fields.SFMatrix4f}

Returns a new null matrix.

Returns:
the new null matrix

add(that) → {x3dom.fields.SFMatrix4f}

Returns the result of adding the given matrix to this matrix.

Parameters:
Name Type Description
that x3dom.fields.SFMatrix4f the other matrix

Returns:
resulting matrix

addScaled(that, s) → {x3dom.fields.SFMatrix4f}

Returns the result of adding the given matrix to this matrix using an additional scale factor for the argument matrix.

Parameters:
Name Type Description
that x3dom.fields.SFMatrix4f the other matrix
s Number the scale factor

Returns:
resulting matrix

adjointT_3x3() → {x3dom.fields.SFMatrix4f}

Computes the transposed adjoint of the upper left 3x3 part of this matrix, and stores it in the upper left part of a new 4x4 identity matrix.

Returns:
the resulting matrix

at(i, j) → {Number}

Returns the value of this matrix at a given position.

Parameters:
Name Type Description
i Number row index (starting with 0)
j Number column index (starting with 0)

Returns:
the value

copy() → {x3dom.fields.SFMatrix4f}

Returns a copy of the matrix.

Returns:
the copy

decompose(t, r, s, so) → {Number}

Computes the decomposition of the given 4x4 affine matrix M as M = T F R SO S SO^t, where T is a translation matrix, F is +/- I (a reflection), R is a rotation matrix, SO is a rotation matrix and S is a (nonuniform) scale matrix.

Parameters:
Name Type Description
t x3dom.fields.SFVec3f 3D vector to be filled with the translation values
r x3dom.fields.Quaternion quaternion to be filled with the rotation values
s x3dom.fields.SFVec3f 3D vector to be filled with the scale factors
so x3dom.fields.Quaternion rotation (quaternion) to be applied before scaling

Returns:
signum of determinant of the transposed adjoint upper 3x3 matrix

det() → {Number}

Computes the determinant of this matrix.

Returns:
determinant

det3(a1, a2, a3, b1, b2, b3, c1, c2, c3) → {Number}

Computes a determinant for a 3x3 matrix m, given as values in row major order.

Parameters:
Name Type Description
a1 Number value of m at (0,0)
a2 Number value of m at (0,1)
a3 Number value of m at (0,2)
b1 Number value of m at (1,0)
b2 Number value of m at (1,1)
b3 Number value of m at (1,2)
c1 Number value of m at (2,0)
c2 Number value of m at (2,1)
c3 Number value of m at (2,2)

Returns:
determinant

e0() → {x3dom.fields.SFVec3f}

Returns the first column vector of the matrix.

Returns:
the vector

e1() → {x3dom.fields.SFVec3f}

Returns the second column vector of the matrix.

Returns:
the vector

e2() → {x3dom.fields.SFVec3f}

Returns the third column vector of the matrix.

Returns:
the vector

e3() → {x3dom.fields.SFVec3f}

Returns the fourth column vector of the matrix.

Returns:
the vector

equals(that) → {Boolean}

Checks whether this matrix equals another matrix.

Parameters:
Name Type Description
that x3dom.fields.SFMatrix4f the other matrix

Returns:

exp() → {x3dom.fields.SFMatrix4f}

Computes the exponential of this matrix.

Returns:
exp of matrix

getEulerAngles() → {Number[]}

Returns an array of 2*3 = 6 euler angles (in radians), assuming that this is a rotation matrix. The first three and the second three values are alternatives for the three euler angles, where each of the two cases leads to the same resulting rotation.

Returns:

getTransform(translation, rotation, scaleFactor, scaleOrientation, center)

Decomposes the matrix into a translation, rotation, scale, and scale orientation. Any projection information is discarded. The decomposition depends upon choice of center point for rotation and scaling, which is optional as the last parameter.

Parameters:
Name Type Argument Default Description
translation x3dom.fields.SFVec3f 3D vector to be filled with the translation values
rotation x3dom.fields.Quaternion quaternion to be filled with the rotation values
scaleFactor x3dom.fields.SFVec3f 3D vector to be filled with the scale factors
scaleOrientation x3dom.fields.Quaternion rotation (quaternion) to be applied before scaling
center x3dom.fields.SFVec3f <optional>
undefined center point for rotation and scaling, if not origin

inverse() → {x3dom.fields.SFMatrix4f}

Computes the inverse of this matrix, given that it is not singular.

Returns:

log() → {x3dom.fields.SFMatrix4f}

Computes the logarithm of this matrix, assuming that its determinant is greater than zero.

Returns:
log of matrix

mult(that) → {x3dom.fields.SFMatrix4f}

Returns the result of multiplying this matrix with the given one, using "post-multiplication" / "right multiply".

Parameters:
Name Type Description
that x3dom.fields.SFMatrix4f matrix to multiply with this one

Returns:
resulting matrix

multFullMatrixPnt(vec) → {x3dom.fields.SFVec3f}

Transforms a given 3D point, using this matrix as a transform matrix (also includes projection part of matrix - required for e.g. modelview-projection matrix). The resulting point is normalized by a w component.

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f point to transform

Returns:
resulting point

multiply(s) → {x3dom.fields.SFMatrix4f}

Returns a scaled version of this matrix.

Parameters:
Name Type Description
s Number scale factor

Returns:
resulting matrix

multMatrixPlane(plane) → {x3dom.fields.SFVec4f}

Transforms a given 3D point, using this matrix as a transform matrix (also includes projection part of matrix - required for e.g. modelview-projection matrix). The resulting point is normalized by a w component.

Parameters:
Name Type Description
plane x3dom.fields.SFVec4f plane to transform

Returns:
resulting plane

multMatrixPnt(vec) → {x3dom.fields.SFVec3f}

Transforms a given 3D point, using this matrix as a homogenous transform matrix (ignores projection part of matrix for speedup in standard cases).

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f point to transform

Returns:
resulting point

multMatrixVec(vec) → {x3dom.fields.SFVec3f}

Transforms a given 3D vector, using this matrix as a homogenous transform matrix.

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f vector to transform

Returns:
resulting vector

negate() → {x3dom.fields.SFMatrix4f}

Returns a negated version of this matrix.

Returns:
resulting matrix

norm1_3x3() → {Number}

Returns the 1-norm of the upper left 3x3 part of this matrix. The 1-norm is also known as maximum absolute column sum norm.

Returns:
the resulting number

normInf_3x3() → {Number}

Returns the infinity-norm of the upper left 3x3 part of this matrix. The infinity-norm is also known as maximum absolute row sum norm.

Returns:
the resulting number

normInfinity() → {Number}

Returns the largest absolute value of all entries in the matrix. This is only a helper for calculating log and not the usual Infinity-norm for matrices.

Returns:
the largest absolute value

polarDecompose(Q, S) → {Number}

Performs a polar decomposition of this matrix A into two matrices Q and S, so that A = QS

Parameters:
Name Type Description
Q x3dom.fields.SFMatrix4f first resulting matrix
S x3dom.fields.SFMatrix4f first resulting matrix

Returns:
determinant of the transposed adjoint upper 3x3 matrix

setFromArray(a)

Fills the values of this matrix, using the given array.

Parameters:
Name Type Description
a Number[] array, the first 16 values will be used to initialize the matrix

setRotate(quat)

Sets the rotation components of a homogenous transform matrix.

Parameters:
Name Type Description
quat x3dom.fields.Quaternion quaternion that describes the rotation

setScale(vec)

Sets the scale components of a homogenous transform matrix.

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f vector containing scale factors along the three main axes

setTranslate(vec)

Sets the translation components of a homogenous transform matrix.

Parameters:
Name Type Description
vec x3dom.fields.SFVec3f the translation vector

setValue(v1, v2, v3, v4)

Fills the upper left 3x3 or 3x4 values of this matrix, using the given (three or four) column vectors.

Parameters:
Name Type Argument Default Description
v1 x3dom.fields.SFVec3f first column vector
v2 x3dom.fields.SFVec3f second column vector
v3 x3dom.fields.SFVec3f third column vector
v4 x3dom.fields.SFVec3f <optional>
undefined fourth column vector

setValueByStr(str)

Fills the values of this matrix from a string, where the entries are separated by commas and given in column-major order.

Parameters:
Name Type Description
str String the string representation

setValues(that)

Fills the values of this matrix with the values of the other one.

Parameters:
Name Type Description
that x3dom.fields.SFMatrix4f the other matrix

spectralDecompose(SO, k)

Performs a spectral decomposition of this matrix.

Parameters:
Name Type Description
SO x3dom.fields.SFMatrix4f resulting matrix
k x3dom.fields.SFVec3f resulting vector

sqrt() → {SFMatrix4f}

Computes the square root of the matrix, assuming that its determinant is greater than zero.

Returns:
a matrix containing the result

toGL() → {Number[]}

Returns a column major version of this matrix, packed into a single array.

Returns:
resulting array of 16 values

toString() → {String}

Converts this matrix to a string representation, where all entries are separated by commas, and where rows are additionally separated by linebreaks.

Returns:

transpose() → {x3dom.fields.SFMatrix4f}

Returns a transposed version of this matrix.

Returns:
resulting matrix