LeapInteractionBoxΒΆ

LeapInteractionBox Class Reference

The LeapInteractionBox class represents a box-shaped region completely within the field of view of the Leap Motion controller. More...

Inherits NSObject.

Instance Methods

(LeapVector *) - denormalizePoint:
 Converts a position defined by normalized LeapInteractionBox coordinates into device coordinates in millimeters. More...
 
(BOOL) - equals:
 Reports whether this is a valid LeapInteractionBox object. More...
 
(LeapVector *) - normalizePoint:clamp:
 Normalizes the coordinates of a point using the interaction box. More...
 

Class Methods

(LeapInteractionBox *) + invalid
 Returns an invalid LeapInteractionBox object. More...
 

Properties

LeapVectorcenter
 The center of the LeapInteractionBox in device coordinates (millimeters). More...
 
float depth
 The depth of the LeapInteractionBox in millimeters, measured along the z-axis. More...
 
float height
 The height of the LeapInteractionBox in millimeters, measured along the y-axis. More...
 
BOOL isValid
 Reports whether this is a valid LeapInteractionBox object. More...
 
float width
 The width of the LeapInteractionBox in millimeters, measured along the x-axis. More...
 

Detailed Description

The LeapInteractionBox class represents a box-shaped region completely within the field of view of the Leap Motion controller.

The interaction box is an axis-aligned rectangular prism and provides normalized coordinates for hands, fingers, and tools within this box. The InteractionBox class can make it easier to map positions in the Leap Motion coordinate system to 2D or 3D coordinate systems used for application drawing.

The LeapInteractionBox region is defined by a center and dimensions along the x, y, and z axes.

LeapInteractionBox *interactionBox = frame.interactionBox;
Since 1.0

Method Documentation

- (LeapVector *) denormalizePoint: (const LeapVector *)  position

Converts a position defined by normalized LeapInteractionBox coordinates into device coordinates in millimeters.

LeapVector *normalizedPoint =
[[LeapVector alloc] initWithX:.23 y:.87 z:.67];
LeapVector *leapCoordinates =
[frame.interactionBox denormalizePoint:normalizedPoint];

This function performs the inverse of [LeapInteractionBox normalizePoint:].

Parameters
positionA normalized position in LeapInteractionBox coordinates.
Returns
The corresponding denormalized position in device coordinates.
Since 1.0
- (BOOL) equals: (const LeapInteractionBox *)  other

Reports whether this is a valid LeapInteractionBox object.

[thisBox equals:thatBox];
Returns
True, if this LeapInteractionBox object contains valid data.
Since 1.0
+ (LeapInteractionBox *) invalid

Returns an invalid LeapInteractionBox object.

Returns
The invalid InteractionBox instance.
Since 1.0
- (LeapVector *) normalizePoint: (const LeapVector *)  position
clamp: (BOOL)  clamp 

Normalizes the coordinates of a point using the interaction box.

Coordinates from the Leap frame of reference (millimeters) are converted to a range of [0..1] such that the minimum value of the LeapInteractionBox maps to 0 and the maximum value of the LeapInteractionBox maps to 1.

int displayWidth = 680;
int displayHeight = 400;
LeapVector *point =
[[LeapVector alloc] initWithX:-75 y:234 z:0];
LeapVector *normalized =
[frame.interactionBox normalizePoint:point clamp:YES];
int displayX = normalized.x * displayWidth;
int displayY = (1 - normalized.y) * displayHeight;
Parameters
positionThe input position in device coordinates.
clampWhether or not to limit the output value to the range [0,1] when the input position is outside the LeapInteractionBox. Defaults to true.
Returns
The normalized position.
Since 1.0

Property Documentation

- (LeapVector*) center
readnonatomicassign

The center of the LeapInteractionBox in device coordinates (millimeters).

This point is equidistant from all sides of the box.

LeapVector *center = interactionBox.center;
Returns
The LeapInteractionBox center in device coordinates.
Since 1.0
- (float) depth
readnonatomicassign

The depth of the LeapInteractionBox in millimeters, measured along the z-axis.

float depth = interactionBox.depth;
Returns
The LeapInteractionBox depth in millimeters.
Since 1.0
- (float) height
readnonatomicassign

The height of the LeapInteractionBox in millimeters, measured along the y-axis.

float height = interactionBox.height;
Returns
The LeapInteractionBox height in millimeters.
Since 1.0
- (BOOL) isValid
readnonatomicassign

Reports whether this is a valid LeapInteractionBox object.

if(interactionBox.isValid){
//Use the data...
}
Returns
True, if this LeapInteractionBox object contains valid data.
Since 1.0
- (float) width
readnonatomicassign

The width of the LeapInteractionBox in millimeters, measured along the x-axis.

float width = interactionBox.width;
Returns
The LeapInteractionBox width in millimeters.
Since 1.0