LeapMatrixΒΆ

Properties:

Methods:

class LeapMatrix

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

Public Functions


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

Compare 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


- (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];

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 *) 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]];

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 *) matrix

Constructs a copy of the specified Matrix object.

LeapMatrix *copyMatrix = [[LeapMatrix alloc] initWithMatrix:otherMatrix];

Since 1.0
Parameters


- (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]];

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.


- (LeapMatrix *) times:(const LeapMatrix *) other

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.


- (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];

Return
A new LeapVector representing the transformed original.
Since 1.0
Parameters


- (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];

Return
A new LeapVector representing the transformed original.
Since 1.0
Parameters
  • point -

    A LeapVector representing the 3D position to transform.

Property


- (LeapVector *) origin
origin

The translation factors for all three axes.

LeapVector *origin = matrix.origin;

Since 1.0


- (LeapMatrix *) rigidInverse
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.

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


- (NSMutableArray *) toNSArray3x3
toNSArray3x3

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
toNSArray4x4

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
xBasis

The rotation and scale factors for the x-axis.

LeapVector *xBasis = matrix.xBasis;

Since 1.0


- (LeapVector *) yBasis
yBasis

The rotation and scale factors for the y-axis.

LeapVector *yBasis = matrix.yBasis;

Since 1.0


- (LeapVector *) zBasis
zBasis

The rotation and scale factors for the z-axis.

LeapVector *zBasis = matrix.zBasis;

Since 1.0

Public Static Functions


+ (LeapMatrix *) identity

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

LeapMatrix *identity = [LeapMatrix identity];

Return
The identity matrix.
Since 1.0