示例#1
0
    public static float getHandClosedPercent(Hand hand)
    {
        float prob = 0.0f;

        Leap.Vector palmNormal = hand.PalmNormal;
        foreach (Finger finger in hand.Fingers)
        {
            prob += palmNormal.Dot(finger.Direction);
        }
        prob /= hand.Fingers.Count;
        return(prob);
    }
示例#2
0
    public static float getHandRotationAmount(Hand hand)
    {
        Leap.Vector normal    = hand.PalmNormal;
        Frame       prevFrame = leapController.Frame(3);

        if (prevFrame != null)
        {
            Hand prevHand = prevFrame.Hand(hand.Id);
            if (prevFrame != null && prevHand.IsValid)
            {
                return(0.5f + normal.Dot(prevHand.PalmNormal) / 2.0f);
            }
        }
        return(0.0f);
    }
示例#3
0
 static LeapQuaternion RotationBetween(Vector fromDirection, Vector toDirection)
 {
   float m = Mathf.Sqrt(2.0f + 2.0f * fromDirection.Dot(toDirection));
   Vector w = (1.0f / m) * fromDirection.Cross(toDirection);
   return new LeapQuaternion(w.x, w.y, w.z, 0.5f * m);
 }
        protected override IDisposable SubscribeCore(ReactiveSpace spaceListener)
        {
            return
                spaceListener
                .ReactiveListener
                .FingersMoves()
                .Concat()
                .ObserveOn(UI)
                .Subscribe(c =>
                {
                    var v = c.TipVelocity.To2D();
                    //v = new Vector(-c.TipVelocity.x, c.TipVelocity.y, 0);

                    var cos = Math.Cos(Helper.DegreeeToRadian(Rotation));
                    var sin = Math.Sin(Helper.DegreeeToRadian(Rotation));

                    var tan = new Vector((float)sin, (float)cos, 0);

                    var man = tan.Dot(v);

                    Rotation -= man / 100;

                });
        }