Attributes:
Functions:
The Bone class represents a tracked finger bone.
Note that Bone objects can be invalid, which means that they do not contain valid tracking data and do not correspond to a physical entity. Invalid Bone objects can be the result of asking for a Bone object from an invalid finger or hand. A Bone object created from the Bone constructor is also invalid.
New in version 2.0.
Type: | number[][] – a 2-dimensional array, with each dimension containing three elements. |
---|
The orthonormal basis vectors for this Bone.
var basis = bone.basis;
Basis vectors specify the orientation of a bone.
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. The matrix() function converts the basis and bone positions to a transformation matrix that can be used to update a 3D object representing the bone in a 3D scene.
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.
Type: | number |
---|
The length of the bone in millimeters.
var length = bone.length;
New in version 2.0.
Type: | number[] |
---|
The distal end of the bone closest to the finger tip.
var bone_end = bone.nextJoint;
New in version 2.0.
Type: | number[] |
---|
The proximal end of the bone closest to the torso.
var bone_start = bone.prevJoint;
New in version 2.0.
Type: | integer – a code indicating the bone name |
---|
The code for the anatomical identity of this bone:
var bone_names = ["metacarpal", "proximal phalange", "intermediate phalange", "distal phalange"];
var type = bone.type;
var name = bone_names[type];
New in version 2.0.
Type: | number |
---|
The average width of the fleshy part surrounding this bone.
var average_width = bone.width;
New in version 2.0.
Type: | number[] |
---|
The midpoint of this bone in millimeters within the Leap Motion coordinate system.
var center = bone.center();
Returns
The three element array representing a position midway between the bone end points.
New in version 2.0.
Type: | number[] |
---|
The direction vector along the bone’s longitudinal axis.
var direction = bone.direction();
This is the negative of the bone’s z-basis (Bone.basis[2]).
Returns
The a 3-element array (number[]) containing the coordinates of the direction vector.
New in version 2.0.
Type: | boolean |
---|
Reports whether this bone is associated with the left hand.
Bones on the left hand use the left-hand rule; those on the right use the right-hand rule.
if(bone.left){
var right_hand_basis = [Leap.vec3.negate(Leap.vec3.create(), bone.basis[0]),
Leap.vec3.negate(Leap.vec3.create(), bone.basis[1]),
Leap.vec3.negate(Leap.vec3.create(), bone.basis[2])];
}
Returns
True, if the bone is associated with the left hand.
New in version 2.0.
Type: | number[] |
---|---|
Arguments: |
|
Calculates the coordinates of the point between the ends of the bone in millimeters from the Leap Motion origin by linearly interpolating between the end points of the bone. If the t parameter is set to 0, the position corresponds to the prevJoint; if set to 1, the position corresponds to nextJoint.
var quarter_point = Leap.vec3.create();
bone.lerp(quarter_point, .25);
Returns
Does not return a value; sets the out array instead.
New in version 2.0.
Type: | number[] |
---|
The transformation describing the bone orientation and position within the Leap Motion coordinate system.
var bone_transform = bone.matrix();
You can use this matrix to transform a 3D or skinned-animation bone object within a 3D scene.
Calculated from the bone’s basis and center().
Returns
A 4x4 matrix stored in row-major order within a 16-element array of floating point numbers.
New in version 2.0.