Bone

Attributes:

class Leap.Bone

The Bone class represents a bone of a finger.

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.

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 object. A Bone object created from the Bone constructor is also invalid. Test for validity with the Bone.is_valid() attribute.

New in version 2.0.

classmethod Bone([Bone])

Constructs a Bone object.

Get valid Bone objects from a Finger object.

bone = Leap.Bone() #invalid
Parameters:Bone (Bone) – An object representing a Bone. If no Bone parameter is supplied, or the object does not represent a Bone, an invalid Bone object is returned.
Return type:Bone

New in version 2.0.

basis
Type:Matrix

The orthonormal basis vectors for this Bone as a Matrix.

Basis vectors specify the orientation of a bone.

  • x_basis. Perpendicular to the longitudinal axis of the bone; exits the sides of the finger.
  • y_basis 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.
  • z_basis. Aligned with the longitudinal axis of the bone. More positive toward the base of the finger.
basis = bone.basis
x_basis = basis.x_basis
y_basis = basis.y_basis
z_basis = basis.z_basis
origin = basis.origin

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 basis vectors 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.

New in version 2.0.

center
Type:Vector

The midpoint of the bone.

middle = bone.center

New in version 2.0.

direction
Type:Vector

The normalized direction of the bone from base to tip.

direction = bone.direction

This is the negative of the bone’s z-basis.

New in version 2.0.

is_valid
Type:boolean

Reports whether this Bone object contains valid data.

bone = finger.bone(Bone.TYPE_PROXIMAL)
if(bone.is_valid):
    # ... Use the bone data

New in version 2.0.

length
Type:float

The length of the bone in millimeters.

length = bone.length

New in version 2.0.

next_joint
Type:Vector

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

bone_end = bone.next_joint

New in version 2.0.

prev_joint
Type:Vector

The position of the end of the bone closest to the wrist.

bone_start = bone.prev_joint

New in version 2.0.

type
Type:integer

The name of this Bone.

type = bone.type

The anatomical type of this Bone:

  • 0 = TYPE_METACARPAL – the bone inside the hand connecting the wrist and finger
  • 1 = TYPE_PROXIMAL – the first exposed bone of the finger, closest to the hand.
  • 2 = TYPE_INTERMEDIATE – the middle bone of the finger
  • 3 = TYPE_DISTAL – the bone at the tip of the finger

New in version 2.0.

width
Type:float

The average width of the finger along the bone (including the fleshy sheathe).

width = bone.width

New in version 2.0.

invalid
Type:Bone

An invalid Bone object.

bone = Bone.invalid

You can use this invalid object in comparisons testing whether a given Bone instance is valid or invalid. (You can also use the Bone.is_valid attribute.)

New in version 2.0.

TYPE_DISTAL
Type:integer

The phalanx bone at the end for the finger (most distant from the body). The distal phalanx has index 3.

distal_bone = finger.bone(Bone.TYPE_DISTAL)

New in version 2.0.

TYPE_INTERMEDIATE
Type:integer

The bone in between the distal and proximal phanlanges. The intermediate phalanx has index 2.

intermediate_bone = finger.bone(Bone.TYPE_INTERMEDIATE)

New in version 2.0.

TYPE_PROXIMAL
Type:integer

The finger bone at the base of the finger (in closest proximity to the body). The proximal phalanx has index 1.

proximal_bone = finger.bone(Bone.TYPE_PROXIMAL)

New in version 2.0.

TYPE_METACARPAL
Type:integer

The bone connecting the wrist area to the base of the proximal finger bone. The metacarpal has index 0.

metacarpal_bone = finger.bone(Bone.TYPE_METACARPAL)

Note: A real thumb has one less bone than the other fingers; therefore the Leap Motion assigns the thumb model a valid, zero-length bone at the metacarpal index. While this differs from the normal anatomical naming system, which dispenses with the intermediate phalanx instead, it does mean that each finger, including the thumb, has the same bone at the same index.

New in version 2.0.