My favorites | English | Sign in

Try Google Chrome's developer tools New!

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

<Global>  !o3djs.math.Vector column o3djs.math
<Global>  (!Array.<!Array.<number>>|!o3d.Matrix4) Matrix o3djs.math
<Global>  !Array.<!Array.<number>> Matrix1 o3djs.math
<Global>  !Array.<!Array.<number>> Matrix2 o3djs.math
<Global>  !Array.<!Array.<number>> Matrix3 o3djs.math
<Global>  (!Array.<!Array.<number>>|!o3d.Matrix4) Matrix4 o3djs.math
<Global>  !o3djs.math.Matrix mulMatrixMatrix o3djs.math
<Global>  !o3djs.math.Matrix2 mulMatrixMatrix2 o3djs.math
<Global>  !o3djs.math.Matrix3 mulMatrixMatrix3 o3djs.math
<Global>  !o3djs.math.Matrix4 mulMatrixMatrix4 o3djs.math
<Global>  !o3djs.math.Vector mulMatrixVector o3djs.math
<Global>  !o3djs.math.Vector mulVectorMatrix o3djs.math
<Global>  !o3djs.math.Vector row o3djs.math
<Global>  !Array.<number> Vector o3djs.math
<Global>  (!Array.<number>|!o3d.Float2) Vector2 o3djs.math
<Global>  (!Array.<number>|!o3d.Float3) Vector3 o3djs.math
<Global>  (!Array.<number>|!o3d.Float4) Vector4 o3djs.math

Member Function Documentation

!o3djs.math.Matrix o3djs.math.addMatrix ( !o3djs.math.Matrix a
!o3djs.math.Matrix b )

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.
!o3djs.math.Vector o3djs.math.addVector ( !o3djs.math.Vector a
!o3djs.math.Vector 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.
number o3djs.math.codet ( !o3djs.math.Matrix a
number x
number y )

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.
!o3djs.math.Matrix o3djs.math.copyMatrix ( !o3djs.math.Matrix m )

Copies a matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix.A copy of m.
number o3djs.math.copyScalar ( number a )

Copies a scalar.

Parameters:
a The scalar.
Returns:
number.a.
!o3djs.math.Vector o3djs.math.copyVector ( !o3djs.math.Vector v )

Copies a vector.

Parameters:
v The vector.
Returns:
!o3djs.math.Vector.A copy of v.

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.
number o3djs.math.det ( !o3djs.math.Matrix m )

Computes the determinant of an arbitrary square matrix.

Parameters:
m The matrix.
Returns:
number.the determinant of m.
number o3djs.math.det1 ( !o3djs.math.Matrix1 m )

Computes the determinant of a 1-by-1 matrix.

Parameters:
m The matrix.
Returns:
number.The determinant of m.
number o3djs.math.det2 ( !o3djs.math.Matrix2 m )

Computes the determinant of a 2-by-2 matrix.

Parameters:
m The matrix.
Returns:
number.The determinant of m.
number o3djs.math.det3 ( !o3djs.math.Matrix3 m )

Computes the determinant of a 3-by-3 matrix.

Parameters:
m The matrix.
Returns:
number.The determinant of m.
number o3djs.math.det4 ( !o3djs.math.Matrix4 m )

Computes the determinant of a 4-by-4 matrix.

Parameters:
m The matrix.
Returns:
number.The determinant of m.
number o3djs.math.distance ( !o3djs.math.Vector a
!o3djs.math.Vector b )

Computes the Euclidean distance between two vectors.

Parameters:
a A vector.
b A vector.
Returns:
number.The distance between a and b.
number o3djs.math.distanceSquared ( !o3djs.math.Vector a
!o3djs.math.Vector b )

Computes the square of the Euclidean distance between two vectors.

Parameters:
a A vector.
b A vector.
Returns:
number.The distance between a and b.
!o3djs.math.Matrix o3djs.math.divMatrixScalar ( !o3djs.math.Matrix m
number k )

Divides a matrix by a scalar.

Parameters:
m The matrix.
k The scalar.
Returns:
!o3djs.math.Matrix.The matrix m divided by k.
!o3djs.math.Vector o3djs.math.divVectorScalar ( !o3djs.math.Vector v
number 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.
!o3djs.math.Vector o3djs.math.divVectorVector ( !o3djs.math.Vector a
!o3djs.math.Vector b )

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.
number o3djs.math.dot ( !o3djs.math.Vector a
!o3djs.math.Vector 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.
!Array.<number> o3djs.math.getMatrixElements ( !o3djs.math.Matrix m )

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:
m The matrix.
Returns:
!Array.<number>.The matrix's elements as a one-dimensional array.
!o3djs.math.Matrix o3djs.math.identity ( number n )

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.

!o3djs.math.Matrix o3djs.math.inverse ( !o3djs.math.Matrix m )

Computes the inverse of an arbitrary square matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix.The inverse of m.
!o3djs.math.Matrix1 o3djs.math.inverse1 ( !o3djs.math.Matrix1 m )

Computes the inverse of a 1-by-1 matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix1.The inverse of m.
!o3djs.math.Matrix2 o3djs.math.inverse2 ( !o3djs.math.Matrix2 m )

Computes the inverse of a 2-by-2 matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix2.The inverse of m.
!o3djs.math.Matrix3 o3djs.math.inverse3 ( !o3djs.math.Matrix3 m )

Computes the inverse of a 3-by-3 matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix3.The inverse of m.
!o3djs.math.Matrix4 o3djs.math.inverse4 ( !o3djs.math.Matrix4 m )

Computes the inverse of a 4-by-4 matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix4.The inverse of m.
number o3djs.math.length ( !o3djs.math.Vector a )

Computes the Euclidean length of a vector, i.e. the square root of the sum of the squares of the entries.

Parameters:
a The vector.
Returns:
number.The length of a.
number o3djs.math.lengthSquared ( !o3djs.math.Vector a )

Computes the square of the Euclidean length of a vector, i.e. the sum of the squares of the entries.

Parameters:
a The vector.
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.
!o3djs.math.Matrix o3djs.math.lerpMatrix ( !o3djs.math.Matrix a
!o3djs.math.Matrix b
number t )

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.
!o3djs.math.Vector o3djs.math.lerpVector ( !o3djs.math.Vector a
!o3djs.math.Vector b
number t )

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.
!o3djs.math.Matrix o3djs.math.mulMatrixScalar ( !o3djs.math.Matrix m
number k )

Multiplies a matrix by a scalar.

Parameters:
m The matrix.
k The scalar.
Returns:
!o3djs.math.Matrix.The product of m and k.
!o3djs.math.Matrix o3djs.math.mulScalarMatrix ( number k
!o3djs.math.Matrix m )

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.
!o3djs.math.Vector o3djs.math.mulScalarVector ( number k
!o3djs.math.Vector v )

Multiplies a scalar by a vector.

Parameters:
k The scalar.
v The vector.
Returns:
!o3djs.math.Vector.The product of k and v.
!o3djs.math.Vector o3djs.math.mulVectorScalar ( !o3djs.math.Vector v
number k )

Multiplies a vector by a scalar.

Parameters:
v The vector.
k The scalar.
Returns:
!o3djs.math.Vector.The product of k and v.
!o3djs.math.Vector o3djs.math.mulVectorVector ( !o3djs.math.Vector a
!o3djs.math.Vector b )

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.
!o3djs.math.Matrix o3djs.math.negativeMatrix ( !o3djs.math.Matrix m )

Negates a matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix.-m.
number o3djs.math.negativeScalar ( number a )

Negates a scalar.

Parameters:
a The scalar.
Returns:
number.-a.
!o3djs.math.Vector o3djs.math.negativeVector ( !o3djs.math.Vector v )

Negates a vector.

Parameters:
v The vector.
Returns:
!o3djs.math.Vector.-v.
!o3djs.math.Vector o3djs.math.normalize ( !o3djs.math.Vector a )

Divides a vector by its Euclidean length and returns the quotient.

Parameters:
a The vector.
Returns:
!o3djs.math.Vector.The normalized vector.
!o3djs.math.Matrix o3djs.math.orthonormalize ( !o3djs.math.Matrix m )

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:
m The matrix.
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.

!o3djs.math.Matrix o3djs.math.subMatrix ( !o3djs.math.Matrix a
!o3djs.math.Matrix b )

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.
!o3djs.math.Vector o3djs.math.subVector ( !o3djs.math.Vector a
!o3djs.math.Vector b )

Subtracts two vectors.

Parameters:
a Operand vector.
b Operand vector.
Returns:
!o3djs.math.Vector.The difference of a and b.
number o3djs.math.trace ( !o3djs.math.Matrix m )

Computes the trace (sum of the diagonal entries) of a square matrix; assumes m is square.

Parameters:
m The matrix.
Returns:
number.The trace of m.
!o3djs.math.Matrix o3djs.math.transpose ( !o3djs.math.Matrix m )

Takes the transpose of a matrix.

Parameters:
m The matrix.
Returns:
!o3djs.math.Matrix.The transpose of m.

Member Property Documentation

!o3djs.math.Vector o3djs.math.column

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

A 1x1 Matrix of floats

!Array.<!Array.<number>> o3djs.math.Matrix2

A 2x2 Matrix of floats

!Array.<!Array.<number>> o3djs.math.Matrix3

A 3x3 Matrix of floats

(!Array.<!Array.<number>>|!o3d.Matrix4) o3djs.math.Matrix4

A 4x4 Matrix of floats

!o3djs.math.Matrix o3djs.math.mulMatrixMatrix

Multiplies two matrices; assumes that the sizes of the matrices are appropriately compatible.

!o3djs.math.Matrix2 o3djs.math.mulMatrixMatrix2

Multiplies two 2-by-2 matrices.

!o3djs.math.Matrix3 o3djs.math.mulMatrixMatrix3

Multiplies two 3-by-3 matrices; assumes that the given matrices are 3-by-3.

!o3djs.math.Matrix4 o3djs.math.mulMatrixMatrix4

Multiplies two 4-by-4 matrices; assumes that the given matrices are 4-by-4.

!o3djs.math.Vector o3djs.math.mulMatrixVector

Multiplies a matrix by a vector; treats the vector as a column vector.

!o3djs.math.Vector o3djs.math.mulVectorMatrix

Multiplies a vector by a matrix; treats the vector as a row vector.

!o3djs.math.Vector o3djs.math.row

Gets the ith row of the given matrix m.

!Array.<number> o3djs.math.Vector

An Array of floats.

(!Array.<number>|!o3d.Float2) o3djs.math.Vector2

An Array of 2 floats

(!Array.<number>|!o3d.Float3) o3djs.math.Vector3

An Array of 3 floats

(!Array.<number>|!o3d.Float4) o3djs.math.Vector4

An Array of 4 floats