Methods:
The Matrix struct represents a transformation matrix.
To use this struct 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 * operator.
Public Functions
- Since
- 1.0
Public Static Functionsboolean equals(Matrix other)Vector getOrigin()The translation factors for all three axes.
Vector thisTranslation = thisMatrix.getOrigin();
- Since
- 1.0
Vector getXBasis()The basis vector for the x-axis.
Vector xTransform = thisMatrix.getXBasis();
- Since
- 1.0
Vector getYBasis()The basis vector for the y-axis.
Vector yTransform = thisMatrix.getYBasis();
- Since
- 1.0
Vector getZBasis()The basis vector for the z-axis.
Vector zTransform = thisMatrix.getZBasis();
- Since
- 1.0
Matrix()Matrix(Matrix other)
Constructs a transformation matrix from the specified basis and translation vectors.
Hand leapHand = frame.hand(handID); Vector handXBasis = leapHand.palmNormal().cross(leapHand.direction()).normalized(); Vector handYBasis = leapHand.palmNormal().opposite(); Vector handZBasis = leapHand.direction().opposite(); Vector handOrigin = leapHand.palmPosition(); Matrix handTransform = new Matrix(handXBasis, handYBasis, handZBasis, handOrigin);
- Since
- 1.0
- Parameters
Matrix(Vector axis, float angleRadians)Constructs a transformation matrix specifying a rotation around the specified vector.
Vector axisOfRotation = leapHand.direction(); float angleOfRotation = 1.27f; Matrix rotator = new Matrix(axisOfRotation, angleOfRotation);
- Since
- 1.0
- Parameters
- axis -
A Vector specifying the axis of rotation.
- angleRadians -
The amount of rotation in radians.
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.
thisMatrix = thatMatrix.rigidInverse();Note that all matrices that are directly returned by the API are rigid.
- Return
- The rigid inverse of the matrix.
- Since
- 1.0
void setOrigin(Vector value)The translation factors for all three axes.
Vector thisTranslation = thisMatrix.getOrigin();
- Since
- 1.0
void setRotation(Vector axis, float angleRadians)Sets this transformation matrix to represent a rotation around the specified vector.
thisMatrix.setRotation(Vector.zAxis(), 1.46f);This function erases any previous rotation and scale transforms applied to this matrix, but does not affect translation.
- Since
- 1.0
- Parameters
- axis -
A Vector specifying the axis of rotation.
- angleRadians -
The amount of rotation in radians.
void setXBasis(Vector value)The basis vector for the x-axis.
Vector xTransform = thisMatrix.getXBasis();
- Since
- 1.0
void setYBasis(Vector value)The basis vector for the y-axis.
Vector yTransform = thisMatrix.getYBasis();
- Since
- 1.0
void setZBasis(Vector value)The basis vector for the z-axis.
Vector zTransform = thisMatrix.getZBasis();
- Since
- 1.0
Multiply transform matrices.
Combines two transformations into a single equivalent transformation.
thisMatrix.times(thatMatrix);String toString()Write the matrix to a string in a human readable format.
- Since
- 1.0
Transforms a vector with this matrix by transforming its rotation, scale, and translation.
Vector newPosition = thisMatrix.transformPoint(oldPosition);Translation is applied after rotation and scale.