ToolΒΆ

The Tool class represents a tracked tool. More...

Inherits Pointable.

Public Types

enum  Zone
 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 is pointing. More...
 
Frame frame () const
 The Frame associated with this Pointable object. More...
 
Hand hand () const
 The Hand associated with a finger. More...
 
int32_t id () const
 A unique ID assigned to this Pointable object, whose value remains the same across consecutive frames while the tracked finger remains visible. More...
 
bool isExtended () const
 Whether or not this Pointable is in an extended posture. More...
 
bool isFinger () const
 Whether or not this Pointable is classified as a finger. More...
 
bool isTool () const
 Whether or not this Pointable is classified as a tool. More...
 
bool isValid () const
 Reports whether this is a valid Pointable object. More...
 
float length () const
 The estimated length of the finger in millimeters. More...
 
bool operator!= (const Pointable &) const
 Compare Pointable object inequality. More...
 
bool operator== (const Pointable &) const
 Compare Pointable object equality. More...
 
Vector stabilizedTipPosition () const
 The stabilized tip position of this Pointable. More...
 
float timeVisible () const
 The duration of time this Pointable has been visible to the Leap Motion Controller. More...
 
Vector tipPosition () const
 The tip position in millimeters from the Leap Motion origin. More...
 
Vector tipVelocity () const
 The rate of change of the tip position in millimeters/second. More...
 
 Tool (ToolImplementation *)
 
 Tool ()
 Constructs a Tool object. More...
 
 Tool (const Pointable &)
 If the specified Pointable object represents a tool, creates a copy of it as a Tool object; otherwise, creates an invalid Tool object. More...
 
std::string toString () const
 A string containing a brief, human readable description of the Tool object. More...
 
float touchDistance () const
 A value proportional to the distance between this Pointable object and the adaptive touch plane. More...
 
Zone touchZone () const
 The current touch zone of this Pointable object. More...
 
float width () const
 The estimated width of the finger in millimeters. More...
 

Static Public Member Functions

static const Toolinvalid ()
 Returns an invalid Tool object. More...
 

Detailed Description

The Tool class represents a tracked tool.

Leap_Tool.png
Deprecated:
3.0

Member Enumeration Documentation

enum Zone
inherited

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

Since
1.0
Enumerator
ZONE_NONE 

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

Since
1.0
ZONE_HOVERING 

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

Since
1.0
ZONE_TOUCHING 

The Pointable has penetrated the plane.

Since
1.0

Constructor & Destructor Documentation

Tool ( ToolImplementation *  )
Tool ( )

Constructs a Tool object.

Leap::Tool frontTool = frame.tools().frontmost();
Deprecated:
3.0
Tool ( const Pointable )
explicit

If the specified Pointable object represents a tool, creates a copy of it as a Tool object; otherwise, creates an invalid Tool object.

if (pointable.isTool()) {
tool = Leap::Tool(pointable);
}
Deprecated:
3.0

Member Function Documentation

Vector direction ( ) const
inherited

The direction in which this finger is pointing.

Leap::Vector pointingToward = pointable.direction();

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.
Since
1.0
Frame frame ( ) const
inherited

The Frame associated with this Pointable object.

Leap::Frame frameOfThisPointableObject = pointable.frame();
Returns
The associated Frame object, if available; otherwise, an invalid Frame object is returned.
Since
1.0
Hand hand ( ) const
inherited

The Hand associated with a finger.

Leap::Hand attachedHand = pointable.hand();

This function always returns an invalid Hand object.

Returns
The associated Hand object, if available; otherwise, an invalid Hand object is returned.
Since
1.0
int32_t id ( ) const
inherited

A unique ID assigned to this Pointable object, whose value remains the same across consecutive frames while the tracked finger 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 Controller field of view), the Leap Motion software may assign a new ID when it detects the entity in a future frame.

int32_t theID = pointable.id();

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

IDs should be from 1 to 100 (inclusive). If more than 100 objects are tracked an IDs of -1 will be used until an ID in the defined range is available.

Returns
The ID assigned to this Pointable object.
Since
1.0
static const Tool& invalid ( )
static

Returns an invalid Tool object.

if (tool != Leap::Tool::invalid()) {
//Handle valid tool data
}
Returns
The invalid Tool instance.
Deprecated:
3.0
bool isExtended ( ) const
inherited

Whether or not this Pointable is in an extended posture.

A finger is considered extended if it is extended straight from the hand as if pointing. A finger is not extended when it is bent down and curled towards the palm.

int extendedFingers = 0;
for (int f = 0; f < hand.fingers().count(); f++)
{
Leap::Finger finger = hand.fingers()[f];
if(finger.isExtended()) extendedFingers++;
}
Returns
True, if the pointable is extended.
Since
2.0
bool isFinger ( ) const
inherited

Whether or not this Pointable is classified as a finger.

if (pointable.isTool()) {
Leap::Tool tool = Leap::Tool(pointable);
} else {
Leap::Finger finger = Leap::Finger(pointable);
}
Returns
True, if this Pointable is classified as a finger.
Since
1.0
bool isTool ( ) const
inherited

Whether or not this Pointable is classified as a tool.

if (pointable.isTool()) {
Leap::Tool tool = Leap::Tool(pointable);
} else {
Leap::Finger finger = Leap::Finger(pointable);
}
Returns
false
Deprecated:
3.0
bool isValid ( ) const
inherited

Reports whether this is a valid Pointable object.

if( pointable.isValid()) {
//Use it...
}
Returns
True, if this Pointable object contains valid tracking data.
Since
1.0
float length ( ) const
inherited

The estimated length of the finger in millimeters.

float apparentlength = pointable.length();
Returns
The estimated length of this Pointable object.
Since
1.0
bool operator!= ( const Pointable ) const
inherited

Compare Pointable object inequality.

thisPointable != thatPointable;

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.

Since
1.0
bool operator== ( const Pointable ) const
inherited

Compare Pointable object equality.

thisPointable == thatPointable;

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.

Since
1.0
Vector stabilizedTipPosition ( ) const
inherited

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. The stabilized position lags behind the tip position by a variable amount, depending primarily on the speed of movement.

Leap::Vector stabilizedPosition = pointable.stabilizedTipPosition();
Returns
A modified tip position of this Pointable object with some additional smoothing and stabilization applied.
Since
1.0
float timeVisible ( ) const
inherited

The duration of time this Pointable has been visible to the Leap Motion Controller.

float lifetime = pointable.timeVisible();
Returns
The duration (in seconds) that this Pointable has been tracked.
Since
1.0
Vector tipPosition ( ) const
inherited

The tip position in millimeters from the Leap Motion origin.

Leap::Vector currentPosition = pointable.tipPosition();
Returns
The Vector containing the coordinates of the tip position.
Since
1.0
Vector tipVelocity ( ) const
inherited

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

Leap::Vector currentSpeed = pointable.tipVelocity();
Returns
The Vector containing the coordinates of the tip velocity.
Since
1.0
std::string toString ( ) const
inline

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

Returns
A description of the Tool object as a string.
Deprecated:
3.0
float touchDistance ( ) const
inherited

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

Leap_Touch_Plane.png
float distance = pointable.touchDistance();
if (distance > 0) {
//Handle hovering ...
} else {
//Handle touching ...
}
Returns
The normalized touch distance of this Pointable object.
Deprecated:
3.0
Zone touchZone ( ) const
inherited

The current touch zone of this Pointable object.

switch (pointable.touchZone()) {
//Handle distant pointable
break;
//Handle pointable near touch plane
break;
//Handle pointable penetrating touch plane
break;
default:
//Handle error cases...
break;
}
Returns
The touch zone of this Pointable
Deprecated:
3.0
float width ( ) const
inherited

The estimated width of the finger in millimeters.

float averageThickness = pointable.width();
Returns
The estimated width of this Pointable object.
Since
1.0