InteractionBoxΒΆ

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

Inherits Interface.

Public Member Functions

Vector center () const
 The center of the InteractionBox in device coordinates (millimeters). More...
 
Vector denormalizePoint (const Vector &normalizedPosition) const
 Converts a position defined by normalized InteractionBox coordinates into device coordinates in millimeters. More...
 
float depth () const
 The depth of the InteractionBox in millimeters, measured along the z-axis. More...
 
float height () const
 The height of the InteractionBox in millimeters, measured along the y-axis. More...
 
 InteractionBox (InteractionBoxImplementation *)
 
 InteractionBox ()
 
bool isValid () const
 Reports whether this is a valid InteractionBox object. More...
 
Vector normalizePoint (const Vector &position, bool clamp=true) const
 Normalizes the coordinates of a point using the interaction box. More...
 
bool operator!= (const InteractionBox &) const
 Compare InteractionBox object inequality. More...
 
bool operator== (const InteractionBox &) const
 Compare InteractionBox object equality. More...
 
std::string toString () const
 A string containing a brief, human readable description of the InteractionBox object. More...
 
float width () const
 The width of the InteractionBox in millimeters, measured along the x-axis. More...
 

Static Public Member Functions

static const InteractionBoxinvalid ()
 Returns an invalid InteractionBox object. More...
 

Friends

std::ostream & operator<< (std::ostream &, const InteractionBox &)
 Writes a brief, human readable description of the InteractionBox object. More...
 

Detailed Description

The InteractionBox 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.

Leap_InteractionBox.png

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

Get an InteractionBox object from a Frame object.

Since
1.0

Constructor & Destructor Documentation

InteractionBox ( InteractionBoxImplementation *  )

Member Function Documentation

Vector center ( ) const

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

This point is equidistant from all sides of the box.

Vector boxCenter = interactionBox.center();
Returns
The InteractionBox center in device coordinates.
Since
1.0
Vector denormalizePoint ( const Vector normalizedPosition) const

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

InteractionBox interactionBox = frame.interactionBox();
Vector point = Vector(100, 75, -125);
Vector normalizedCoordinates = interactionBox.normalizePoint(point, false);
Vector denormalizedCoordinates = interactionBox.denormalizePoint(normalizedCoordinates);
// denormalizedCoordinates == point

This function performs the inverse of normalizePoint().

Parameters
normalizedPositionThe input position in InteractionBox coordinates.
Returns
The corresponding denormalized position in device coordinates.
Since
1.0
float depth ( ) const

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

float boxDimensionAlongZAxis = interactionBox.depth();
Returns
The InteractionBox depth in millimeters.
Since
1.0
float height ( ) const

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

float boxDimensionAlongYAxis = interactionBox.height();
Returns
The InteractionBox height in millimeters.
Since
1.0
static const InteractionBox& invalid ( )
static

Returns an invalid InteractionBox object.

You can use the instance returned by this function in comparisons testing whether a given InteractionBox instance is valid or invalid. (You can also use the InteractionBox::isValid() function.)

if (interactionBox != InteractionBox::invalid()) {
//Use the box...
}
Returns
The invalid InteractionBox instance.
Since
1.0
bool isValid ( ) const

Reports whether this is a valid InteractionBox object.

if (interactionBox.isValid()) {
//Use the box...
}
Returns
True, if this InteractionBox object contains valid data.
Since
1.0
Vector normalizePoint ( const Vector position,
bool  clamp = true 
) const

Normalizes the coordinates of a point using the interaction box.

Vector normalizedHandPosition = interactionBox.normalizePoint(hand.palmPosition());

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

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 InteractionBox. Defaults to true.
Returns
The normalized position.
Since
1.0
bool operator!= ( const InteractionBox ) const

Compare InteractionBox object inequality.

thisBox != thatBox;

Two InteractionBox objects are equal if and only if both InteractionBox objects represent the exact same InteractionBox and both InteractionBoxes are valid.

Since
1.0
bool operator== ( const InteractionBox ) const

Compare InteractionBox object equality.

thisBox == thatBox;

Two InteractionBox objects are equal if and only if both InteractionBox objects represent the exact same InteractionBox and both InteractionBoxes are valid.

Since
1.0
std::string toString ( ) const
inline

A string containing a brief, human readable description of the InteractionBox object.

Returns
A description of the InteractionBox as a string.
Since
1.0
float width ( ) const

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

float boxDimensionAlongXAxis = interactionBox.width();
Returns
The InteractionBox width in millimeters.
Since
1.0

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const InteractionBox  
)
friend

Writes a brief, human readable description of the InteractionBox object.

std::cout << interactionBox << std::endl;
Since
1.0