Exemple #1
0
        private void trianglerPose()
        {
            if (palmPositionPosePoints.Count <= 2)
            {
                return;
            }
            debugField = "";

            List <PosePoint> copylist = new List <PosePoint>(palmPositionPosePoints.ToArray());

            //最近点選ぶ > KeyPoint
            PosePoint keyP = getMaxPosePoint(copylist, x => (x.position - palmPos).magnitude);

            copylist.Remove(keyP);
            debugField += "key:" + keyP.position.ToString() + "\n";

            //最もベクターが反対の点とのKeyMag距離点の中和ポーズの設定
            Vector3 PalmToKeyVect;

            while (copylist.Count > 0)
            {
                PalmToKeyVect = keyP.position - palmPos;
                PosePoint Apoint = getMinPosePoint(copylist, x => Vector3.Dot(PalmToKeyVect, (x.position - palmPos)));
                copylist.Remove(Apoint);

                keyP        = PosePoint.MixPointNearst(keyP, palmPos, Apoint, true);
                debugField += "koo:" + (keyP.position - palmPos).magnitude.ToString() + "%" + Apoint.position.ToString() + "\n";
            }

            debugField += "pos:" + palmPos.ToString() + "\n";
            keyP.Pose.SetPosing(model);
            targetertester.transform.position = keyP.position / 1000;
        }
        public static PosePoint MixPoint(PosePoint A, PosePoint B, float weightA)
        {
            PosePoint result = new PosePoint();

            result.position = B.position + (A.position - B.position) * weightA;
            result.Pose     = B.Pose + (A.Pose - B.Pose) * weightA;
            return(result);
        }
Exemple #3
0
        private void Nicoiti(Vector3 point)
        {
            if (palmPositionPosePoints.Count == 0)
            {
                return;
            }
            PosePoint ans = PosePoint.RecallNearst(palmPositionPosePoints, 0, palmPositionPosePoints.Count - 1, point);

            ans.Pose.SetPosing(model);
        }
Exemple #4
0
        private PosePoint RecallNearst(int A, int B)
        {
            if (A == B)
            {
                return(palmPositionPosePoints[A]);
            }
            else
            {
                PosePoint PoseA = RecallNearst(A, Mathf.CeilToInt((A + B) / 2));
                PosePoint PoseB = RecallNearst(Mathf.CeilToInt((A + B) / 2) + 1, B);

                return(PosePoint.MixPointNearst(PoseA, palmPos, PoseB, true));
            }
        }
        public static PosePoint MixPointSameLong(PosePoint Key, Vector3 longSample, PosePoint slideSample)
        {
            if ((Key.position - slideSample.position).sqrMagnitude == 0)
            {
                return(Key);
            }
            float longWeight = (Key.position - longSample).sqrMagnitude / (Key.position - slideSample.position).sqrMagnitude;

            if (float.IsInfinity(longWeight))
            {
                longWeight = 1f;
            }
            return(MixPoint(slideSample, Key, longWeight));
        }
        public static PosePoint RecallNearst(List <PosePoint> list, int A, int B, Vector3 point)
        {
            if (A == B)
            {
                return(list[A]);
            }
            else
            {
                PosePoint PoseA = RecallNearst(list, A, Mathf.CeilToInt((A + B) / 2), point);
                PosePoint PoseB = RecallNearst(list, Mathf.CeilToInt((A + B) / 2) + 1, B, point);

                return(PosePoint.MixPointNearst(PoseA, point, PoseB, true));
            }
        }
Exemple #7
0
        private void Nicoiti()
        {
            if (palmPositionPosePoints.Count == 0)
            {
                return;
            }
            debugField = "";
            PosePoint ans = RecallNearst(0, palmPositionPosePoints.Count - 1);

            debugField += "lng:" + (ans.position - palmPos).magnitude.ToString() + "\n";
            debugField += "ans:" + ans.position.ToString() + "\n";
            debugField += "pal:" + palmPos.ToString() + "\n";
            ans.Pose.SetPosing(model);
            targetertester.transform.position = ans.position / 1000;
        }
Exemple #8
0
        private PosePoint getMinPosePoint(List <PosePoint> listdata, ramd calc)
        {
            float     levels = float.MaxValue;
            PosePoint r      = null;

            foreach (var e in listdata)
            {
                float calcResult = calc(e);
                if (calcResult < levels)
                {
                    r      = e;
                    levels = calcResult;
                }
            }
            return(r);
        }
        public static PosePoint MixPointNearst(PosePoint Key, Vector3 target, PosePoint slideSample, bool overFloor)
        {
            if ((Key.position - slideSample.position).magnitude == 0)
            {
                return(Key);
            }

            Vector3 keyToTarget = target - Key.position;
            Vector3 keyToSlide  = slideSample.position - Key.position;

            float dot = Vector3.Dot(keyToSlide.normalized, keyToTarget.normalized) * keyToTarget.magnitude / keyToSlide.magnitude;

            if (!overFloor)
            {
                dot = Mathf.Min(1f, Mathf.Max(0f, dot));
            }
            return(MixPoint(Key, slideSample, (1f - dot)));
        }