/** * Does an in-place rigid transformation of a Finger. * * @param transform A LeapTransform containing the desired translation, rotation, and scale * to be applied to the Finger. */ public static Finger Transform(this Finger finger, LeapTransform transform) { Bone nextBone = finger.bones[3]; nextBone.NextJoint = transform.TransformPoint(nextBone.NextJoint); finger.TipPosition = nextBone.NextJoint; for (int i = 3; i-- != 0;) { Bone bone = finger.bones[i]; bone.NextJoint = nextBone.PrevJoint = transform.TransformPoint(bone.NextJoint); nextBone.TransformGivenJoints(transform); nextBone = bone; } nextBone.PrevJoint = transform.TransformPoint(nextBone.PrevJoint); nextBone.TransformGivenJoints(transform); finger.TipVelocity = transform.TransformVelocity(finger.TipVelocity); finger.Direction = finger.bones[2].Direction; finger.StabilizedTipPosition = transform.TransformPoint(finger.StabilizedTipPosition); finger.Width *= Math.Abs(transform.scale.x); finger.Length *= Math.Abs(transform.scale.z); return(finger); }
/** * Does an in-place rigid transformation of a Bone. * * @param transform A LeapTransform containing the desired translation, rotation, and scale * - * to be applied to the bone. */ public static Bone Transform(this Bone bone, LeapTransform transform) { bone.PrevJoint = transform.TransformPoint(bone.PrevJoint); bone.NextJoint = transform.TransformPoint(bone.NextJoint); bone.TransformGivenJoints(transform); return(bone); }