LeapJS API Reference
Class

Leap.Hand

Contents

class Leap.Hand

The Hand class reports the physical characteristics of a detected hand.

Hand tracking data includes a palm position and velocity; vectors for the palm normal and direction to the fingers; properties of a sphere fit to the hand; and lists of the attached fingers and tools.

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

Constructor Top

  Hand ()

Static Properties & Enumerations Top

Leap.Hand Invalid

Properties Top

Leap.Vector direction
Leap.Pointable fingers[]
String id
Leap.Vector palmNormal
Leap.Vector palmPosition
Leap.Vector palmVeclocity
Leap.Pointable pointables[]
Leap.Vector sphereCenter
Number sphereRadius
Leap.Pointable tools[]
Boolean valid

Methods Top

Leap.Pointable finger (String id)
Number rotationAngle (Leap.Frame sinceFrame, Leap.Vector axis)
Leap.Vector rotationAxis (Leap.Frame sinceFrame)
Leap.Matrix rotationMatrix (Leap.Frame sinceFrame)
Number scaleFactor (Leap.Frame sinceFrame)
String toString ()
Leap.Vector translation (Leap.Frame sinceFrame)

Constructor details Top

hand.js at line 6
Hand ()

Constructs a Hand object.

An uninitialized hand is considered invalid. Get valid Hand objects from a Frame object.

Static Properties & Enumerations Detail Top

hand.js at line 334
static public Leap.Hand Invalid

An invalid Hand object.

You can use an invalid Hand object in comparisons testing whether a given Hand instance is valid or invalid. (You can also use the Hand valid property.)

Properties Detail Top

hand.js at line 50
public Leap.Vector direction

The direction from the palm position toward the fingers.

The direction is expressed as a unit vector pointing in the same direction as the directed line from the palm position to the fingers.

hand.js at line 127
public Leap.Pointable fingers[]

The list of fingers detected in this frame that are attached to this hand, given in arbitrary order.

The list can be empty if no fingers attached to this hand are detected.

hand.js at line 28
public String id

A unique ID assigned to this Hand object, whose value remains the same across consecutive frames while the tracked hand remains visible. If tracking is lost (for example, when a hand is occluded by another hand or when it is withdrawn from or reaches the edge of the Leap field of view), the Leap may assign a new ID when it detects the hand in a future frame.

Use the ID value with the Frame.hand() function to find this Hand object in future frames.

hand.js at line 69
public Leap.Vector palmNormal

The normal vector to the palm. If your hand is flat, this vector will point downward, or "out" of the front surface of your palm.

Palm Vectors

The direction is expressed as a unit vector pointing in the same direction as the palm normal (that is, a vector orthogonal to the palm).

hand.js at line 43
public Leap.Vector palmPosition

The center position of the palm in millimeters from the Leap origin.

hand.js at line 61
public Leap.Vector palmVeclocity

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

hand.js at line 112
public Leap.Pointable pointables[]

The list of Pointable objects (fingers and tools) detected in this frame that are associated with this hand, given in arbitrary order. The list can be empty if no fingers or tools associated with this hand are detected.

Use the Pointable tool property to determine whether or not an item in the list represents a tool or finger. You can also get only the tools using the Hand.tools[] list or only the fingers using the Hand.fingers[] list.

hand.js at line 82
public Leap.Vector sphereCenter

The center of a sphere fit to the curvature of this hand.

This sphere is placed roughly as if the hand were holding a ball.

Hand Ball

hand.js at line 93
public Number sphereRadius

The radius of a sphere fit to the curvature of this hand, in millimeters.

This sphere is placed roughly as if the hand were holding a ball. Thus the size of the sphere decreases as the fingers are curled into a fist.

hand.js at line 138
public Leap.Pointable tools[]

The list of tools detected in this frame that are held by this hand, given in arbitrary order.

The list can be empty if no tools held by this hand are detected.

hand.js at line 104
public Boolean valid

Reports whether this is a valid Hand object.

Methods Detail Top

hand.js at line 154
public Leap.Pointable finger (String id)

The finger with the specified ID attached to this hand.

Use this function to retrieve a Pointable object representing a finger attached to this hand using an ID value obtained from a previous frame. This function always returns a Pointable object, but if no finger with the specified ID is present, an invalid Pointable object is returned.

Note that the ID values assigned to fingers persist across frames, but only until tracking of a particular finger is lost. If tracking of a finger is lost and subsequently regained, the new Finger object representing that finger may have a different ID than that representing the finger in an earlier frame.

Parameters

String id

The ID value of a finger from a previous frame.

Return Value

Leap.Pointable

The Finger object with the matching ID if one exists for this hand in this frame; otherwise, an invalid Finger object is returned.

hand.js at line 180
public Number rotationAngle (Leap.Frame sinceFrame, Leap.Vector axis)

The angle of rotation around the rotation axis derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

The returned angle is expressed in radians measured clockwise around the rotation axis (using the right-hand rule) between the start and end frames. The value is always between 0 and pi radians (0 and 180 degrees).

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then the angle of rotation is zero.

Parameters

Leap.Frame sinceFrame

The starting frame for computing the relative rotation.

Leap.Vector axis

The axis to measure rotation around.

(Optional)

Return Value

Number

A positive value representing the heuristically determined rotational change of the hand between the current frame and that specified in the sinceFrame parameter.

hand.js at line 218
public Leap.Vector rotationAxis (Leap.Frame sinceFrame)

The axis of rotation derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

The returned direction vector is normalized.

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns a zero vector.

Parameters

Leap.Frame sinceFrame

The starting frame for computing the relative rotation.

Return Value

Leap.Vector

A normalized direction Vector representing the axis of the heuristically determined rotational change of the hand between the current frame and that specified in the sinceFrame parameter.

hand.js at line 245
public Leap.Matrix rotationMatrix (Leap.Frame sinceFrame)

The transform matrix expressing the rotation derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns an identity matrix.

Parameters

Leap.Frame sinceFrame

The starting frame for computing the relative rotation.

Return Value

Leap.Matrix

A transformation Matrix containing the heuristically determined rotational change of the hand between the current frame and that specified in the sinceFrame parameter.

hand.js at line 272
public Number scaleFactor (Leap.Frame sinceFrame)

The scale factor derived from the hand's motion between the current frame and the specified frame.

The scale factor is always positive. A value of 1.0 indicates no scaling took place. Values between 0.0 and 1.0 indicate contraction and values greater than 1.0 indicate expansion.

The Leap derives scaling from the relative inward or outward motion of a hand and its associated fingers and tools (independent of translation and rotation).

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns 1.0.

Parameters

Leap.Frame sinceFrame

The starting frame for computing the relative scaling.

Return Value

Number

A positive value representing the heuristically determined scaling change ratio of the hand between the current frame and that specified in the sinceFrame parameter.

hand.js at line 324
public String toString ()

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

Return Value

String

A description of the Hand as a string.

hand.js at line 298
public Leap.Vector translation (Leap.Frame sinceFrame)

The change of position of this hand between the current frame and the specified frame

The returned translation vector provides the magnitude and direction of the movement in millimeters.

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns a zero vector.

Parameters

Leap.Frame sinceFrame

The starting frame for computing the relative translation.

Return Value

Leap.Vector

A Vector representing the heuristically determined change in hand position between the current frame and that specified in the sinceFrame parameter.