LeapJS API Reference
Class

Leap.Matrix

Contents

class Leap.Matrix

The Matrix object represents a transformation matrix.

To use this object to transform a Vector, construct a matrix containing the desired transformation and then use the Matrix.transformPoint() or Matrix.transformDirection() functions to apply the transform.

Transforms can be combined by multiplying two or more transform matrices using the times function.

Constructor Top

  Matrix ()

Static Properties & Enumerations Top

Leap.Matrix identity

Properties Top

Leap.Vector [0]
Leap.Vector [1]
Leap.Vector [2]
Leap.Vector [3]
Leap.Vector origin
Leap.Vector xBasis
Leap.Vector yBasis
Leap.Vector zBasis

Methods Top

Boolean compare ()
Leap.Matrix rigidInverse ()
void setRotation (Leap.Vector _axis, float angleRadians)
Leap.Matrix times (Matrix other)
Array toArray3x3 ()
Array toArray4x4 ()
String toString ()
Leap.Vector transformDirection (Leap.Vector in)
Leap.Vector transformPoint (Leap.Vector in)

Constructor details Top

matrix.js at line 4
Matrix ()

Constructs a Matrix object.

Creates a new Matrix from the specified Array of Vectors or Matrix. The default constructor creates an identity matrix.

Static Properties & Enumerations Detail Top

matrix.js at line 293
static public Leap.Matrix identity

Returns the identity matrix specifying no translation, rotation, and scale.

Properties Detail Top

matrix.js at line 54
public Leap.Vector [0]

The rotation and scale factors for the x-axis.

matrix.js at line 68
public Leap.Vector [1]

The rotation and scale factors for the y-axis.

matrix.js at line 82
public Leap.Vector [2]

The rotation and scale factors for the z-axis.

matrix.js at line 96
public Leap.Vector [3]

The translation factors for all three axes.

matrix.js at line 95
public Leap.Vector origin

The translation factors for all three axes.

matrix.js at line 53
public Leap.Vector xBasis

The rotation and scale factors for the x-axis.

matrix.js at line 67
public Leap.Vector yBasis

The rotation and scale factors for the y-axis.

matrix.js at line 81
public Leap.Vector zBasis

The rotation and scale factors for the z-axis.

Methods Detail Top

matrix.js at line 275
public Boolean compare ()

Compare Matrix equality component-wise.

Return Value

Boolean

matrix.js at line 185
public Leap.Matrix rigidInverse ()

Performs a matrix inverse if the matrix consists entirely of rigid transformations (translations and rotations).

If the matrix is not rigid, this operation will not represent an inverse.

Note that all matricies that are directly returned by the API are rigid.

Return Value

Leap.Matrix

The rigid inverse of the matrix.

matrix.js at line 112
public void setRotation (Leap.Vector _axis, float angleRadians)

Sets this transformation matrix to represent a rotation around the specified vector.

This function erases any previous rotation and scale transforms applied to this matrix, but does not affect translation.

Parameters

Leap.Vector _axis

A Vector specifying the axis of rotation.

float angleRadians

The amount of rotation in radians.

Return Value

void

matrix.js at line 166
public Leap.Matrix times (Matrix other)

Multiply transform matrices.

Combines two transformations into a single equivalent transformation.

Parameters

Matrix other

A Matrix to multiply on the right hand side.

Return Value

Leap.Matrix

A new Matrix representing the transformation equivalent to applying the other transformation followed by this transformation.

matrix.js at line 206
public Array toArray3x3 ()

Writes the 3x3 Matrix object to a 9 element row-major float array.

Translation factors are discarded.

Return Value

Array

The rotation Matrix as a flattened array.

matrix.js at line 230
public Array toArray4x4 ()

Convert a 4x4 Matrix object to a 16 element row-major float array.

Translation factors are discarded.

Return Value

Array

The entire Matrix as a flattened array.

matrix.js at line 261
public String toString ()

Write the matrix to a string in a human readable format.

Return Value

String

matrix.js at line 150
public Leap.Vector transformDirection (Leap.Vector in)

Transforms a vector with this matrix by transforming its rotation and scale only.

Parameters

Leap.Vector in

The Vector to transform.

Return Value

Leap.Vector

A new Vector representing the transformed original.

matrix.js at line 135
public Leap.Vector transformPoint (Leap.Vector in)

Transforms a vector with this matrix by transforming its rotation, scale, and translation.

Translation is applied after rotation and scale.

Parameters

Leap.Vector in

The Vector to transform.

Return Value

Leap.Vector

A new Vector representing the transformed original.