LeapMatrixΒΆ

LeapMatrix Class Reference

The LeapMatrix class represents a transformation matrix. More...

Inherits NSObject.

Instance Methods

(BOOL) - equals:
 Compare LeapMatrix equality component-wise. More...
 
(id) - initWithAxis:angleRadians:
 Constructs a transformation matrix specifying a rotation around the specified vector. More...
 
(id) - initWithAxis:angleRadians:translation:
 Constructs a transformation matrix specifying a rotation around the specified vector and a translation by the specified vector. More...
 
(id) - initWithMatrix:
 Constructs a copy of the specified Matrix object. More...
 
(id) - initWithXBasis:yBasis:zBasis:origin:
 Constructs a transformation matrix from the specified basis and translation vectors. More...
 
(LeapMatrix *) - times:
 Multiply transform matrices. More...
 
(LeapVector *) - transformDirection:
 Transforms a vector with this matrix by transforming its rotation and scale only. More...
 
(LeapVector *) - transformPoint:
 Transforms a vector with this matrix by transforming its rotation, scale, and translation. More...
 

Class Methods

(LeapMatrix *) + identity
 Returns the identity matrix specifying no translation, rotation, and scale. More...
 

Properties

LeapVectororigin
 The translation factors for all three axes. More...
 
LeapMatrixrigidInverse
 Performs a matrix inverse if the matrix consists entirely of rigid transformations (translations and rotations). More...
 
NSMutableArray * toNSArray3x3
 Converts a LeapMatrix object to a 9-element NSArray object. More...
 
NSMutableArray * toNSArray4x4
 Converts a LeapMatrix object to a 16-element NSArray object. More...
 
LeapVectorxBasis
 The rotation and scale factors for the x-axis. More...
 
LeapVectoryBasis
 The rotation and scale factors for the y-axis. More...
 
LeapVectorzBasis
 The rotation and scale factors for the z-axis. More...
 

Detailed Description

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.

Since 1.0

Method Documentation

- (BOOL) equals: (const LeapMatrix *)  other

Compare LeapMatrix equality component-wise.

bool matricesAreEqual = [thisMatrix equals:thatMatrix];
Parameters
otherThe LeapMatrix object to compare.
Returns
YES, if the corresponding elements in the two matrices are equal.
Since 1.0
+ (LeapMatrix *) identity

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

Returns
The identity matrix.
Since 1.0
- (id) initWithAxis: (const LeapVector *)  axis
angleRadians: (float)  angleRadians 

Constructs a transformation matrix specifying a rotation around the specified vector.

LeapMatrix *rotation = [[LeapMatrix alloc] initWithAxis:[LeapVector up]
angleRadians:LEAP_PI/3];
Parameters
axisA LeapVector specifying the axis of rotation.
angleRadiansThe amount of rotation in radians.
Since 1.0
- (id) initWithAxis: (const LeapVector *)  axis
angleRadians: (float)  angleRadians
translation: (const LeapVector *)  translation 

Constructs 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]];
Parameters
axisA LeapVector specifying the axis of rotation.
angleRadiansThe angle of rotation in radians.
translationA LeapVector representing the translation part of the transform.
Since 1.0
- (id) initWithMatrix: (LeapMatrix *)  matrix

Constructs a copy of the specified Matrix object.

LeapMatrix *copyMatrix = [[LeapMatrix alloc] initWithMatrix:otherMatrix];
Parameters
matrixthe LeapMatrix to copy.
Since 1.0
- (id) initWithXBasis: (const LeapVector *)  xBasis
yBasis: (const LeapVector *)  yBasis
zBasis: (const LeapVector *)  zBasis
origin: (const LeapVector *)  origin 

Constructs 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]];
Parameters
xBasisA LeapVector specifying rotation and scale factors for the x-axis.
yBasisA LeapVector specifying rotation and scale factors for the y-axis.
zBasisA LeapVector specifying rotation and scale factors for the z-axis.
originA LeapVector specifying translation factors on all three axes.
Since 1.0
- (LeapMatrix *) times: (const LeapMatrix *)  other

Multiply transform matrices.

LeapMatrix *product = [thisMatrix times:thatMatrix];

Combines two transformations into a single equivalent transformation.

Parameters
otherA LeapMatrix to multiply on the right hand side.
Returns
A new LeapMatrix representing the transformation equivalent to applying the other transformation followed by this transformation.
Since 1.0
- (LeapVector *) transformDirection: (const LeapVector *)  direction

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];
Parameters
directionThe LeapVector to transform.
Returns
A new LeapVector representing the transformed original.
Since 1.0
- (LeapVector *) transformPoint: (const LeapVector *)  point

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];
Parameters
pointA LeapVector representing the 3D position to transform.
Returns
A new LeapVector representing the transformed original.
Since 1.0

Property Documentation

- (LeapVector*) origin
readwritenonatomicstrong

The translation factors for all three axes.

LeapVector *origin = matrix.origin;
Since 1.0
- (LeapMatrix*) rigidInverse
readnonatomicassign

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.

LeapMatrix *rigidInverse = [matrix rigidInverse];

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

Returns
The rigid inverse of the matrix.
Since 1.0
- (NSMutableArray*) toNSArray3x3
readnonatomicassign

Converts 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
- (NSMutableArray*) toNSArray4x4
readnonatomicassign

Converts 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
- (LeapVector*) xBasis
readwritenonatomicstrong

The rotation and scale factors for the x-axis.

LeapVector *xBasis = matrix.xBasis;
Since 1.0
- (LeapVector*) yBasis
readwritenonatomicstrong

The rotation and scale factors for the y-axis.

LeapVector *yBasis = matrix.yBasis;
Since 1.0
- (LeapVector*) zBasis
readwritenonatomicstrong

The rotation and scale factors for the z-axis.

LeapVector *zBasis = matrix.zBasis;
Since 1.0