public float ReturnMatchAccuracyWithReferenceSet(TrajectoryRefSet otherSet) { if (trajectories.Count == 0 && trajectories.Count != otherSet.trajectories.Count && !otherSet.isActual) { return(0); } // Make sure set is non-zero, has same # of pts as else // actual set, and only actual set is flagged actual { float accuracyTotal = 0; for (int i = 0; i < trajectories.Count; i++) { float ptDiffStart = (Mathf.Abs(trajectories[i].trajStart.x - otherSet.trajectories[i].trajStart.x) + Mathf.Abs(trajectories[i].trajStart.y - otherSet.trajectories[i].trajStart.y) + Mathf.Abs(trajectories[i].trajStart.z - otherSet.trajectories[i].trajStart.z)) / 3; float ptDiffEnd = (Mathf.Abs(trajectories[i].trajEnd.x - otherSet.trajectories[i].trajEnd.x) + Mathf.Abs(trajectories[i].trajEnd.y - otherSet.trajectories[i].trajEnd.y) + Mathf.Abs(trajectories[i].trajEnd.z - otherSet.trajectories[i].trajEnd.z)) / 3; accuracyTotal += (100f - ((ptDiffStart + ptDiffEnd) / 2f)); } return(accuracyTotal / trajectories.Count); } }
public void DetermineMatches() { ProjectHandler projHandler = GameObject.FindObjectOfType <ProjectHandler>(); matches.Clear(); if (projHandler.trajRefSets.Count > 0) { List <TrajectoryRefSet> acceptableMatches = new List <TrajectoryRefSet>(); foreach (TrajectoryRefSet trajRef in projHandler.trajRefSets) { if (this.ReturnMatchAccuracyWithReferenceSet(trajRef) > trajRef.accuracyRequirement) { acceptableMatches.Add(trajRef); } } int numOfTopPicksFound = 0; float tempMatchRating = 0; TrajectoryRefSet tempTopRef = null; while ((numOfTopPicksFound < defaultNumOfRefsToShow) && (acceptableMatches.Count > 0)) { foreach (TrajectoryRefSet trajRef in acceptableMatches) { float rating = ReturnMatchRatingWithReferenceSet(trajRef); if (rating > tempMatchRating) { tempMatchRating = rating; tempTopRef = trajRef; } } if (tempTopRef && !matches.Contains(tempTopRef)) { matches.Add(tempTopRef); } acceptableMatches.Remove(tempTopRef); tempTopRef = null; numOfTopPicksFound++; } } }
public float ReturnMatchRatingWithReferenceSet(TrajectoryRefSet otherSet) { return(ReturnMatchAccuracyWithReferenceSet(otherSet) - otherSet.accuracyRequirement); }