Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isCurled(hand, finger) {
var finger_dir = finger.direction;
var palm_dir = hand.direction;
var palm_normal = hand.palmNormal;
var threshhold = 7*Math.PI/36; //35 degrees
var right_angle = Math.PI/2; //90 degrees
//Angle between the finger and the palm normal
var fn_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_normal));
//Angle between the finger and the palm direction
var fd_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_dir));
//We check fd_angle > 90 to detect the condition where the user has curled their finger past the palm normal
return fn_angle < threshhold || fd_angle > right_angle;
}
function isCurled(hand, finger) {
var finger_dir = finger.direction;
var palm_dir = hand.direction;
var palm_normal = hand.palmNormal;
var threshhold = 7*Math.PI/36; //35 degrees
var right_angle = Math.PI/2; //90 degrees
//Angle between the finger and the palm normal
var fn_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_normal));
//Angle between the finger and the palm direction
var fd_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_dir));
//We check fd_angle > 90 to detect the condition where the user has curled their finger past the palm normal
return fn_angle < threshhold || fd_angle > right_angle;
}
Gesture.prototype.detect = function() {
var direction, dotProduct, gesture, j, len, pointableID, ref;
if (this.frame.gestures.length > 0) {
ref = this.frame.gestures;
for (j = 0, len = ref.length; j < len; j++) {
gesture = ref[j];
switch (gesture.type) {
case "circle":
if (this.extendedFingers.is(["thumb", "index"])) {
pointableID = gesture.pointableIds[0];
direction = this.frame.pointable(pointableID).direction;
dotProduct = Leap.vec3.dot(direction, gesture.normal);
if (dotProduct > 0) {
return 'oneFingerRotateClockwise';
} else {
return 'oneFingerRotateContraClockwise';
}
}
}
}
}
return false;
};