o3djs.math Module Reference
List of all members.
Detailed Description
A module for math for o3djs.math.
Source
o3djs/math.js
Public Member Functions
|
!o3djs.math.Matrix
|
addMatrix(a, b)
|
o3djs.math |
|
!o3djs.math.Vector
|
addVector(a, b)
|
o3djs.math |
|
number
|
codet(a, x, y)
|
o3djs.math |
|
!o3djs.math.Matrix
|
copyMatrix(m)
|
o3djs.math |
|
number
|
copyScalar(a)
|
o3djs.math |
|
!o3djs.math.Vector
|
copyVector(v)
|
o3djs.math |
|
!o3djs.math.Vector
|
cross(a, b)
|
o3djs.math |
|
number
|
degToRad(degrees)
|
o3djs.math |
|
number
|
det(m)
|
o3djs.math |
|
number
|
det1(m)
|
o3djs.math |
|
number
|
det2(m)
|
o3djs.math |
|
number
|
det3(m)
|
o3djs.math |
|
number
|
det4(m)
|
o3djs.math |
|
number
|
distance(a, b)
|
o3djs.math |
|
number
|
distanceSquared(a, b)
|
o3djs.math |
|
!o3djs.math.Matrix
|
divMatrixScalar(m, k)
|
o3djs.math |
|
!o3djs.math.Vector
|
divVectorScalar(v, k)
|
o3djs.math |
|
!o3djs.math.Vector
|
divVectorVector(a, b)
|
o3djs.math |
|
number
|
dot(a, b)
|
o3djs.math |
|
!Array.<number>
|
getMatrixElements(m)
|
o3djs.math |
|
!o3djs.math.Matrix
|
identity(n)
|
o3djs.math |
|
|
installColumnMajorFunctions()
|
o3djs.math |
|
|
installErrorCheckFreeFunctions()
|
o3djs.math |
|
|
installErrorCheckFunctions()
|
o3djs.math |
|
|
installRowMajorFunctions()
|
o3djs.math |
|
!o3djs.math.Matrix
|
inverse(m)
|
o3djs.math |
|
!o3djs.math.Matrix1
|
inverse1(m)
|
o3djs.math |
|
!o3djs.math.Matrix2
|
inverse2(m)
|
o3djs.math |
|
!o3djs.math.Matrix3
|
inverse3(m)
|
o3djs.math |
|
!o3djs.math.Matrix4
|
inverse4(m)
|
o3djs.math |
|
number
|
length(a)
|
o3djs.math |
|
number
|
lengthSquared(a)
|
o3djs.math |
|
number
|
lerpCircular(a, b, t, range)
|
o3djs.math |
|
!o3djs.math.Matrix
|
lerpMatrix(a, b, t)
|
o3djs.math |
|
number
|
lerpRadian(a, b, t)
|
o3djs.math |
|
number
|
lerpScalar(a, b, t)
|
o3djs.math |
|
!o3djs.math.Vector
|
lerpVector(a, b, t)
|
o3djs.math |
|
number
|
modClamp(v, range, opt_rangeStart)
|
o3djs.math |
|
!o3djs.math.Matrix
|
mulMatrixScalar(m, k)
|
o3djs.math |
|
!o3djs.math.Matrix
|
mulScalarMatrix(k, m)
|
o3djs.math |
|
number
|
mulScalarScalar(a, b)
|
o3djs.math |
|
!o3djs.math.Vector
|
mulScalarVector(k, v)
|
o3djs.math |
|
!o3djs.math.Vector
|
mulVectorScalar(v, k)
|
o3djs.math |
|
!o3djs.math.Vector
|
mulVectorVector(a, b)
|
o3djs.math |
|
!o3djs.math.Matrix
|
negativeMatrix(m)
|
o3djs.math |
|
number
|
negativeScalar(a)
|
o3djs.math |
|
!o3djs.math.Vector
|
negativeVector(v)
|
o3djs.math |
|
!o3djs.math.Vector
|
normalize(a)
|
o3djs.math |
|
!o3djs.math.Matrix
|
orthonormalize(m)
|
o3djs.math |
|
number
|
pseudoRandom()
|
o3djs.math |
|
number
|
radToDeg(radians)
|
o3djs.math |
|
|
resetPseudoRandom()
|
o3djs.math |
|
!o3djs.math.Matrix
|
subMatrix(a, b)
|
o3djs.math |
|
!o3djs.math.Vector
|
subVector(a, b)
|
o3djs.math |
|
number
|
trace(m)
|
o3djs.math |
|
!o3djs.math.Matrix
|
transpose(m)
|
o3djs.math |
Public Properties
Member Function Documentation
Adds two matrices; assumes a and b are the same size.
- Parameters:
-
| a |
Operand matrix. |
| b |
Operand matrix. |
- Returns:
-
!o3djs.math.Matrix.The sum of a and b.
Adds two vectors; assumes a and b have the same dimension.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
- Returns:
-
!o3djs.math.Vector.The sum of a and b.
Computes the determinant of the cofactor matrix obtained by removal
of a specified row and column. This is a helper function for the general
determinant and matrix inversion functions.
- Parameters:
-
| a |
The original matrix. |
| x |
The row to be removed. |
| y |
The column to be removed. |
- Returns:
-
number.The determinant of the matrix obtained by removing
row x and column y from a.
| number o3djs.math.copyScalar |
( |
number |
a |
) |
|
Copies a scalar.
- Parameters:
-
- Returns:
-
number.a.
Computes the cross product of two vectors; assumes both vectors have
three entries.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
- Returns:
-
!o3djs.math.Vector.The vector a cross b.
| number o3djs.math.degToRad |
( |
number |
degrees |
) |
|
Converts degrees to radians.
- Parameters:
-
| degrees |
A value in degrees. |
- Returns:
-
number.the value in radians.
Computes the determinant of an arbitrary square matrix.
- Parameters:
-
- Returns:
-
number.the determinant of m.
Computes the determinant of a 1-by-1 matrix.
- Parameters:
-
- Returns:
-
number.The determinant of m.
Computes the determinant of a 2-by-2 matrix.
- Parameters:
-
- Returns:
-
number.The determinant of m.
Computes the determinant of a 3-by-3 matrix.
- Parameters:
-
- Returns:
-
number.The determinant of m.
Computes the determinant of a 4-by-4 matrix.
- Parameters:
-
- Returns:
-
number.The determinant of m.
Computes the Euclidean distance between two vectors.
- Parameters:
-
- Returns:
-
number.The distance between a and b.
Computes the square of the Euclidean distance between two vectors.
- Parameters:
-
- Returns:
-
number.The distance between a and b.
Divides a matrix by a scalar.
- Parameters:
-
| m |
The matrix. |
| k |
The scalar. |
- Returns:
-
!o3djs.math.Matrix.The matrix m divided by k.
Divides a vector by a scalar.
- Parameters:
-
| v |
The vector. |
| k |
The scalar. |
- Returns:
-
!o3djs.math.Vector.v The vector v divided by k.
Divides a vector by another vector (component-wise); assumes a and
b have the same length.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
- Returns:
-
!o3djs.math.Vector.The vector of quotients of entries of a and
b.
Computes the dot product of two vectors; assumes that a and b have
the same dimension.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
- Returns:
-
number.The dot product of a and b.
Returns the elements of a matrix as a one-dimensional array. The
rows or columns (depending on whether the matrix is row-major or
column-major) are concatenated.
- Parameters:
-
- Returns:
-
!Array.<number>.The matrix's elements as a one-dimensional array.
Creates an n-by-n identity matrix.
- Parameters:
-
| n |
The dimension of the identity matrix required. |
- Returns:
-
!o3djs.math.Matrix.An n-by-n identity matrix.
| o3djs.math.installColumnMajorFunctions |
( |
|
|
) |
|
Sets each function in the namespace o3djs.math to the column major
version in o3djs.math.columnMajor (provided such a function exists in
o3djs.math.columnMajor). Call this function to establish the column
major convention.
| o3djs.math.installErrorCheckFreeFunctions |
( |
|
|
) |
|
Sets each function in the namespace o3djs.math to the error checking free
version in o3djs.math.errorCheckFree (provided such a function exists in
o3djs.math.errorCheckFree).
| o3djs.math.installErrorCheckFunctions |
( |
|
|
) |
|
Sets each function in the namespace o3djs.math to the error checking
version in o3djs.math.errorCheck (provided such a function exists in
o3djs.math.errorCheck).
| o3djs.math.installRowMajorFunctions |
( |
|
|
) |
|
Sets each function in the namespace o3djs.math to the row major
version in o3djs.math.rowMajor (provided such a function exists in
o3djs.math.rowMajor). Call this function to establish the row major
convention.
Computes the inverse of an arbitrary square matrix.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix.The inverse of m.
Computes the inverse of a 1-by-1 matrix.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix1.The inverse of m.
Computes the inverse of a 2-by-2 matrix.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix2.The inverse of m.
Computes the inverse of a 3-by-3 matrix.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix3.The inverse of m.
Computes the inverse of a 4-by-4 matrix.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix4.The inverse of m.
Computes the Euclidean length of a vector, i.e. the square root of the
sum of the squares of the entries.
- Parameters:
-
- Returns:
-
number.The length of a.
Computes the square of the Euclidean length of a vector, i.e. the sum
of the squares of the entries.
- Parameters:
-
- Returns:
-
number.The square of the length of a.
| number o3djs.math.lerpCircular |
( |
number |
a |
|
|
|
|
number |
b |
|
|
|
|
number |
t |
|
|
|
|
number |
range |
) |
|
Lerps in a circle.
Does a lerp between a and b but inside range so for example if
range is 100, a is 95 and b is 5 lerping will go in the positive direction.
- Parameters:
-
| a |
Start value. |
| b |
Target value. |
| t |
Amount to lerp (0 to 1). |
| range |
Range of circle. |
- Returns:
-
number.lerped result.
Performs linear interpolation on two matrices.
Given matrices a and b and interpolation coefficient t, returns
(1 - t) * a + t * b.
- Parameters:
-
| a |
Operand matrix. |
| b |
Operand matrix. |
| t |
Interpolation coefficient. |
- Returns:
-
!o3djs.math.Matrix.The weighted of a and b.
| number o3djs.math.lerpRadian |
( |
number |
a |
|
|
|
|
number |
b |
|
|
|
|
number |
t |
) |
|
Lerps radians.
- Parameters:
-
| a |
Start value. |
| b |
Target value. |
| t |
Amount to lerp (0 to 1). |
- Returns:
-
number.lerped result.
| number o3djs.math.lerpScalar |
( |
number |
a |
|
|
|
|
number |
b |
|
|
|
|
number |
t |
) |
|
Performs linear interpolation on two scalars.
Given scalars a and b and interpolation coefficient t, returns
(1 - t) * a + t * b.
- Parameters:
-
| a |
Operand scalar. |
| b |
Operand scalar. |
| t |
Interpolation coefficient. |
- Returns:
-
number.The weighted sum of a and b.
Performs linear interpolation on two vectors.
Given vectors a and b and interpolation coefficient t, returns
(1 - t) * a + t * b.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
| t |
Interpolation coefficient. |
- Returns:
-
!o3djs.math.Vector.The weighted sum of a and b.
| number o3djs.math.modClamp |
( |
number |
v |
|
|
|
|
number |
range |
|
|
|
|
number |
opt_rangeStart |
) |
|
Clamps a value between 0 and range using a modulo.
- Parameters:
-
| v |
Value to clamp mod. |
| range |
Range to clamp to. |
| opt_rangeStart |
start of range. Default = 0. |
- Returns:
-
number.Clamp modded value.
Multiplies a matrix by a scalar.
- Parameters:
-
| m |
The matrix. |
| k |
The scalar. |
- Returns:
-
!o3djs.math.Matrix.The product of m and k.
Multiplies a scalar by a matrix.
- Parameters:
-
| k |
The scalar. |
| m |
The matrix. |
- Returns:
-
!o3djs.math.Matrix.The product of m and k.
| number o3djs.math.mulScalarScalar |
( |
number |
a |
|
|
|
|
number |
b |
) |
|
Multiplies two scalars.
- Parameters:
-
| a |
Operand scalar. |
| b |
Operand scalar. |
- Returns:
-
number.The product of a and b.
Multiplies a scalar by a vector.
- Parameters:
-
| k |
The scalar. |
| v |
The vector. |
- Returns:
-
!o3djs.math.Vector.The product of k and v.
Multiplies a vector by a scalar.
- Parameters:
-
| v |
The vector. |
| k |
The scalar. |
- Returns:
-
!o3djs.math.Vector.The product of k and v.
Multiplies a vector by another vector (component-wise); assumes a and
b have the same length.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
- Returns:
-
!o3djs.math.Vector.The vector of products of entries of a and
b.
| number o3djs.math.negativeScalar |
( |
number |
a |
) |
|
Negates a scalar.
- Parameters:
-
- Returns:
-
number.-a.
Divides a vector by its Euclidean length and returns the quotient.
- Parameters:
-
- Returns:
-
!o3djs.math.Vector.The normalized vector.
Performs Graham-Schmidt orthogonalization on the vectors which make up the
given matrix and returns the result in the rows of a new matrix. When
multiplying many orthogonal matrices together, errors can accumulate causing
the product to fail to be orthogonal. This function can be used to correct
that.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix.A matrix whose rows are obtained from the
rows of m by the Graham-Schmidt process.
| o3djs.math.pseudoRandom |
( |
|
|
) |
|
Returns a deterministic pseudorandom number between 0 and 1
- Returns:
-
number.a random number between 0 and 1
| number o3djs.math.radToDeg |
( |
number |
radians |
) |
|
Converts radians to degrees.
- Parameters:
-
| radians |
A value in radians. |
- Returns:
-
number.the value in degrees.
| o3djs.math.resetPseudoRandom |
( |
|
|
) |
|
Resets the pseudoRandom function sequence.
Subtracts two matrices; assumes a and b are the same size.
- Parameters:
-
| a |
Operand matrix. |
| b |
Operand matrix. |
- Returns:
-
!o3djs.math.Matrix.The sum of a and b.
Subtracts two vectors.
- Parameters:
-
| a |
Operand vector. |
| b |
Operand vector. |
- Returns:
-
!o3djs.math.Vector.The difference of a and b.
Computes the trace (sum of the diagonal entries) of a square matrix;
assumes m is square.
- Parameters:
-
- Returns:
-
number.The trace of m.
Takes the transpose of a matrix.
- Parameters:
-
- Returns:
-
!o3djs.math.Matrix.The transpose of m.
Member Property Documentation
Gets the jth column of the given matrix m.
| (!Array.<!Array.<number>>|!o3d.Matrix4) o3djs.math.Matrix
|
A arbitrary size Matrix of floats
| !Array.<!Array.<number>> o3djs.math.Matrix1
|
| !Array.<!Array.<number>> o3djs.math.Matrix2
|
| !Array.<!Array.<number>> o3djs.math.Matrix3
|
| (!Array.<!Array.<number>>|!o3d.Matrix4) o3djs.math.Matrix4
|
Multiplies two matrices; assumes that the sizes of the matrices are
appropriately compatible.
Multiplies two 2-by-2 matrices.
Multiplies two 3-by-3 matrices; assumes that the given matrices are 3-by-3.
Multiplies two 4-by-4 matrices; assumes that the given matrices are 4-by-4.
Multiplies a matrix by a vector; treats the vector as a column vector.
Multiplies a vector by a matrix; treats the vector as a row vector.
Gets the ith row of the given matrix m.
| !Array.<number> o3djs.math.Vector
|