V8 Javascript API

RS.Math.Matrix4x4 Class Reference

[Math]

Description

A 4x4 componenet Matrix.

Constructor

 Matrix4x4( undefined matrix)
If matrix is not supplied defaults to the identity matrix. More...

Functions

 clear()
Clear this matrix by setting all elements to 0.
Matrix4x4 clone()
Returns a copy of this matrix. More...
 equal( Matrix4x4 rhs, Boolean use_tolerance)
Returns true if this matrix and rhs are equal. More...
Boolean equal_with_tolerance( com.​mi.​rs.​types.​Matrix4x4 lhs, com.​mi.​rs.​types.​Matrix4x4 rhs, Number tolerance)
Compares two matrices to see if they are roughly equal. More...
Number get_determinant()
The matrix determinant. More...
Matrix4x4 invert()
Sets this matrix to its inverse. More...
Matrix4x4 multiply( Matrix4x4 matrix)
Multiples this matrix by matrix. More...
 set( Object rhs)
Sets this matrix from an object. More...
 set_identity()
Sets this matrix to the identity matrix.
 set_rotation( Vector4 axis, Number angle)
Sets this matrix to a rotation matrix. More...
 set_scaling( Number x, Number y, Number z)
Sets this matrix to a scaling matrix. More...
 set_translation( Number x, Number y, Number z)
Sets the translation elements of this matrix while leaving the rest of the matrix untouched. More...
String toString()
Returns a string describing this Object. More...
 translate( Number dx, Number dy, Number dz)
Increases the translation elements of this matrix while leaving the rest of the matrix untouched. More...
Matrix transpose()
Sets this matrix to it's transpose. More...

Constructor

RS.​Math.​Matrix4x4( undefined matrix)

If matrix is not supplied defaults to the identity matrix.

Functions

RS.​Math.​Matrix4x4.clear()

Clear this matrix by setting all elements to 0.

Matrix4x4 RS.​Math.​Matrix4x4.clone()

Returns a copy of this matrix.

Returns

A clonse of this matrix

RS.​Math.​Matrix4x4.equal( Matrix4x4 rhs, Boolean use_tolerance)

Returns true if this matrix and rhs are equal. If use tolerance is true then small differences because of for instance rounding errors are still regarded as equal.

Parameters

rhs
use_tolerance
Boolean RS.​Math.​Matrix4x4.equal_with_tolerance( com.​mi.​rs.​types.​Matrix4x4 lhs, com.​mi.​rs.​types.​Matrix4x4 rhs, Number tolerance)

Compares two matrices to see if they are roughly equal. Useful when comparing two matrices to see if they are equal in a more practical sense than just comparing floating point numbers that might be different only because of rounding errors etc.

Parameters

lhs
rhs
tolerance

Returns

True if lhs and rhs are roughly equal.

Number RS.​Math.​Matrix4x4.get_determinant()

The matrix determinant.

Returns

The determinant.

Matrix4x4 RS.​Math.​Matrix4x4.invert()

Sets this matrix to its inverse. Throws if the determinant is zero. Note that you will likely need to transpose the inverted matrix to keep it in row major form which is what RealityServer expects.

Returns

this

Matrix4x4 RS.​Math.​Matrix4x4.multiply( Matrix4x4 matrix)

Multiples this matrix by matrix.

Parameters

matrix
The matrix on the left hand side of the multiplication

Returns

this

RS.​Math.​Matrix4x4.set( Object rhs)

Sets this matrix from an object. Arguments can be any of:

An array. The array must have 16 elements in the following order: [xx,xy,xz,xw,yx,yy,yz,yw,zx,zy,zz,zw,wx,wy,wz,ww] or 4 array elements specifying the rows of the array.

An Object. The object must have the interface defined by the RealityServer type Float64<4,4> meaning it must have 16 members of type Number called xx, xy, xz, ..., wy, wz, ww.

16 Numbers. Specifies the matrix elements in row major order.

1 Number. Sets the diagonal values on the array, all other elements are set to 0.

Parameters

rhs
The object to set this from. May be one of the following:
  • Object
  • Array
  • Matrix4x4
RS.​Math.​Matrix4x4.set_identity()

Sets this matrix to the identity matrix.

RS.​Math.​Matrix4x4.set_rotation( Vector4 axis, Number angle)

Sets this matrix to a rotation matrix.

Parameters

axis
The vector to rotate around.
angle
The angle to rotate in radians.
RS.​Math.​Matrix4x4.set_scaling( Number x, Number y, Number z)

Sets this matrix to a scaling matrix.

Parameters

x
The amount to scale in the x axis.
y
The amount to scale in the y axis.
z
The amount to scale in the z axis.
RS.​Math.​Matrix4x4.set_translation( Number x, Number y, Number z)

Sets the translation elements of this matrix while leaving the rest of the matrix untouched.

Parameters

x
y
z
String RS.​Math.​Matrix4x4.toString()

Returns a string describing this Object.

Returns

A String describing this Object.

RS.​Math.​Matrix4x4.translate( Number dx, Number dy, Number dz)

Increases the translation elements of this matrix while leaving the rest of the matrix untouched.

Parameters

dx
dy
dz
Matrix RS.​Math.​Matrix4x4.transpose()

Sets this matrix to it's transpose.

Returns

4x4 this