コード例 #1
0
ファイル: Gesture.cs プロジェクト: Paximillian/WeAreVR
    public double SimilarityScoreAgainst(Gesture i_OtherGesture, eAccuracyLevel i_Accuracy)
    {
        Reset();
        List <GesturePose> poses = this.ToList();

        i_OtherGesture.Reset();
        List <GesturePose> otherPoses = i_OtherGesture.ToList();

        double xPosDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Position.x
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Position.x
        }).ToList());

        double yPosDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Position.y
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Position.y
        }).ToList());

        double zPosDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Position.z
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Position.z
        }).ToList());

        double xRotDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.x
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.x
        }).ToList());

        double yRotDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.y
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.y
        }).ToList());

        double zRotDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.z
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.z
        }).ToList());

        double wRotDist = Algorithms.FrechetDistance(poses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.w
        }).ToList(),
                                                     otherPoses.Select(pose => new double[2] {
            pose.Time, pose.Rotation.w
        }).ToList());

        //Debug.Log(i_OtherGesture.name + (xPosDist + yPosDist + zPosDist + xRotDist + yRotDist + zRotDist + wRotDist) / 7);

        switch (i_Accuracy)
        {
        case eAccuracyLevel.All:
            return((xPosDist + yPosDist + zPosDist + xRotDist + yRotDist + zRotDist + wRotDist) / 7);

        case eAccuracyLevel.Position:
            return((xPosDist + yPosDist + zPosDist) / 3);

        case eAccuracyLevel.Rotation:
            return((xRotDist + yRotDist + zRotDist + wRotDist) / 4);
        }

        return(Mathf.Infinity);
    }
コード例 #2
0
ファイル: Gesture.cs プロジェクト: Paximillian/WeAreVR
 /// <summary>
 /// Compares this gesture to the given one and returns a value between 0-1 indicating the match rate of the 2.
 /// </summary>
 public bool IsSimilarTo(Gesture i_OtherGesture, eAccuracyLevel i_Accuracy)
 {
     return(SimilarityScoreAgainst(i_OtherGesture, i_Accuracy) < 0.35f);
 }