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; }
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 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)); } }