BoneΒΆ

The Bone class represents a tracked bone. More...

Inherits Interface.

Public Types

enum  Type
 Enumerates the names of the bones. More...
 

Public Member Functions

Matrix basis () const
 The orthonormal basis vectors for this Bone as a Matrix. More...
 
 Bone (BoneImplementation *)
 
 Bone ()
 Constructs an invalid Bone object. More...
 
Vector center () const
 The midpoint of the bone. More...
 
Vector direction () const
 The normalized direction of the bone from base to tip. More...
 
bool isValid () const
 Reports whether this is a valid Bone object. More...
 
float length () const
 The estimated length of the bone in millimeters. More...
 
Vector nextJoint () const
 The end of the bone, closest to the finger tip. More...
 
bool operator!= (const Bone &) const
 Compare Bone object inequality. More...
 
bool operator== (const Bone &) const
 Compare Bone object equality. More...
 
Vector prevJoint () const
 The base of the bone, closest to the wrist. More...
 
std::string toString () const
 A string containing a brief, human readable description of the Bone object. More...
 
Type type () const
 The name of this bone. More...
 
float width () const
 The average width of the flesh around the bone in millimeters. More...
 

Static Public Member Functions

static const Boneinvalid ()
 Returns an invalid Bone object. More...
 

Friends

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

Detailed Description

The Bone class represents a tracked bone.

All fingers contain 4 bones that make up the anatomy of the finger. Get valid Bone objects from a Finger object.

Bones are ordered from base to tip, indexed from 0 to 3. Additionally, the bone's Type enum may be used to index a specific bone anatomically.

Leap::FingerList fingers = frame.hands()[0].fingers();
for(Leap::FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); fl++){
Leap::Bone bone;
Leap::Bone::Type boneType;
for(int b = 0; b < 4; b++)
{
boneType = static_cast<Leap::Bone::Type>(b);
bone = (*fl).bone(boneType);
std::cout << "Finger index: " << (*fl).type() << " " << bone << std::endl;
}
}

The thumb does not have a base metacarpal bone and therefore contains a valid, zero length bone at that location.

Note that Bone objects can be invalid, which means that they do not contain valid tracking data and do not correspond to a physical bone. Invalid Bone objects can be the result of asking for a Bone object from an invalid finger, indexing a bone out of range, or constructing a new bone. Test for validity with the Bone::isValid() function.

Since
2.0

Member Enumeration Documentation

enum Type

Enumerates the names of the bones.

Members of this enumeration are returned by Bone::type() to identify a Bone object.

Since
2.0
Enumerator
TYPE_METACARPAL 

Bone connected to the wrist inside the palm.

TYPE_PROXIMAL 

Bone connecting to the palm.

TYPE_INTERMEDIATE 

Bone between the tip and the base.

TYPE_DISTAL 

Bone at the tip of the finger.

Constructor & Destructor Documentation

Bone ( BoneImplementation *  )
Bone ( )

Constructs an invalid Bone object.

Get valid Bone objects from a Finger object.

Since
2.0

Member Function Documentation

Matrix basis ( ) const

The orthonormal basis vectors for this Bone as a Matrix.

Basis vectors specify the orientation of a bone.

xBasis Perpendicular to the longitudinal axis of the bone; exits the sides of the finger.

yBasis or up vector Perpendicular to the longitudinal axis of the bone; exits the top and bottom of the finger. More positive in the upward direction.

zBasis Aligned with the longitudinal axis of the bone. More positive toward the base of the finger.

The bases provided for the right hand use the right-hand rule; those for the left hand use the left-hand rule. Thus, the positive direction of the x-basis is to the right for the right hand and to the left for the left hand. You can change from right-hand to left-hand rule by multiplying the z basis vector by -1.

You can use the basis vectors for such purposes as measuring complex finger poses and skeletal animation.

Note that converting the basis vectors directly into a quaternion representation is not mathematically valid. If you use quaternions, create them from the derived rotation matrix not directly from the bases.

Leap::Matrix basis = bone.basis();
Leap::Vector xBasis = basis.xBasis;
Leap::Vector yBasis = basis.yBasis;
Leap::Vector zBasis = basis.zBasis;
Returns
The basis of the bone as a matrix.
Since
2.0
Vector center ( ) const

The midpoint of the bone.

Leap::Vector middle = bone.center();
Returns
The midpoint in the center of the bone.
Since
2.0
Vector direction ( ) const

The normalized direction of the bone from base to tip.

Leap::Bone bone = finger.bone(Leap::Bone::TYPE_DISTAL);
Leap::Vector distalDirection = bone.basis().yBasis;
Returns
The normalized direction of the bone from base to tip.
Since
2.0
static const Bone& invalid ( )
static

Returns an invalid Bone object.

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

Returns
The invalid Bone instance.
Since
2.0
bool isValid ( ) const

Reports whether this is a valid Bone object.

if(bone.isValid())
{
// ... Use the bone data
}
Returns
True, if this Bone object contains valid tracking data.
Since
2.0
float length ( ) const

The estimated length of the bone in millimeters.

float length = bone.length();
Returns
The length of the bone in millimeters.
Since
2.0
Vector nextJoint ( ) const

The end of the bone, closest to the finger tip.

In anatomical terms, this is the distal end of the bone.

Leap::Vector boneEnd = bone.nextJoint();
Returns
The Vector containing the coordinates of the next joint position.
Since
2.0
bool operator!= ( const Bone ) const

Compare Bone object inequality.

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

Since
2.0
bool operator== ( const Bone ) const

Compare Bone object equality.

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

Since
2.0
Vector prevJoint ( ) const

The base of the bone, closest to the wrist.

In anatomical terms, this is the proximal end of the bone.

Leap::Vector boneStart = bone.prevJoint();
Returns
The Vector containing the coordinates of the previous joint position.
Since
2.0
std::string toString ( ) const
inline

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

std::string description = bone.toString();
Returns
A description of the Bone object as a string.
Since
2.0
Type type ( ) const

The name of this bone.

Returns
The anatomical type of this bone as a member of the Bone::Type enumeration.
Since
2.0
float width ( ) const

The average width of the flesh around the bone in millimeters.

float width = bone.width();
Returns
The width of the flesh around the bone in millimeters.
Since
2.0

Friends And Related Function Documentation

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

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

Since
2.0