LeapMatrixΒΆ
Properties:
Methods:
The LeapMatrix class represents a transformation matrix.
To use this class to transform a LeapVector, construct a matrix containing the desired transformation and then use the [LeapMatrix transformPoint:] or [LeapMatrix transformDirection:] functions to apply the transform.
Transforms can be combined by multiplying two or more transform matrices using the [LeapMatrix times:] function.
Public Functions
- Since 1.0
Property- (BOOL) equals:(const LeapMatrix *) otherCompare LeapMatrix equality component-wise.
bool matricesAreEqual = [thisMatrix equals:thatMatrix];
- Return
- YES, if the corresponding elements in the two matrices are equal.
- Since 1.0
- Parameters
- other -
The LeapMatrix object to compare.
- (id) initWithAxis:(const LeapVector *) axis angleRadians:(float) angleRadiansConstructs a transformation matrix specifying a rotation around the specified vector.
LeapMatrix *rotation = [[LeapMatrix alloc] initWithAxis:[LeapVector up] angleRadians:LEAP_PI/3];
- Since 1.0
- Parameters
- axis -
A LeapVector specifying the axis of rotation.
- angleRadians -
The amount of rotation in radians.
- (id) initWithAxis:(const LeapVector *) axis angleRadians:(float) angleRadians translation:(const LeapVector *) translationConstructs a transformation matrix specifying a rotation around the specified vector and a translation by the specified vector.
LeapMatrix *transform = [[LeapMatrix alloc] initWithAxis:[LeapVector zAxis] angleRadians:LEAP_PI translation:[[LeapVector alloc] initWithX:5 y:3 z:1]];
- Since 1.0
- Parameters
- axis -
A LeapVector specifying the axis of rotation.
- angleRadians -
The angle of rotation in radians.
- translation -
A LeapVector representing the translation part of the transform.
- (id) initWithMatrix:(LeapMatrix *) matrixConstructs a copy of the specified Matrix object.
LeapMatrix *copyMatrix = [[LeapMatrix alloc] initWithMatrix:otherMatrix];
- Since 1.0
- Parameters
- matrix -
the LeapMatrix to copy.
- (id) initWithXBasis:(const LeapVector *) xBasis yBasis:(const LeapVector *) yBasis zBasis:(const LeapVector *) zBasis origin:(const LeapVector *) originConstructs a transformation matrix from the specified basis and translation vectors.
LeapMatrix *newMatrix = [[LeapMatrix alloc] initWithXBasis:[LeapVector xAxis] yBasis:[LeapVector yAxis] zBasis:[LeapVector zAxis] origin:[LeapVector zero]];
- Since 1.0
- Parameters
- xBasis -
A LeapVector specifying rotation and scale factors for the x-axis.
- yBasis -
A LeapVector specifying rotation and scale factors for the y-axis.
- zBasis -
A LeapVector specifying rotation and scale factors for the z-axis.
- origin -
A LeapVector specifying translation factors on all three axes.
Multiply transform matrices.
LeapMatrix *product = [thisMatrix times:thatMatrix];Combines two transformations into a single equivalent transformation.
- Return
- A new LeapMatrix representing the transformation equivalent to applying the other transformation followed by this transformation.
- Since 1.0
- Parameters
- other -
A LeapMatrix to multiply on the right hand side.
Transforms a vector with this matrix by transforming its rotation and scale only.
LeapVector *direction = [[LeapVector alloc] initWithX:-13 y:87 z:42]; LeapVector *transformedDirection = [thisMatrix transformPoint:point];
- Return
- A new LeapVector representing the transformed original.
- Since 1.0
- Parameters
- direction -
The LeapVector to transform.
Transforms a vector with this matrix by transforming its rotation, scale, and translation.
Translation is applied after rotation and scale.
LeapVector *point = [[LeapVector alloc] initWithX:10 y:100 z:-30]; LeapVector *transformedPoint = [thisMatrix transformPoint:point];
- Return
- A new LeapVector representing the transformed original.
- Since 1.0
- Parameters
- point -
A LeapVector representing the 3D position to transform.
Public Static Functionsorigin- (LeapVector *) originrigidInverse- (LeapMatrix *) rigidInversePerforms 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.
LeapMatrix *rigidInverse = [matrix rigidInverse];Note that all matricies that are directly returned by the API are rigid.
- Return
- The rigid inverse of the matrix.
- Since 1.0
toNSArray3x3- (NSMutableArray *) toNSArray3x3Converts a LeapMatrix object to a 9-element NSArray object.
The elements of the matrix are inserted into the array in row-major order.
NSArray *matrix3x3Array = thisMatrix.toNSArray3x3; float R2C1 = [[matrix3x3Array objectAtIndex:4] floatValue];Translation factors are discarded.
- Since 1.0
toNSArray4x4- (NSMutableArray *) toNSArray4x4Converts a LeapMatrix object to a 16-element NSArray object.
The elements of the matrix are inserted into the array in row-major order.
NSArray *matrix4x4Array = thisMatrix.toNSArray4x4; float R4C3 = [[matrix4x4Array objectAtIndex:15] floatValue];
- Since 1.0
xBasis- (LeapVector *) xBasisyBasis- (LeapVector *) yBasiszBasis- (LeapVector *) zBasis+ (LeapMatrix *) identityReturns the identity matrix specifying no translation, rotation, and scale.
LeapMatrix *identity = [LeapMatrix identity];
- Return
- The identity matrix.
- Since 1.0