Leap Motion C++ API Reference  0.8.0
Leap::Pointable Class Reference

The Pointable class reports the physical characteristics of a detected finger or tool. More...

Inherits Leap::Interface.

Inherited by Leap::Finger, and Leap::Tool.

Public Types

enum  Zone { ZONE_NONE = 0, ZONE_HOVERING = 1, ZONE_TOUCHING = 2 }
 Defines the values for reporting the state of a Pointable object in relation to an adaptive touch plane. More...
 

Public Member Functions

Vector direction () const
 The direction in which this finger or tool is pointing.
 
Frame frame () const
 The Frame associated with this Pointable object.
 
Hand hand () const
 The Hand associated with this finger or tool.
 
int32_t id () const
 A unique ID assigned to this Pointable object, whose value remains the same across consecutive frames while the tracked finger or tool remains visible.
 
bool isFinger () const
 Whether or not the Pointable is believed to be a finger.
 
bool isTool () const
 Whether or not the Pointable is believed to be a tool.
 
bool isValid () const
 Reports whether this is a valid Pointable object.
 
float length () const
 The estimated length of the finger or tool in millimeters.
 
bool operator!= (const Pointable &) const
 Compare Pointable object inequality.
 
bool operator== (const Pointable &) const
 Compare Pointable object equality.
 
 Pointable ()
 Constructs a Pointable object.
 
Vector stabilizedTipPosition () const
 The stabilized tip position of this Pointable.
 
Vector tipPosition () const
 The tip position in millimeters from the Leap Motion origin.
 
Vector tipVelocity () const
 The rate of change of the tip position in millimeters/second.
 
std::string toString () const
 A string containing a brief, human readable description of the Pointable object.
 
float touchDistance () const
 A value proportional to the distance between this Pointable object and the adaptive touch plane.
 
Zone touchZone () const
 The current touch zone of this Pointable object.
 
float width () const
 The estimated width of the finger or tool in millimeters.
 

Static Public Member Functions

static const Pointableinvalid ()
 Returns an invalid Pointable object.
 

Friends

std::ostream & operator<< (std::ostream &, const Pointable &)
 Writes a brief, human readable description of the Pointable object to an output stream.
 

Detailed Description

The Pointable class reports the physical characteristics of a detected finger or tool.

Both fingers and tools are classified as Pointable objects. Use the Pointable::isFinger() function to determine whether a Pointable object represents a finger. Use the Pointable::isTool() function to determine whether a Pointable object represents a tool. The Leap Motion software classifies a detected entity as a tool when it is thinner, straighter, and longer than a typical finger.

To provide touch emulation, the Leap Motion software associates a floating touch plane that adapts to the user's finger movement and hand posture. The Leap Motion interprets purposeful movements toward this plane as potential touch points. The Pointable class reports touch state with the touchZone and touchDistance values.

Note that Pointable objects can be invalid, which means that they do not contain valid tracking data and do not correspond to a physical entity. Invalid Pointable objects can be the result of asking for a Pointable object using an ID from an earlier frame when no Pointable objects with that ID exist in the current frame. A Pointable object created from the Pointable constructor is also invalid. Test for validity with the Pointable::isValid() function.

Member Enumeration Documentation

Defines the values for reporting the state of a Pointable object in relation to an adaptive touch plane.

Enumerator:
ZONE_NONE 

The Pointable object is too far from the plane to be considered hovering or touching.

ZONE_HOVERING 

The Pointable object is close to, but not touching the plane.

ZONE_TOUCHING 

The Pointable has penetrated the plane.

Constructor & Destructor Documentation

Leap::Pointable::Pointable ( )

Constructs a Pointable object.

An uninitialized pointable is considered invalid. Get valid Pointable objects from a Frame or a Hand object.

Member Function Documentation

Vector Leap::Pointable::direction ( ) const

The direction in which this finger or tool is pointing.

The direction is expressed as a unit vector pointing in the same direction as the tip.

Leap_Finger_Model.png
Returns
The Vector pointing in the same direction as the tip of this Pointable object.
Frame Leap::Pointable::frame ( ) const

The Frame associated with this Pointable object.

Returns
The associated Frame object, if available; otherwise, an invalid Frame object is returned.
Hand Leap::Pointable::hand ( ) const

The Hand associated with this finger or tool.

Returns
The associated Hand object, if available; otherwise, an invalid Hand object is returned.
int32_t Leap::Pointable::id ( ) const

A unique ID assigned to this Pointable object, whose value remains the same across consecutive frames while the tracked finger or tool remains visible.

If tracking is lost (for example, when a finger is occluded by another finger or when it is withdrawn from the Leap Motion device field of view), the Leap Motion software may assign a new ID when it detects the entity in a future frame.

Use the ID value with the Frame::pointable() function to find this Pointable object in future frames.

Returns
The ID assigned to this Pointable object.
static const Pointable& Leap::Pointable::invalid ( )
static

Returns an invalid Pointable object.

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

Returns
The invalid Pointable instance.
bool Leap::Pointable::isFinger ( ) const

Whether or not the Pointable is believed to be a finger.

Fingers are generally shorter, thicker, and less straight than tools.

Returns
True, if this Pointable is classified as a finger.
bool Leap::Pointable::isTool ( ) const

Whether or not the Pointable is believed to be a tool.

Tools are generally longer, thinner, and straighter than fingers.

Returns
True, if this Pointable is classified as a tool.
bool Leap::Pointable::isValid ( ) const

Reports whether this is a valid Pointable object.

Returns
True, if this Pointable object contains valid tracking data.
float Leap::Pointable::length ( ) const

The estimated length of the finger or tool in millimeters.

The reported length is the visible length of the finger or tool from the hand to tip. If the length isn't known, then a value of 0 is returned.

Returns
The estimated length of this Pointable object.
bool Leap::Pointable::operator!= ( const Pointable ) const

Compare Pointable object inequality.

Two Pointable objects are equal if and only if both Pointable objects represent the exact same physical entities in the same frame and both Pointable objects are valid.

bool Leap::Pointable::operator== ( const Pointable ) const

Compare Pointable object equality.

Two Pointable objects are equal if and only if both Pointable objects represent the exact same physical entities in the same frame and both Pointable objects are valid.

Vector Leap::Pointable::stabilizedTipPosition ( ) const

The stabilized tip position of this Pointable.

Smoothing and stabilization is performed in order to make this value more suitable for interaction with 2D content.

Returns
A modified tip position of this Pointable object with some additional smoothing and stabilization applied.
Vector Leap::Pointable::tipPosition ( ) const

The tip position in millimeters from the Leap Motion origin.

Returns
The Vector containing the coordinates of the tip position.
Vector Leap::Pointable::tipVelocity ( ) const

The rate of change of the tip position in millimeters/second.

Returns
The Vector containing the coordinates of the tip velocity.
std::string Leap::Pointable::toString ( ) const

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

Returns
A description of the Pointable object as a string.
float Leap::Pointable::touchDistance ( ) const

A value proportional to the distance between this Pointable object and the adaptive touch plane.

The touch distance is a value in the range [-1, 1]. The value 1.0 indicates the Pointable is at the far edge of the hovering zone. The value 0 indicates the Pointable is just entering the touching zone. A value of -1.0 indicates the Pointable is firmly within the touching zone. Values in between are proportional to the distance from the plane. Thus, the touchDistance of 0.5 indicates that the Pointable is halfway into the hovering zone.

You can use the touchDistance value to modulate visual feedback given to the user as their fingers close in on a touch target, such as a button.

Returns
The normalized touch distance of this Pointable object.
Zone Leap::Pointable::touchZone ( ) const

The current touch zone of this Pointable object.

The Leap Motion software computes the touch zone based on a floating touch plane that adapts to the user's finger movement and hand posture. The Leap Motion software interprets purposeful movements toward this plane as potential touch points. When a Pointable moves close to the adaptive touch plane, it enters the "hovering" zone. When a Pointable reaches or passes through the plane, it enters the "touching" zone.

The possible states are present in the Zone enum of this class:

  • Zone.NONE – The Pointable is outside the hovering zone.
  • Zone.HOVERING – The Pointable is close to, but not touching the touch plane.
  • Zone.TOUCHING – The Pointable has penetrated the touch plane.

The touchDistance value provides a normalized indication of the distance to the touch plane when the Pointable is in the hovering or touching zones.

Returns
The touch zone of this Pointable
float Leap::Pointable::width ( ) const

The estimated width of the finger or tool in millimeters.

The reported width is the average width of the visible portion of the finger or tool from the hand to the tip. If the width isn't known, then a value of 0 is returned.

Returns
The estimated width of this Pointable object.

Friends And Related Function Documentation

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

Writes a brief, human readable description of the Pointable object to an output stream.