# 17.6. The MathDevice Object¶

Provides optimized vector and matrix operations.

Compatibility with JavaScript arrays (returned by VMath function calls and JSON.parse)

The MathDevice functions are not compatible with JavaScript arrays this includes the result of VMath functions. To convert between VMath and MathDevice objects see MathDeviceConvert.

Optional destination parameter

Most of the functions on the MathDevice which return a MathDevice object have an optional destination parameter. This optional last parameter specifies the MathDevice object to copy the result into. This functionality is useful to avoid the memory allocation of a new vector. For example, the following code will require memory for 3 Vector3 objects:

var vectorA = mathDevice.v3Build(1, 2, 3);
var vectorB = mathDevice.v3Build(4, 5, 6);

Later on the JavaScript VM will have to garbage collect the unreferenced Vector3 memory costing valuable time. However taking advantage of the destination parameter, the following code will require memory for only 2 Vector3 objects:

var vectorA = mathDevice.v3Build(1, 2, 3);
var vectorB = mathDevice.v3Build(4, 5, 6);

This method doesn’t require the JavaScript VM to do any unneeded garbage collection.

The destination can also be null or undefined in which case the destination is ignored and a new MathDevice object is created.

Function caching

When using the MathDevice object is it always best to cache functions when they are called multiple times. For example:

var a, b;
a = mathDevice.v3Build(1, 1, 1);
b = mathDevice.v3Build(1, 2, 3);
for (var i = 0; i < 6; i += 1)
{
mathDevice.v3Mul(a, b, a);
}

Will be slower than:

var a, b;
a = mathDevice.v3Build(1, 1, 1);
b = mathDevice.v3Build(2, 3, 4);
var v3Mul = mathDevice.v3Mul;
for (var i = 0; i < 6; i += 1)
{
v3Mul.call(mathDevice, a, b, a);
}

## 17.6.1. Methods¶

The format for all Math Device function names is lower case type name, e.g. v3, m44 or quat, followed by the operation in camel case. For example:

mathDevice.typeNameFunctionName();
mathDevice.typeNameFunctionNameTypeName();

A preceding type name is given if the second parameters type is not clear. For example, mathDevice.quatFromM43 rather than mathDevice.quatFromMatrix.

The MathDevice uses arrays of single-precision floats for all of its internal objects. On the other hand the JavaScript representation of numbers uses double-precision floats for all of its number objects. Subsequently, there is a loss of precision between JavaScript values and the MathDevice objects to be careful of.

### 17.6.1.1. objectsAreIdentical¶

Summary

Compares two native math device objects and returns true if they are the same object. This method is intended for debugging and validation purposes only.

Syntax

var identical = mathDevice.objectsAreIdentical(v1, v2);

### 17.6.1.2. truncate¶

Summary

Converts the given floating point number into an integer, rounding towards zero.

Syntax

var index = mathDevice.truncate(fraction * tableSize);

### 17.6.1.3. v2Build¶

Summary

Creates a vector with 2 components.

Syntax

var destination = mathDevice.v2Build(a, b, destination);
a, b
A JavaScript number. The components of the vector to build.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.4. v2BuildZero¶

Summary

Creates a vector with 2 components all set to 0.0.

Syntax

var position = mathDevice.v2BuildZero(destination);

destination (Optional)

Returns a Vector2 object.

### 17.6.1.5. v2BuildOne¶

Summary

Creates a vector with 2 components all set to 1.0.

Syntax

var position = mathDevice.v2BuildOne(destination);

destination (Optional)

Returns a Vector2 object.

### 17.6.1.6. v2BuildXAxis¶

Summary

Creates a vector with 2 components set to [1.0, 0.0].

Syntax

var position = mathDevice.v2BuildXAxis(destination);

destination (Optional)

Returns a Vector2 object.

### 17.6.1.7. v2BuildYAxis¶

Summary

Creates a vector with 2 components set to [0.0, 1.0].

Syntax

var position = mathDevice.v2BuildYAxis(destination);

destination (Optional)

Returns a Vector2 object.

### 17.6.1.8. v2Copy¶

Summary

Returns a 2 component vector copy of the given vector.

Syntax

var source = mathDevice.v2Build(0, 20);
var destination = mathDevice.v2Copy(source, destination);
source
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.9. v2Abs¶

Summary

Returns a 2 component vector initialized to the component-wise absolute of the vector parameter given.

Syntax

var vector = mathDevice.v2Build(-4, 10);
destination = mathDevice.v2Abs(vector, destination);
vectorA
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.10. v2Equal¶

Summary

Returns a boolean specifying whether the two 2 component vectors are equal. Optional third parameter specifies the precision of the comparison with a default of 1E-06.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(2.00049, 0);
var equal = mathDevice.v2Equal(vectorA, vectorB, scalar);
vectorA, vectorB
A Vector2 object.
scalar (Optional)
A JavaScript number.

### 17.6.1.11. v2Neg¶

Summary

Returns a 2 component vector initialized to the component-wise negation of a given vector.

Syntax

var vector = mathDevice.v2Build(0, 20);
destination = mathDevice.v2Neg(vector, destination);
vector
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.12. v2Reciprocal¶

Summary

Returns a 2 component vector initialized to the component-wise reciprocal of a given vector.

Syntax

var vector = mathDevice.v2Build(0.5, 5);
destination = mathDevice.v2Reciprocal(vector, destination);
vector
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

If any of the components is zero this will cause an “Error calling method on NPObject” JavaScript error.

Summary

Returns a 2 component vector initialized to the component-wise addition of two other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
vectorA, vectorB
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

Summary

Returns a 2 component vector initialized to the component-wise addition of 2 other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
var vectorC = mathDevice.v2Build(1, 2);
destination = mathDevice.v2Add2(vectorA, vectorB, vectorC, destination);
vectorA, vectorB, vectorC
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

Summary

Returns a 2 component vector initialized to the component-wise addition of 4 other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
var vectorC = mathDevice.v2Build(1, 2);
var vectorD = mathDevice.v2Build(4, 6);
destination = mathDevice.v2Add4(vectorA, vectorB, vectorC, vectorD, destination);
vectorA, vectorB, vectorC, vectorD
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.16. v2Sub¶

Summary

Returns a 2 component vector initialized to the component-wise subtraction of two other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
destination = mathDevice.v2Sub(vectorA, vectorB, destination);
vectorA, vectorB
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.17. v2Mul¶

Summary

Returns a 2 component vector initialized to the component-wise multiplication of two other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
destination = mathDevice.v2Mul(vectorA, vectorB, destination);
vectorA, vectorB
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.18. v2Min¶

Summary

Returns a 2 component vector initialized to the component-wise minimum of two other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
destination = mathDevice.v2Min(vectorA, vectorB, destination);
vectorA, vectorB
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.19. v2Max¶

Summary

Returns a 2 component vector initialized to the component-wise maximum of two other vectors.

Syntax

var vectorA = mathDevice.v2Build(2, 0);
var vectorB = mathDevice.v2Build(7, 4);
destination = mathDevice.v2Max(vectorA, vectorB, destination);
vectorA, vectorB
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.20. v2Dot¶

Summary

Returns the scalar dot product of two 2 component vectors.

Syntax

var cosAngle = mathDevice.v2Dot(vectorA, vectorB);
vectorA, vectorB
A Vector2 object.

Returns a JavaScript number.

### 17.6.1.21. v2PerpDot¶

Summary

Returns the scalar perp-dot product of two 2 component vectors.

Syntax

var sinAngle = mathDevice.v2PerpDot(vectorA, vectorB);
vectorA, vectorB
A Vector2 object.

Returns a JavaScript number.

### 17.6.1.22. v2Normalize¶

Summary

Returns a 2 component vector initialized to the normalized value of another 2 component vector.

Syntax

var vector = mathDevice.v2Build(2, 6);
destination = mathDevice.v2Normalize(vector, destination);
vector
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.23. v2LengthSq¶

Summary

Returns the scalar squared length of a given 2 component vector.

Syntax

var vectorLengthSq = mathDevice.v2LengthSq(vector);

//example usage:
if (1.0 !== vectorLengthSq)
{
normal = mathDevice.v2ScalarMul(vector, (1.0 / Math.sqrt(vectorLengthSq)));
}

Returns a JavaScript number.

vector
A Vector2 object.

### 17.6.1.24. v2Length¶

Summary

Returns the scalar length of a given 2 component vector.

Syntax

var vectorLength = mathDevice.v2Length(vector);

//example usage:
if (1.0 !== vectorLength)
{
vector = mathDevice.v2ScalarMul(vector, (1.0 / vectorLength));
}
vector
A Vector2 object.

Returns a JavaScript number.

Summary

Returns a 2 component vector initialized to the addition of the third argument with the multiplication of the first two arguments.

Syntax

var vectorMulA = mathDevice.v2Build(2, 2);
var vectorMulB = mathDevice.v2Build(0, 7);

//example usage:
var newPos = mathDevice.v2MulAdd(velocity, deltaTime, pos);
A Vector2 object.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.26. v2ScalarBuild¶

Summary

Creates a vector with 2 components all set to the scalar argument provided.

Syntax

var destination = mathDevice.v2ScalarBuild(100, destination);

destination (Optional)

Returns a Vector2 object.

Summary

Returns a 2 component vector initialized to the addition of the first vector parameter to the second scalar one.

Syntax

//example usage:
vector
A Vector2 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.28. v2ScalarSub¶

Summary

Returns a 2 component vector initialized to the subtraction of the first vector parameter to the second scalar one.

Syntax

destination = mathDevice.v2ScalarSub(vector, scalar, destination);

//example usage:
nodeMinExtent = mathDevice.v2ScalarSub(nodeMinExtent, 0.1);
vector
A Vector2 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.29. v2ScalarMul¶

Summary

Returns a 2 component vector initialized to the multiplication of the first vector parameter to the second scalar one.

Syntax

destination = mathDevice.v2ScalarMul(vector, scalar, destination);

//example usage:
vector
A Vector2 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector2 object.

Summary

Returns a 2 component vector initialized to the sum of the first vector with the multiplication of the second vector parameter by the third scalar one.

Syntax

newPosition = mathDevice.v2AddScalarMul(position, velocity, time, newPosition);
position
A Vector2 object.
velocity
A Vector2 object.
time
A JavaScript number.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.31. v2Lerp¶

Summary

Returns a 2 component vector initialized to the linear interpolation between the first and second vector parameters using the delta passed as the third parameter.

Syntax

var vectorA = mathDevice.v2Build(10, 20);
var vectorB = mathDevice.v2Build(20, 0);
destination = mathDevice.v2Lerp(vectorA, vectorB, scalar, destination);
vectorA, vectorB
A Vector2 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector2 object.

### 17.6.1.32. v2CatmullRom¶

Summary

Returns a 2 component vector initialized to the Catmull Rom interpolation through a set of 4 points.

Syntax

var vectorA = mathDevice.v2Build(10,  0);
var vectorB = mathDevice.v2Build(20,  0);
var vectorC = mathDevice.v2Build(5,  10);
var vectorD = mathDevice.v2Build(10, 10);
destination = mathDevice.v2CatmullRom(t, tension, vectorA, vectorB, vectorC, vectorD, destination);
vectorA, vectorB, vectorC, vectorD
A Vector2 object.
t, tension
A JavaScript number.

destination (Optional)

Returns a Vector2 object. The interpolation will be at B with derivative tension * (C - A) for t = 0. The interpolation will be at C with derivative tension * (D - A) for t = 1.

### 17.6.1.33. v3Build¶

Summary

Creates a vector with 3 components.

Syntax

var destination = mathDevice.v3Build(a, b, c, destination);
a, b, c
A JavaScript number. The components of the vector to build.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.34. v3BuildZero¶

Summary

Creates a vector with 3 components all set to 0.0.

Syntax

var position = mathDevice.v3BuildZero(destination);

destination (Optional)

Returns a Vector3 object.

### 17.6.1.35. v3BuildOne¶

Summary

Creates a vector with 3 components all set to 1.0.

Syntax

var position = mathDevice.v3BuildOne(destination);

destination (Optional)

Returns a Vector3 object.

### 17.6.1.36. v3BuildXAxis¶

Summary

Creates a vector with 3 components set to [1.0, 0.0, 0.0].

Syntax

var position = mathDevice.v3BuildXAxis(destination);

destination (Optional)

Returns a Vector3 object.

### 17.6.1.37. v3BuildYAxis¶

Summary

Creates a vector with 3 components set to [0.0, 1.0, 0.0].

Syntax

var position = mathDevice.v3BuildYAxis(destination);

destination (Optional)

Returns a Vector3 object.

### 17.6.1.38. v3BuildZAxis¶

Summary

Creates a vector with 3 components set to [0.0, 0.0, 1.0].

Syntax

var position = mathDevice.v3BuildZAxis(destination);

destination (Optional)

Returns a Vector3 object.

### 17.6.1.39. v3Copy¶

Summary

Returns a 3 component vector copy of the given vector.

Syntax

var source = mathDevice.v3Build(0, 0, 20);
var destination = mathDevice.v3Copy(source, destination);
source
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.40. v3Abs¶

Summary

Returns a 3 component vector initialized to the component-wise absolute of the vector parameter given.

Syntax

var vector = mathDevice.v3Build(-4, 0, 10);
destination = mathDevice.v3Abs(vector, destination);
vectorA
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.41. v3Equal¶

Summary

Returns a boolean specifying whether the two 3 component vectors are equal. Optional third parameter specifies the precision of the comparison with a default of 1E-06.

Syntax

var vectorA = mathDevice.v3Build(0, 2, 0);
var vectorB = mathDevice.v3Build(0, 2.00049, 0);
var equal = mathDevice.v3Equal(vectorA, vectorB, scalar);
vectorA, vectorB
A Vector3 object.
scalar (Optional)
A JavaScript number.

### 17.6.1.42. v3Neg¶

Summary

Returns a 3 component vector initialized to the component-wise negation of a given vector.

Syntax

var vector = mathDevice.v3Build(0, 0, 20);
destination = mathDevice.v3Neg(vector, destination);
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.43. v3Reciprocal¶

Summary

Returns a 3 component vector initialized to the component-wise reciprocal of a given vector.

Syntax

var vector = mathDevice.v3Build(0.5, 5, 1);
destination = mathDevice.v3Reciprocal(vector, destination);
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

If any of the components is zero this will cause an “Error calling method on NPObject” JavaScript error.

Summary

Returns a 3 component vector initialized to the component-wise addition of two other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
vectorA, vectorB
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

Summary

Returns a 3 component vector initialized to the component-wise addition of 3 other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
var vectorC = mathDevice.v3Build(1, 2, 9);
destination = mathDevice.v3Add3(vectorA, vectorB, vectorC, destination);
vectorA, vectorB, vectorC
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

Summary

Returns a 3 component vector initialized to the component-wise addition of 4 other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
var vectorC = mathDevice.v3Build(1, 2, 9);
var vectorD = mathDevice.v3Build(4, 6, 0);
destination = mathDevice.v3Add4(vectorA, vectorB, vectorC, vectorD, destination);
vectorA, vectorB, vectorC, vectorD
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.47. v3Sub¶

Summary

Returns a 3 component vector initialized to the component-wise subtraction of two other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
destination = mathDevice.v3Sub(vectorA, vectorB, destination);
vectorA, vectorB
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.48. v3Mul¶

Summary

Returns a 3 component vector initialized to the component-wise multiplication of two other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
destination = mathDevice.v3Mul(vectorA, vectorB, destination);
vectorA, vectorB
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.49. v3Min¶

Summary

Returns a 3 component vector initialized to the component-wise minimum of two other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
destination = mathDevice.v3Min(vectorA, vectorB, destination);
vectorA, vectorB
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.50. v3Max¶

Summary

Returns a 3 component vector initialized to the component-wise maximum of two other vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
destination = mathDevice.v3Max(vectorA, vectorB, destination);
vectorA, vectorB
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.51. v3Dot¶

Summary

Returns the scalar dot product of two 3 component vectors.

Syntax

var cosAngle = mathDevice.v3Dot(vectorA, vectorB);
vectorA, vectorB
A Vector3 object.

Returns a JavaScript number.

### 17.6.1.52. v3Cross¶

Summary

Returns a 3 component vector initialized to the cross product of two other 3 component vectors.

Syntax

var vectorA = mathDevice.v3Build(3, 0, 2);
var vectorB = mathDevice.v3Build(7, 4, 3);
destination = mathDevice.v3Cross(vectorA, vectorB, destination);
vectorA, vectorB
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.53. v3Normalize¶

Summary

Returns a 3 component vector initialized to the normalized value of another 3 component vector.

Syntax

var vector = mathDevice.v3Build(3, 2, 6);
destination = mathDevice.v3Normalize(vector, destination);
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.54. v3LengthSq¶

Summary

Returns the scalar squared length of a given 3 component vector.

Syntax

var vectorLengthSq = mathDevice.v3LengthSq(vector);

//example usage:
if (1.0 !== vectorLengthSq)
{
normal = mathDevice.v3ScalarMul(vector, (1.0 / Math.sqrt(vectorLengthSq)));
}

Returns a JavaScript number.

vector
A Vector3 object.

### 17.6.1.55. v3Length¶

Summary

Returns the scalar length of a given 3 component vector.

Syntax

var vectorLength = mathDevice.v3Length(vector);

//example usage:
if (1.0 !== vectorLength)
{
vector = mathDevice.v3ScalarMul(vector, (1.0 / vectorLength));
}
vector
A Vector3 object.

Returns a JavaScript number.

Summary

Returns a 3 component vector initialized to the addition of the third argument with the multiplication of the first two arguments.

Syntax

var vectorMulA = mathDevice.v3Build(3, 2, 6);
var vectorMulB = mathDevice.v3Build(0, 7, 3);
var vectorAdd = mathDevice.v3Build(1, 8, 5);

//example usage:
var newPos = mathDevice.v3MulAdd(velocity, deltaTime, pos);
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.57. v3ScalarBuild¶

Summary

Creates a vector with 3 components all set to the scalar argument provided.

Syntax

var destination = mathDevice.v3ScalarBuild(100, destination);

destination (Optional)

Returns a Vector3 object.

Summary

Returns a 3 component vector initialized to the addition of the first vector parameter to the second scalar one.

Syntax

//example usage:
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.59. v3ScalarSub¶

Summary

Returns a 3 component vector initialized to the subtraction of the first vector parameter to the second scalar one.

Syntax

destination = mathDevice.v3ScalarSub(vector, scalar, destination);

//example usage:
nodeMinExtent = mathDevice.v3ScalarSub(nodeMinExtent, 0.1);
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.60. v3ScalarMul¶

Summary

Returns a 3 component vector initialized to the multiplication of the first vector parameter to the second scalar one.

Syntax

destination = mathDevice.v3ScalarMul(vector, scalar, destination);

//example usage:
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector3 object.

Summary

Returns a 3 component vector initialized to the sum of the first vector with the multiplication of the second vector parameter by the third scalar one.

Syntax

newPosition = mathDevice.v3AddScalarMul(position, velocity, time, newPosition);
position
A Vector3 object.
velocity
A Vector3 object.
time
A JavaScript number.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.62. v3Lerp¶

Summary

Returns a 3 component vector initialized to the linear interpolation between the first and second vector parameters using the delta passed as the third parameter.

Syntax

var vectorA = mathDevice.v3Build(10, 0, 20);
var vectorB = mathDevice.v3Build(20, 0, 6);
destination = mathDevice.v3Lerp(vectorA, vectorB, scalar, destination);
vectorA, vectorB
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.63. v3CatmullRom¶

Summary

Returns a 3 component vector initialized to the Catmull Rom interpolation through a set of 4 points.

Syntax

var vectorA = mathDevice.v3Build(10,  0, 20);
var vectorB = mathDevice.v3Build(20,  0,  6);
var vectorC = mathDevice.v3Build(5,  10,  6);
var vectorD = mathDevice.v3Build(10, 10,  9);
destination = mathDevice.v3CatmullRom(t, tension, vectorA, vectorB, vectorC, vectorD, destination);
vectorA, vectorB, vectorC, vectorD
A Vector3 object.
t, tension
A JavaScript number.

destination (Optional)

Returns a Vector3 object. The interpolation will be at B with derivative tension * (C - A) for t = 0. The interpolation will be at C with derivative tension * (D - A) for t = 1.

### 17.6.1.64. v4Build¶

Summary

Creates a vector with 4 components.

Syntax

var destination = mathDevice.v4Build(100, 10, 0, 42, destination);

destination (Optional)

Returns a Vector4 object.

### 17.6.1.65. v4BuildZero¶

Summary

Creates a vector with 4 components all set to 0.0.

Syntax

var destination = mathDevice.v4BuildZero(destination);

destination (Optional)

Returns a Vector4 object.

### 17.6.1.66. v4BuildOne¶

Summary

Creates a vector with 4 components all set to 1.0.

Syntax

var destination = mathDevice.v4BuildOne(destination);

destination (Optional)

Returns a Vector4 object.

### 17.6.1.67. v4Copy¶

Summary

Returns a 4 component vector copy of the given vector.

Syntax

var source = mathDevice.v4Build(0, 0, 0, 20);
destination = mathDevice.v4Copy(source, destination);
source
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.68. v4Neg¶

Summary

Returns a 4 component vector initialized to the component-wise negation of a given vector.

Syntax

var vector = mathDevice.v4Build(0, 0, 0, 20);
destination = mathDevice.v4Neg(vector, destination);
vector
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

Summary

Returns a 4 component vector initialized to the component-wise addition of two other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 6, 5, 0);
vectorA, vectorB
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

Summary

Returns a 4 component vector initialized to the component-wise addition of 3 other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 8, 5, 0);
var vectorC = mathDevice.v4Build(9, 6, 6, 5);
destination = mathDevice.v4Add3(vectorA, vectorB, vectorC, destination);
vectorA, vectorB, vectorC
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

Summary

Returns a 4 component vector initialized to the component-wise addition of 4 other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 1, 3, 2);
var vectorB = mathDevice.v4Build(3, 8, 5, 0);
var vectorC = mathDevice.v4Build(9, 6, 6, 5);
var vectorD = mathDevice.v4Build(4, 2, 3, 1);
destination = mathDevice.v4Add3(vectorA, vectorB, vectorC, vectorD, destination);
vectorA, vectorB, vectorC, vectorD
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.72. v4Sub¶

Summary

Returns a 4 component vector initialized to the component-wise subtraction of two other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 6, 5, 0);
destination = mathDevice.v4Sub(vectorA, vectorB, destination);
vectorA, vectorB
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.73. v4Mul¶

Summary

Returns a 4 component vector initialized to the component-wise multiplication of two other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 6, 5, 0);
destination = mathDevice.v4Mul(vectorA, vectorB, destination);
vectorA, vectorB
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.74. v4Min¶

Summary

Returns a 4 component vector initialized to the component-wise minimum of two other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 6, 5, 0);
destination = mathDevice.v4Min(vectorA, vectorB, destination);
vectorA, vectorB
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.75. v4Max¶

Summary

Returns a 4 component vector initialized to the component-wise maximum of two other vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 6, 5, 0);
destination = mathDevice.v4Max(vectorA, vectorB, destination);
vectorA, vectorB
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.76. v4Dot¶

Summary

Returns the scalar dot product of to 4 component vectors.

Syntax

var vectorA = mathDevice.v4Build(7, 4, 3, 2);
var vectorB = mathDevice.v4Build(3, 6, 5, 0);
var dot = mathDevice.v4Dot(vectorA, vectorB);
vectorA, vectorB
A Vector4 object.

Returns a JavaScript number.

### 17.6.1.77. v4Normalize¶

Summary

Returns a 4 component vector initialized to the normalized value of another 4 component vector.

Syntax

var vector = mathDevice.v4Build(7, 4, 3, 2);
var destination = mathDevice.v4Normalize(vector, destination);
vectorA
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.78. v4LengthSq¶

Summary

Returns the scalar squared length of a given 4 component vector.

Syntax

var vectorLengthSq = mathDevice.v4LengthSq(vector);

//example code:
if (1.0 !== vectorLengthSq)
{
vector = mathDevice.v4ScalarMul(vector, (1.0 / Math.sqrt(vectorLengthSq)));
}
vector
A Vector4 object.

Returns a JavaScript number.

### 17.6.1.79. v4Length¶

Summary

Returns the scalar length of a given 4 component vector.

Syntax

var vectorLength = mathDevice.v4Length(vector);

//example code:
if (1.0 !== vectorLength)
{
vector = mathDevice.v4ScalarMul(vector, (1.0 / vectorLength));
}
vector
A Vector4 object.

Returns a JavaScript number.

Summary

Returns a 4 component vector initialized to the addition of the third argument with the multiplication of the first two arguments.

Syntax

var vectorMulA = mathDevice.v4Build(3, 2, 6);
var vectorMulB = mathDevice.v4Build(0, 7, 3);
var vectorAdd = mathDevice.v4Build(1, 8, 5);

//example usage:
var newPos = mathDevice.v4MulAdd(velocity, deltaTime, pos);
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.81. v4ScalarBuild¶

Summary

Creates a vector with 4 components all set to the argument given.

Syntax

var destination = mathDevice.v4ScalarBuild(100, destination);

destination (Optional)

Returns a Vector4 object.

Summary

Returns a 4 component vector initialized to the addition of the first vector parameter to the second scalar one.

Syntax

vector
A Vector4 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.83. v4ScalarSub¶

Summary

Returns a 4 component vector initialized to the subtraction of the first vector parameter to the second scalar one.

Syntax

destination = mathDevice.v4ScalarSub(color, scalar, destination);
vector
A Vector4 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.84. v4ScalarMul¶

Summary

Returns a 4 component vector initialized to the multiplication of the first vector parameter to the second scalar one.

Syntax

destination = mathDevice.v4ScalarMul(vector, scalar, destination);
vector
A Vector4 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector4 object.

Summary

Returns a 4 component vector initialized to the sum of the first vector with the multiplication of the second vector parameter by the third scalar one.

Syntax

destination = mathDevice.v4AddScalarMul(vector1, vector2, delta, destination);
vector1
A Vector4 object.
vector2
A Vector4 object.
delta
A JavaScript number.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.86. v4Lerp¶

Summary

Returns a 4 component vector initialized to the linear interpolation between the first and second vector parameters using the delta passed as the third parameter.

Syntax

var vectorA = mathDevice.v4Build(10, 0, 20, 0);
var vectorB = mathDevice.v4Build(20, 0, 6, 0);
destination = mathDevice.v4Lerp(vectorA, vectorB, scalar, destination);
vectorA, vectorB
A Vector4 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.87. v4Abs¶

Summary

Returns a 4 component vector initialized to the component-wise absolute of the vector parameter given.

Syntax

var vector = mathDevice.v4Build(-4, 0, 10, -5);
destination = mathDevice.v4Abs(vector, destination);
vector
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.88. v4Equal¶

Summary

Returns a boolean specifying whether the two 4 component vectors are equal. Optional third parameter specifies the precision of the comparison with a default of 1E-06.

Syntax

var vectorA = mathDevice.v4Build(0, 2, 0, -1);
var vectorB = mathDevice.v4Build(0, 2.00014, 0, -1);
var equal = mathDevice.v4Equal(vectorA, vectorB, scalar);
vectorA, vectorB
A Vector4 object.
scalar (Optional)
A JavaScript number. The precision of the equality test.

### 17.6.1.89. planeNormalize¶

Summary

Returns a 4D vector initialized to the normalized value of a 4D vector interpreted as a Plane equation.

Syntax

var vector = mathDevice.v4Build(5, 3, 2, 9);
destination = mathDevice.planeNormalize(vector, destination);
vector
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.90. aabbBuild¶

Summary

Creates an AABB object, containing bounding box defined by two points; a minimum and a maximum.

Syntax

var destination = mathDevice.aabbBuild(minX, minY, minZ, maxX, maxY, maxZ, destination);

// example usage:
var unitBox = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
minX, minY, minZ
JavaScript numbers giving the coordinates of the minimum point.
maxX, maxY, maxZ
JavaScript numbers giving the coordinates of the maximum point.

destination (Optional)

Returns a AABB object.

### 17.6.1.91. aabbBuildEmpty¶

Summary

Creates an AABB object, containing bounding box defined by two points; a minimum and a maximum. The box has its minimum point set to the maximum values possible and its maximum point set to the minimum values possible.

Syntax

var destination = mathDevice.aabbBuildEmpty(destination);

// example usage:
var aabbEmpty = mathDevice.aabbBuildEmpty();
var unitBox = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
var union = mathDevice.aabbUnion(aabbEmpty, unitBox);
// union is now equal to unitBox

destination (Optional)

Returns a AABB object.

### 17.6.1.92. aabbCopy¶

Summary

Returns a copy of the given AABB object.

Syntax

var source = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
var destination = mathDevice.aabbCopy(source, destination);
source
An AABB object.

destination (Optional)

Returns an AABB object.

### 17.6.1.93. aabbIsEmpty¶

Summary

Returns a true if the given AABB object is empty, false otherwise.

Syntax

var source = mathDevice.aabbBuildEmpty();
var isEmpty = mathDevice.aabbIsEmpty(aabb);
aabb
An AABB object.

Returns an JavaScript boolean object.

### 17.6.1.94. aabbGetCenterAndHalf¶

Summary

Gets the center point and the half extents of the AABB object.

Syntax

var source = mathDevice.aabbBuildEmpty();
mathDevice.aabbGetCenterAndHalf(aabb, center, halfExtents);

//example usage:
var newBox = mathDevice.aabbBuild(center[0] - halfExtents[0],
center[1] - halfExtents[1],
center[2] - halfExtents[2],
center[3] - halfExtents[3],
center[4] - halfExtents[4],
center[5] - halfExtents[5],);
aabb
An AABB object.
center
A Vector3 object.
halfExtents
A Vector3 object.

### 17.6.1.95. aabbIsInsidePlanes¶

Summary

Returns true if the any point in the AABB object is on the correct side of each plane, false otherwise.

Syntax

var isInside = mathDevice.aabbIsInsidePlanes(aabb, planes);

//example usage:
mathDevice.aabbIsInsidePlanes(aabb, [mathDevice.v4Build(0, 0, -1, 4),
mathDevice.v4Build(0, 0, 1, -4)]);
aabb
An AABB object.
planes
An array of Vector4 objects representing planes.

Returns an JavaScript boolean object.

### 17.6.1.96. aabbIsFullyInsidePlanes¶

Summary

Returns true if the all points in the AABB object are on the correct side of each plane, false otherwise.

Syntax

var isFullyInside = mathDevice.aabbIsFullyInsidePlanes(aabb, planes);

//example usage:
mathDevice.aabbIsFullyInsidePlanes(aabb, [mathDevice.v4Build(0, 0, -1, 4),
mathDevice.v4Build(0, 0, 1, -4)]);
aabb
An AABB object.
planes
An array of Vector4 objects representing planes.

Returns an JavaScript boolean object.

### 17.6.1.97. aabbUnion¶

Summary

Returns the union of two given AABB objects. The union of any AABB object a and an empty AABB object is a.

Syntax

var boxA = mathDevice.aabbBuild(0, 0, 0, 1, 1, 4);
var boxB = mathDevice.aabbBuild(1, 0, 1, 2, 3, 2);
var destination = mathDevice.aabbUnion(boxA, boxB, destination);
// the result is a box with minimum at the origin and
// maximum at point (2, 3, 4)
boxA, boxB
An AABB object.

destination (Optional)

Returns a AABB object.

### 17.6.1.98. aabbUnionArray¶

Summary

Returns the union of an array of AABB objects. The union of any AABB object a and an empty AABB object is a.

Syntax

var boxA = mathDevice.aabbBuild(0, 0, 0, 1, 1, 4);
var boxB = mathDevice.aabbBuild(1, 0, 1, 2, 3, 2);
var destination = mathDevice.aabbUnionArray([boxA, boxB], destination);
// the result is a box with minimum at the origin and
// maximum at point (2, 3, 4)
boxA, boxB
An AABB object.

destination (Optional)

Returns a AABB object.

Summary

“Stretches” an AABB object to contain a set of points.

Syntax

var box = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
var points = [];
points[0] = mathDevice.v3Build(0, 0, 2);
points[1] = mathDevice.v3Build(0, -1, -2);
points[2] = mathDevice.v3Build(1, 0, 1);
// box will now have minimum (0, -1, -2) and
// maximum (1, 1, 2)
box
An AABB object.
points
An array of Vector3 objects.

### 17.6.1.100. aabbTransform¶

Summary

Returns a transformed AABB object.

Syntax

var sqrt = Math.sqrt;
var box = mathDevice.aabbBuild(0, 0, 0, sqrt(2), 1, sqrt(2));
var up = mathDevice.v3BuildYAxis();
var matrix = mathDevice.m43FromAxisRotation(up, Math.PI / 4);
var destination = mathDevice.aabbTransform(box, matrix, destination);
// returns a box with roughly minimum (-1, 0, 0) and maximum (1, 1, 2)
box
An AABB object.
matrix
A Matrix43 object.

destination (Optional)

Returns a AABB object.

### 17.6.1.101. aabbIntercept¶

Summary

Returns the interception of two given AABB objects. The interception of any AABB object a and an empty AABB object is an empty AABB object.

Syntax

var boxA = mathDevice.aabbBuild(0, 0, 0, 1, 1, 4);
var boxB = mathDevice.aabbBuild(1, 0, 1, 2, 3, 2);
var destination = mathDevice.aabbIntercept(boxA, boxB, destination);
// the result is a box with minimum at (1, 0, 1) and
// maximum at point (1, 1, 2)
boxA, boxB
An AABB object.

destination (Optional)

Returns a AABB object.

### 17.6.1.102. aabbOverlaps¶

Summary

Returns true if the two given AABB objects overlap (including edges), false otherwise. The overlap of any AABB object a and an empty AABB object is false.

Syntax

var boxA = mathDevice.aabbBuild(0, 0, 0, 1, 1, 4);
var boxB = mathDevice.aabbBuild(1, 0, 1, 2, 3, 2);
var bool = mathDevice.aabbOverlaps(boxA, boxB);
// returns true
boxA, boxB
An AABB object.

Returns a JavaScript boolean.

### 17.6.1.103. aabbSphereOverlaps¶

Summary

Returns true if the given AABB object overlaps with the sphere (including edges), false otherwise.

Syntax

var box = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
var center = mathDevice.v3Build(0, 0, 0);
var bool = mathDevice.aabbSphereOverlaps(box, center, radius);
// returns true
box
An AABB object.
center
A Vector3 object. The center of the sphere to check.
A JavaScript number.

Returns a JavaScript boolean.

### 17.6.1.104. aabbIsInside¶

Summary

Returns true if the first given AABB object is inside the second given AABB object (including edges), false otherwise.

Syntax

var boxA = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
var boxB = mathDevice.aabbBuild(0, 0, 0, 0.5, 0.5, 0.5);
var bool = mathDevice.aabbIsInside(boxA, boxB);
// returns true
boxA, boxB
An AABB object.

Returns a JavaScript boolean.

### 17.6.1.105. aabbTestInside¶

Summary

• Returns 2 if the first given AABB object is inside the second given AABB object (including edges).
• Returns 1 if the first given AABB object overlaps with the second given AABB object (including edges) but is not inside it.
• Returns 0 if there is no overlap between the objects.

Syntax

var boxA = mathDevice.aabbBuild(0, 0, 0, 1, 1, 1);
var boxB = mathDevice.aabbBuild(0, 0, 0, 0.5, 0.5, 0.5);
var bool = mathDevice.aabbTestInside(boxA, boxB);
// returns 2
boxA, boxB
An AABB object.

Returns a JavaScript number.

### 17.6.1.106. quatBuild¶

Summary

Creates a quat object, containing a rotation represented by a quaternion.

Syntax

var destination = mathDevice.quatBuild(a, b, c, d, destination);
a, b, c, d
A JavaScript number. The components of the Quaternion.

Returns a Quaternion object.

destination (Optional)

### 17.6.1.107. quatEqual¶

Summary

Returns a boolean specifying whether the two quaternions are equal. Optional third parameter specifies the precision of the comparison with a default of 1E-06.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
var equal = mathDevice.quatEqual(quatA, quatB, scalar);
quatA, quatB
A Quaternion object.
scalar
A JavaScript number.

Returns a JavaScript boolean.

### 17.6.1.108. quatIsSimilar¶

Summary

Returns a boolean specifying whether the two quaternions are similar. This function differs from mathDevice.quatEqual in that it will evaluate to true for quaternions which have similar rotations rather than similar quaternion component values. Optional third parameter specifies the precision of the comparison with a default of 1E-06.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
var equal = mathDevice.quatIsSimilar(quatA, quatB, scalar);
quatA, quatB
A Quaternion object.
scalar (Optional)
A JavaScript number.

Returns a JavaScript boolean.

### 17.6.1.109. quatLength¶

Summary

Returns the scalar length of a given quaternion.

Syntax

var quatLength = mathDevice.quatLength(quat);
quat
A Quaternion object.

Returns a JavaScript number.

### 17.6.1.110. quatNormalize¶

Summary

Returns a quaternion initialized to the normalized value of another quaternion.

Syntax

destination = mathDevice.quatNormalize(quat, destination);
quat
A Quaternion object.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.111. quatConjugate¶

Summary

Returns a quaternion initialized to the conjugate value of another quaternion.

Syntax

destination = mathDevice.quatConjugate(quat, destination);
quat
A Quaternion object.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.112. quatDot¶

Summary

Returns a scalar, the dot product of the two given quaternions.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
scalar = mathDevice.quatDot(quatA, quatB);
quatA, quatB
A Quaternion object.

Returns a JavaScript number.

### 17.6.1.113. quatMul¶

Summary

Returns a quaternion object representing the multiplication of the two given quaternions.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
destination = mathDevice.quatMul(quatA, quatB, destination);
quatA, quatB
A Quaternion object.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.114. quatToAxisRotation¶

Summary

Creates a vector initialized to the rotation and angle represented by the quaternion parameter.

Syntax

destination = mathDevice.quatToAxisRotation(quat, destination);

//example usage:
var axis = mathDevice.v3Build(destination[0], destination[1], destination[2]);
var rotation = destination[3];
quat
A Quaternion object.

destination (Optional)

Returns a Vector4 object with the first 3 components as the axis of rotation and the 4th component as the rotation in radians.

### 17.6.1.115. quatTransformVector¶

Summary

Creates a vector initialized to the second vector parameter transformed by the first quaternion parameter.

Syntax

destination = mathDevice.quatTransformVector(quat, vector, destination);

//example usage:
var axis = mathDevice.v3Build(0, 1, 0);
var quat = mathDevice.quatFromAxisRotation(axis, Math.PI * 0.5);
var vec3 = mathDevice.v3Build(1, 0, 0);
var transformedVec = mathDevice.quatTransformVector(quat, vec3);
quat
A Quaternion object.
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.116. quatFromAxisRotation¶

Summary

Creates a quaternion initialized to the rotation represented by the first parameter as the axis vector and second as the rotation in radians.

Syntax

destination = mathDevice.quatFromAxisRotation(vector, scalar, destination);

//example usage:
var up = mathDevice.v3BuildYAxis();
var deltaRotation = mathDevice.quatFromAxisRotation(up, angle);
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.117. quatFromM43¶

Summary

Creates a quaternion initialized to the rotation part of the given 4x3 orthogonal matrix.

Syntax

destination = mathDevice.quatFromM43(matrix, destination);

//example usage:
var matrix = camera.getMatrix();
var rotation = mathDevice.quatFromM43(matrix);
matrix
A Matrix43 object.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.118. quatCopy¶

Summary

Returns a quaternion copy of the given quaternion.

Syntax

var quat = mathDevice.quatBuild(0, 0, 0, 1);
destination = mathDevice.quatCopy(quat, destination);
quat
A Quaternion object.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.119. quatLerp¶

Summary

Returns a quaternion initialized to the linear interpolation of the given two quaternions at the given delta between them.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
destination = mathDevice.quatLerp(quatA, quatB, scalar, destination);
quatA, quatB
A Quaternion object.
scalar
A JavaScript number.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.120. quatSlerp¶

Summary

Returns a quaternion initialized to the spherical linear interpolation of the given two quaternions at the given delta between them.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
destination = mathDevice.quatSlerp(quatA, quatB, scalar, destination);
quatA, quatB
A Quaternion object.
scalar
A JavaScript number.

destination (Optional)

Returns a Quaternion object.

### 17.6.1.121. QuatPosBuild¶

Summary

Creates a quatPos object, containing a position and a rotation represented by a quaternion.

Syntax

var destination = mathDevice.QuatPosBuild(quatA, quatB, quatC, quatD, v3A, v3B, v3C, destination);
var destination = mathDevice.QuatPosBuild(quat, v3, destination);
quatA, quatB, quatC, quatD
A JavaScript number. These numbers give the components of the quaternion.
v3A, v3B, v3C
A JavaScript number. These numbers give the components of the position.
quat
A Quat object.
v3
A Vector3 object.

destination (Optional)

Returns a QuaternionPosition object. The parameters are given as quaternion components and then position components.

### 17.6.1.122. quatMulTranslate¶

Summary

Multiplies together two pairs of rotations and translations represented as a quaternion and 3 component vector. The result is given in an additional quaternion and 3 component vector passed as the fifth and sixth parameters. This method matches m43Mul in functionality but working with quaternion representations.

Syntax

var quatA = mathDevice.quatBuild(0, 0, 0, 1);
var vectorA = mathDevice.v3Build(0, 20, 0);

var quatB = mathDevice.quatBuild(0, 0.707, 0, 0.707);
var vectorB = mathDevice.v3Build(0, 4, 10);

var destinationQuat = mathDevice.quatBuild(0, 0, 0, 0);
var destinationVector = mathDevice.v3Build(0, 0, 0);
mathDevice.quatMulTranslate(quatA, vectorA, quatB, vectorB, destinationQuat, destinationVector);
quatA, quatB, destinationQuat
A Quaternion object.
vectorA, vectorB, destinationVector
A Vector3 object.

Notice that the destinations are not optional here they must be provided, this function returns null.

### 17.6.1.123. m33BuildIdentity¶

Summary

Creates a 3x3 matrix initialized to the identity.

Syntax

var destination = mathDevice.m33BuildIdentity(destination);

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.124. m33Build¶

Summary

Creates a 3x3 matrix initialized to the 3 given 3 component vectors.

Syntax

var destination = mathDevice.m33Build(a, b, c,
d, e, f,
g, h, i,
destination);
var destination = mathDevice.m33Build(right, up, at, destination);
a, b, c, d, e, f, g, h, i
A JavaScript number. The components of the matrix given in row column format.
right
A Vector3 object. The components of this vector are copied to the first row of the matrix.
up
A Vector3 object. The components of this vector are copied to the second row of the matrix.
at
A Vector3 object. The components of this vector are copied to the last row of the matrix.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.125. m33Copy¶

Summary

Copies a 3x3 matrix.

Syntax

var destination = mathDevice.m33Build(matrix, destination);
matrix
A Matrix33 object. The elements of this matrix are copied into the destination matrix.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.126. m33FromAxisRotation¶

Summary

Creates a 3x3 matrix initialized to the rotation represented by the first parameter as the axis vector and the second scalar one as the angle.

Syntax

destination = mathDevice.m33FromAxisRotation(vector, scalar, destination);

//example usage:
var up = mathDevice.v3Build(0, 1, 0);
var deltaRotation = mathDevice.m33FromAxisRotation(up, angle);
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.127. m33Mul¶

Summary

Creates a 3x3 matrix initialized to the multiplication of two other 3x3 matrices.

Syntax

var matrixA = mathDevice.m33Build(rightA, upA, atA);
var matrixB = mathDevice.m33Build(rightB, upB, atB);
destination = mathDevice.m33Mul(matrixA, matrixB, destination);
matrixA, matrixB
A Matrix33 or Matrix43 object. If a Matrix43 object is given only its 3x3 components are used for the multiplication.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.128. m33Transform¶

Summary

Creates a Vector3 initialized to the transform of a Vector3 by a 3x3 matrix.

Syntax

destination = mathDevice.m33Transform(matrix, vector, destination);
matrix
A Matrix33 object.
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.129. m33Transpose¶

Summary

Creates a 3x3 matrix initialized to the transposed of the given 3x3 matrix.

Syntax

destination = mathDevice.m33Transpose(matrix, destination);
matrix
A Matrix33 object.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.130. m33InverseTranspose¶

Summary

Creates a 3x3 matrix initialized to the transposed inverse of the given 3x3 matrix.

Syntax

destination = mathDevice.m33InverseTranspose(matrix, destination);

//example usage:
var worldToObjectInverseTranspose = mathDevice.m33InverseTranspose(worldRotation);
matrix
Either a Matrix33 or a Matrix43 object. If a Matrix43 object is given only its 3x3 components are used for the transposed inverse.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.131. m33Determinant¶

Summary

Evaluates the determinant of a 3x3 matrix.

Syntax

var determinant = mathDevice.m33Determinant(matrix);
matrix
A Matrix33 object.

Returns a JavaScript number.

### 17.6.1.132. m33MulM43¶

Summary

Creates a 4x3 matrix initialized to the multiplication of the 3x3 part of a 3x3 or 4x3 matrix with a 4x3 matrix. This operation keeps the 4th row of the second argument.

Syntax

destination = mathDevice.m33MulM43(matrixA, matrixB, destination);
matrixA
Either a Matrix33 or Matrix43 object. If a Matrix43 object is given only its 3x3 component is used for the multiplication.
matrixB
A Matrix43 object.

destination (Optional)

Returns a Matrix43 object with matrixB‘s 4th row.

### 17.6.1.133. m33MulM44¶

Summary

Creates a 4x4 matrix initialized to the multiplication of a 3x3 matrix with a 4x4 matrix.

Syntax

destination = mathDevice.m33MulM44(matrixA, matrixB, destination);
matrixA
A Matrix33 object.
matrixB
A Matrix44 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.134. m33FromQuat¶

Creates a 3x3 matrix initialized to the rotation represented by a quaternion.

Syntax

destination = mathDevice.m33FromQuat(quat, destination);
quat
A Quaternion object.

destination (Optional)

Returns a Matrix33 object.

### 17.6.1.135. m33Right¶

Summary

Creates a 3 component vector initialized to the right element of the given 3x3 matrix.

Syntax

destination = mathDevice.m33Right(matrix, destination);

//example usage:
var right = mathDevice.m33Right(rotation);
matrix
A Matrix33 object.

destination (Optional)

Returns a Vector3 object. This function returns the first row of the matrix.

### 17.6.1.136. m33Up¶

Summary

Creates a 3 component vector initialized to the up element of the given 3x3 matrix. Optional second parameter specifies the vector to copy the results to - this destination parameter should be created beforehand and it will also be the return value. This functionality is useful to avoid the memory allocation of a new vector.

Syntax

destination = mathDevice.m33Up(matrix, destination);
matrix
A Matrix33 object.

destination (Optional)

Returns a Vector3 object. This function returns the second row of the matrix.

### 17.6.1.137. m33At¶

Summary

Creates a 3 component vector initialized to the at element of the given 3x3 matrix.

Syntax

destination = mathDevice.m33At(matrix, destination);
matrix
A Matrix33 object.

destination (Optional)

Returns a Vector3 object. This function returns the last row of the matrix.

### 17.6.1.138. m33SetRight¶

Summary

Sets the right element of a 3x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m33SetRight(matrix, vector);
matrix
A Matrix33 object.
vector
A Vector3 object.

This function sets the first row of the matrix.

### 17.6.1.139. m33SetUp¶

Summary

Sets the up element of a 3x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m33SetUp(matrix, vector);
matrix
A Matrix33 object.
vector
A Vector3 object.

This function sets the second row of the matrix.

### 17.6.1.140. m33SetAt¶

Summary

Sets the at element of a 3x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m33SetAt(matrix, vector);
matrix
A Matrix33 object.
vector
A Vector3 object.

This function sets the last row of the matrix.

### 17.6.1.141. m34BuildIdentity¶

Summary

Creates a 3x4 matrix initialized to the identity.

Syntax

var destination = mathDevice.m34BuildIdentity(destination);

destination (Optional)

Returns a Matrix34 object.

### 17.6.1.142. m34Pos¶

Summary

Creates a 3 component vector initialized to the position element of the given 3x4 matrix.

Syntax

destination = mathDevice.m34Pos(matrix, destination);
matrix
A Matrix33 object.

destination (Optional)

Returns a Vector3 object. This returns the first row of the matrix.

### 17.6.1.143. m43BuildIdentity¶

Summary

Creates a 4x3 matrix initialized to the identity.

Syntax

var destination = mathDevice.m43BuildIdentity(destination);

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.144. m43Build¶

Summary

Creates a 4x3 matrix initialized to the 4 given 3 component vectors.

Syntax

var destination = mathDevice.m43Build(a, b, c,
d, e, f,
g, h, i,
j, k, l,
destination);
var destination = mathDevice.m43Build(right, up, at, pos, destination);
a, b, c, d, e, f, g, h, i, j, k, l
A JavaScript number. The components of the matrix given in row column format.
right
A Vector3 object. The components of this vector are copied to the first row of the matrix.
up
A Vector3 object. The components of this vector are copied to the second row of the matrix.
at
A Vector3 object. The components of this vector are copied to the third row of the matrix.
pos
A Vector3 object. The components of this vector are copied to the last row of the matrix.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.145. m43BuildTranslation¶

Summary

Creates a 4x3 matrix initialized with the identity matrix for its first 3 rows and a given 3 component vector for the position row.

Syntax

var destination = mathDevice.m43BuildTranslation(a, b, c, destination);
var destination = mathDevice.m43BuildTranslation(vector, destination);
a, b, c
A JavaScript number. The components of the translation.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.146. m43Copy¶

Summary

Creates a 4x3 matrix initialized to a copy of the given 4x3 matrix.

Syntax

destination = mathDevice.m43Copy(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.147. m43FromM33V3¶

Summary

Creates a 4x3 matrix with the first 3 rows set equal to the matrix and the last row equal to the vector.

Syntax

destination = mathDevice.m43FromM33V3(matrix, vector, destination);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.148. m43FromAxisRotation¶

Summary

Creates a 4x3 matrix initialized to the rotation represented by the first parameter as the axis vector and the second scalar one as the angle. Position element is initialized to zero.

Syntax

destination = mathDevice.m43FromAxisRotation(vector, scalar, destination);

//example usage:
var up = mathDevice.v3Build(0, 1, 0);
var transform = mathDevice.m43FromAxisRotation(up, angle);
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.149. m43FromQuatPos¶

Summary

Creates a 4x3 matrix initialized to a quatPos vector.

Syntax

destination = mathDevice.m43FromQuatPos(quatPos, destination);

//example usage:
var boneTransform = mathDevice.quatPos(0, 1, 0, 1,
5, 3, 0);
var transform = mathDevice.m43FromQuatPos(boneTransform);
quatPos
A QuaternionPosition object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.150. m43FromRTS¶

Summary

Creates a 4x3 matrix initialized from a given Quaternion, 3 component position vector and 3 component scale vector.

Syntax

destination = mathDevice.m43FromRTS(quat, vector, scalar, destination);

//example usage:
var rotation = mathDevice.quatBuild(0, 0, 0, 1);
var translation = mathDevice.v3Build(10, 10, 10);
var scale = mathDevice.v3Build(2, 1, 1);
var transform = mathDevice.m43FromRTS(rotation, translation, scale);
quat
A Quaternion object.
vector
A Vector3 object.
scalar
A JavaScript number.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.151. m43FromRT¶

Summary

Creates a 4x3 matrix initialized from a given Quaternion and 3 component position vector.

Syntax

destination = mathDevice.m43FromRT(quat, vector, destination);

//example usage:
var rotation = mathDevice.quatBuild(0, 0, 0, 1);
var translation = mathDevice.v3Build(10, 10, 10);
var transform = mathDevice.m43FromRT(rotation, translation);
quat
A Quaternion object.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.152. m43Right¶

Summary

Creates a 3 component vector initialized to the right element of the given 4x3 matrix.

Syntax

destination = mathDevice.m43Right(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Vector3 object. This function returns the first row of the matrix.

### 17.6.1.153. m43Up¶

Summary

Creates a 3 component vector initialized to the up element of the given 4x3 matrix.

Syntax

destination = mathDevice.m43Up(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Vector3 object. This function returns the second row of the matrix.

### 17.6.1.154. m43At¶

Summary

Creates a 3 component vector initialized to the at element of the given 4x3 matrix.

Syntax

destination = mathDevice.m43At(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Vector3 object. This function returns the third row of the matrix.

### 17.6.1.155. m43Pos¶

Summary

Creates a 3 component vector initialized to the position element of the given 4x3 matrix.

Syntax

destination = mathDevice.m43Pos(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Vector3 object. This function returns the fourth row of the matrix.

### 17.6.1.156. m43Mul¶

Summary

Creates a 4x3 matrix initialized to the multiplication of two other 4x3 matrices.

Syntax

destination = mathDevice.m43Mul(matrixA, matrixB, destination);
matrixA, matrixB
A Matrix43 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.157. m43MulTranspose¶

Summary

Creates a 3x4 matrix initialized to the transposed multiplication of two 4x3 matrices.

Syntax

destination = mathDevice.m43MulTranspose(matrixA, matrixB, destination);
matrixA, matrixB
A Matrix43 object.

destination (Optional)

Returns a Matrix34 object.

### 17.6.1.158. m43MulM44¶

Summary

Creates a 4x4 matrix initialized to the multiplication of a 4x3 matrix by a 4x4 matrix.

Syntax

destination = mathDevice.m43MulM44(matrixA, matrixB, destination);

//example usage:
var worldViewProjection = mathDevice.m43MulM44(worldTransform, viewProjection);
matrixA, matrixB
A Matrix43 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.159. m43Transpose¶

Summary

Creates a 3x4 matrix initialized to the transpose of the given 4x3 matrix.

Syntax

destination = mathDevice.m43Transpose(matrix, destination);

//example usage:
var worldTransformTransposed = mathDevice.m43Transpose(worldTransform);
matrix
A Matrix43 object.

destination (Optional)

Returns a Matrix34 object.

### 17.6.1.160. m43InverseOrthonormal¶

Summary

Creates a 4x3 matrix initialized to the inverse of a given orthonormal 4x3 matrix.

Syntax

destination = mathDevice.m43InverseOrthonormal(matrix, destination);

//example usage:
var viewTransform = mathDevice.m43InverseOrthonormal(cameraTransform);
matrix
A Matrix43 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.161. m43Orthonormalize¶

Summary

Creates a 4x3 matrix initialized to the othogonalized and normalized value of a given 4x3 matrix.

Syntax

destination = mathDevice.m43Orthonormalize(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.162. m43Determinant¶

Summary

Evaluates the determinant of a 4x3 matrix.

Syntax

var det = mathDevice.m43Determinant(matrix);
matrix
A Matrix43 object.

Returns a JavaScript number value.

### 17.6.1.163. m43Inverse¶

Summary

Creates a 4x3 matrix initialized to the inverse of a given 4x3 matrix.

Syntax

destination = mathDevice.m43Inverse(matrix, destination);
matrix
A Matrix43 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.164. m43Translate¶

Summary

Adds component-wise the given 3 component vector to the position element of a 4x3 matrix.

Syntax

mathDevice.m43Translate(matrix, vector);

//example usage:
var deltaPos = mathDevice.v3Build(0, 0, 20);
mathDevice.m43Translate(worldTransform, deltaPos);
matrix
A Matrix43 object.
vector
A Vector3 object.

### 17.6.1.165. m43Scale¶

Summary

Scales up the 3x3 part of a 4x3 matrix. Each row is multiplied by each component of the scale vector.

Syntax

destination = mathDevice.m43Scale(matrix, vector, destination);

//example usage:
var vecScale = mathDevice.v3ScalarBuild(10);
mathDevice.m43Scale(matrix, vecScale, matrix);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.166. m43Offset¶

Summary

Creates a 4x3 matrix initialized to the given 4x3 matrix translated to the given relative 3 component vector. The relative vector is first rotated with the 3x3 component of the matrix and then added to its position element.

Syntax

destination = mathDevice.m43Offset(matrix, vector, destination);

//example usage:
var newTransform = mathDevice.m43Offset(initialTransform, relativeOffset);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.167. m43NegOffset¶

Summary

Creates a 4x3 matrix initialized to the given 4x3 matrix translated to the given relative 3 component vector. The relative vector is first rotated with the 3x3 component of the matrix and then subtracted to its position element.

Syntax

destination = mathDevice.m43NegOffset(matrix, vector, destination);

//example usage:
var newTransform = mathDevice.m43NegOffset(initialTransform, negativeRelativeOffset);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix43 object.

### 17.6.1.168. m43InverseTransposeProjection¶

Summary

Creates a 3x4 matrix initialized to the transposed inverse of the given 4x3 matrix projected to the given 3 component vector.

Syntax

destination = mathDevice.m43InverseTransposeProjection(matrix, vector, destination);

//example usage:
var worldViewMatrix = mathDevice.m43Mul(worldMatrix, viewMatrix, worldViewMatrix);
var newTransform = mathDevice.m43InverseTransposeProjection(worldViewMatrix, halfExtents);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Matrix34 object.

This function gives the same result as the following function calls::

var inverse = mathDevice.m43InverseOrthonormal(matrix);
var result = mathDevice.m34Transpose(inverse);

For example for applying a texture to a point light. Then matrix would be a transform from object space into view space. The vector would then be the half extents of the light. The result of this example operation would give a transform from world space to light space. This light space is normalized to have its extents from (0, 0, 0) to (1, 1, 1).

### 17.6.1.169. m43TransformPoint¶

Summary

Creates a 3 component vector initialized to the transformation as a point of the given 3 component vector by the given 4x3 matrix.

Syntax

destination = mathDevice.m43TransformPoint(matrix, vector, destination);

//example usage:
var worldPosition = mathDevice.m43TransformPoint(worldTransform, localPosition);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.170. m43TransformVector¶

Summary

Creates a 3 component vector initialized to the transformation as a direction of the given 3 component vector by the given 4x3 matrix.

Syntax

destination = mathDevice.m43TransformVector(matrix, vector, destination);

//example usage:
var worldNormal = mathDevice.m43TransformVector(worldTransform, localNormal);
matrix
A Matrix43 object.
vector
A Vector3 object.

destination (Optional)

Returns a Vector3 object.

### 17.6.1.171. m43SetRight¶

Summary

Sets the right element of a 4x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m43SetRight(matrix, vector);
matrix
A Matrix43 object.
vector
A Vector3 object.

### 17.6.1.172. m43SetUp¶

Summary

Sets the up element of a 4x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m43SetUp(matrix, vector);
matrix
A Matrix43 object.
vector
A Vector3 object.

### 17.6.1.173. m43SetAt¶

Summary

Sets the at element of a 4x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m43SetAt(matrix, vector);
matrix
A Matrix43 object.
vector
A Vector3 object.

### 17.6.1.174. m43SetPos¶

Summary

Sets the position element of a 4x3 matrix to the values of the given 3 component vector.

Syntax

mathDevice.m43SetPos(matrix, vector);
matrix
A Matrix43 object.
vector
A Vector3 object.

### 17.6.1.175. m43SetAxisRotation¶

Summary

Sets the 3x3 rotation component of a 4x3 matrix to the rotation defined by the given 3D axis and the given scalar angle.

Syntax

mathDevice.m43SetAxisRotation(matrix, vector, scalar);
matrix
A Matrix43 object.
vector
A Vector3 object.
scalar
A JavaScript number.

### 17.6.1.176. m44BuildIdentity¶

Summary

Creates a 4x4 matrix initialized to the identity.

Syntax

var matrix = mathDevice.m44BuildIdentity(destination);

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.177. m44Build¶

Summary

Creates a 4x4 matrix initialized to the 4 given 4 component vectors.

Syntax

var destination = mathDevice.m44Build(a, b, c, d,
e, f, g, h,
i, j, k, l,
m, n, o, p,
destination);
var destination = mathDevice.m44Build(right, up, at, pos, destination);
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p
A JavaScript number. The components of the matrix given in row column format.
right, up, at, pos
A Vector4 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.178. m44Copy¶

Summary

Copies a 4x4 matrix.

Syntax

var destination = mathDevice.m44Build(matrix, destination);
matrix
A Matrix44 object. The elements of this matrix are copied into the destination matrix.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.179. m44Mul¶

Summary

Creates a 4x4 matrix initialized to the multiplication of two other 4x4 matrices.

Syntax

destination = mathDevice.m44Mul(matrixA, matrixB, destination);

//example usage:
var newTransform = mathDevice.m44Mul(initialTransform, deltaTransform);
matrixA, matrixB
A Matrix44 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.180. m44Inverse¶

Summary

Creates a 4x4 matrix initialized to the inverse of a given non-orthonormal 4x4 matrix.

Syntax

destination = mathDevice.m44Inverse(matrix, destination);
matrix
A Matrix44 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.181. m44Transpose¶

Summary

Creates a 4x4 matrix initialized to the transpose of the given 4x4 matrix.

Syntax

destination = mathDevice.m44Transpose(matrix, destination);
matrix
A Matrix44 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.182. m44Transform¶

Summary

Creates a 4 component vector initialized to the transformation of the given 4 component vector by the given 4x4 matrix.

Syntax

destination = mathDevice.m44Transform(matrix, vector, destination);

//example usage:
var worldPosition = mathDevice.m44Transform(worldTransform, localPosition);
matrix
A Matrix44 object.
vector
A Vector4 object.

destination (Optional)

Returns a Vector4 object.

### 17.6.1.183. m44Translate¶

Summary

Adds component-wise the given 3 component vector to the position element of a 4x4 matrix.

Syntax

mathDevice.m44Translate(matrix, vector);

//example usage:
var deltaPos = mathDevice.v3Build(0, 0, 20);
mathDevice.m44Translate(worldTransform, deltaPos);
matrix
A Matrix44 object.
vector
A Vector4 object.

### 17.6.1.184. m44Scale¶

Summary

Scales up the 3x3 part of a 4x4 matrix. Each row is multiplied by each component of the scale vector.

Syntax

destination = mathDevice.m44Scale(matrix, vector, destination);

//example usage:
var vecScale = mathDevice.v4ScalarBuild(10);
mathDevice.m44Scale(matrix, vecScale, matrix);
matrix
A Matrix44 object.
vector
A Vector4 object.

destination (Optional)

Returns a Matrix44 object.

### 17.6.1.185. m44SetRight¶

Summary

Sets the right element of a 4x4 matrix to the values of the given 4 component vector.

Syntax

mathDevice.m44SetRight(matrix, vector);
matrix
A Matrix44 object.
vector
A Vector4 object.

### 17.6.1.186. m44SetUp¶

Summary

Sets the up element of a 4x4 matrix to the values of the given 4 component vector.

Syntax

mathDevice.m44SetUp(matrix, vector);
matrix
A Matrix44 object.
vector
A Vector4 object.

### 17.6.1.187. m44SetAt¶

Summary

Sets the at element of a 4x4 matrix to the values of the given 4 component vector.

Syntax

mathDevice.m44SetAt(matrix, vector);
matrix
A Matrix44 object.
vector
A Vector4 object.

### 17.6.1.188. m44SetPos¶

Summary

Sets the position element of a 4x4 matrix to the values of the given 4 component vector.

Syntax

mathDevice.m44SetPos(matrix, vector);
matrix
A Matrix44 object.
vector
A Vector4 object.

### 17.6.1.189. m44Right¶

Summary

Creates a 4 component vector initialized to the right element of the given 4x4 matrix.

Syntax

destination = mathDevice.m44Right(matrix, destination);
matrix
A Matrix44 object.

destination (Optional)

Returns a Vector4 object. This function returns the first row of the matrix.

### 17.6.1.190. m44Up¶

Summary

Creates a 4 component vector initialized to the up element of the given 4x4 matrix.

Syntax

destination = mathDevice.m44Up(matrix, destination);
matrix
A Matrix44 object.

destination (Optional)

Returns a Vector4 object. This function returns the second row of the matrix.

### 17.6.1.191. m44At¶

Summary

Creates a 4 component vector initialized to the at element of the given 4x4 matrix.

Syntax

destination = mathDevice.m44At(matrix, destination);
matrix
A Matrix44 object.

destination (Optional)

Returns a Vector4 object. This function returns the third row of the matrix.

### 17.6.1.192. m44Pos¶

Summary

Creates a 4 component vector initialized to the position element of the given 4x4 matrix.

Syntax

destination = mathDevice.m44Pos(matrix, destination);
matrix
A Matrix44 object.

destination (Optional)

Returns a Vector4 object. This function returns the fourth row of the matrix.

### 17.6.1.193. isInsidePlanesAABB¶

Summary

Returns true if the axis-aligned bounding box defined by the extents is inside the planes array.

Syntax

var boolean = mathDevice.isInsidePlanesAABB(extents, planes);

//example usage:
var isVisible = mathDevice.isInsidePlanesAABB(extents, camera.frustumPlanes);
extents
An extents object.
planes
A JavaScript array of Plane objects.

Returns a True or False.

### 17.6.1.194. isFullyInsidePlanesAABB¶

Summary

Returns true if the axis-aligned bounding box defined by the extents is fully inside the planes array.

Syntax

var boolean = mathDevice.isFullyInsidePlanesAABB(extents, planes);

//example usage:
var isVisible = mathDevice.isFullyInsidePlanesAABB(extents, camera.frustumPlanes);
extents
An extents object.
planes
A JavaScript array of Plane objects.

Returns true or false.

### 17.6.1.195. isVisibleBox¶

Summary

Returns true if the box defined by the center and half extents 3 component vectors is inside the projection space defined by the given 4x4 matrix.

Syntax

var boolean = mathDevice.isVisibleBox(center, halfExtents, matrix);

//example usage:
var isVisible = mathDevice.isVisibleBox(center, halfExtents, worldViewProjection);
center
A Vector3 object.
halfExtents
A Vector3 object.
matrix
A Matrix44 object.

Returns true or false.

### 17.6.1.196. isVisibleBoxOrigin¶

Summary

Returns true if the box located at the local origin with the given half extents 3 component vector is inside the projection space defined by the given 4x4 matrix.

Syntax

var boolean = mathDevice.isVisibleBoxOrigin(halfExtents, matrix);

//example usage:
var isVisible = mathDevice.isVisibleBoxOrigin(halfExtents, worldViewProjection);
halfExtents
A Vector3 object.
matrix
A Matrix44 object.

Returns true or false.

## 17.6.2. Properties¶

### 17.6.2.1. FLOAT_MAX¶

Summary

Largest value available to the internal representation used in the MathDevice objects.