public SymbolAnalyzerResult Analyze(List <Vector3> points) { List <SymbolComparationResult> comparationResults = symbolComparator.CompareCustomSymbolWithAllTemplates(points); SymbolComparationResult bestResult = GetBestResult(comparationResults); SymbolAnalyzerResult resultOfAnalyze = new SymbolAnalyzerResult(bestResult.Type, bestResult.Value); return(resultOfAnalyze); }
private static SymbolComparationResult CalculateValueOfSymbolsDifference(SymbolTemplate example, List <Vector3> playersShapePoints) { List <float> distancesBetweenClosestPoints = GetDistancesBetweenClosestPointsOfLists(example.Points, playersShapePoints); float averageDistance = MathHelper.CalculateAverageValue(distancesBetweenClosestPoints); float dispertion = MathHelper.CalculateDispertionValue(distancesBetweenClosestPoints, averageDistance); const int coefficientToMakeResultReadable = 100; float comparationResultValue = dispertion * Mathf.Pow(averageDistance, 3) * coefficientToMakeResultReadable; SymbolComparationResult comparationResult = new SymbolComparationResult(example.Type, comparationResultValue); return(comparationResult); }
public List <SymbolComparationResult> CompareCustomSymbolWithAllTemplates(List <Vector3> customSymbol) { LogWriter.WriteLog(this, "Got new shape for comparation"); List <SymbolComparationResult> results = new List <SymbolComparationResult>(shapes.Count); foreach (SymbolTemplate exampleShape in shapes) { SymbolComparationResult symbolsDifference = CalculateValueOfSymbolsDifference(exampleShape, customSymbol); LogWriter.WriteLog(this, "Result with " + symbolsDifference.Type + " is " + symbolsDifference.Value); results.Add(symbolsDifference); } return(results); }
private static SymbolComparationResult GetBestResult(List <SymbolComparationResult> comparationResults) { if (comparationResults.Count == 0) { return(null); } SymbolComparationResult bestResult = comparationResults[0]; for (int i = 1; i != comparationResults.Count; i++) { if (comparationResults[i].Value < bestResult.Value) { bestResult = comparationResults[i]; } } return(bestResult); }