Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/14 01:39:50 (11 years ago)
Author:
ascheibe
Message:

#1886 added calculation of diameter and updated convex hull modifier to calculate the new measures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs

    r10274 r10275  
    9090    }
    9191
    92     public static double[] CalculateCentroid(List<double[]> convexHull) {
     92    public static double[] CalculateCentroids(List<double[]> convexHull) {
    9393      int n = convexHull.Count;
    9494      int dim = convexHull.First().Length;
     
    132132      double ca = c.EuclideanDistance(a);
    133133
    134       return Math.Acos((ab * ab + bc * bc - ca * ca) / (2 * ab * bc));
     134      //return degrees
     135      return Math.Acos((ab * ab + bc * bc - ca * ca) / (2 * ab * bc)) * 180.0 / Math.PI;
    135136    }
    136137
     
    145146      return thetas;
    146147    }
     148
     149    public static double CalculateMaxDiameter(List<double[]> convexHull) {
     150      double maxDist = double.MinValue;
     151
     152      for (int i = 0; i < convexHull.Count; i++) {
     153        for (int j = 0; j < convexHull.Count; j++) {
     154          if (i != j) {
     155            double dist = convexHull[i].EuclideanDistance(convexHull[j]);
     156            if (dist > maxDist)
     157              maxDist = dist;
     158          }
     159        }
     160      }
     161      return maxDist;
     162    }
    147163  }
    148164}
Note: See TracChangeset for help on using the changeset viewer.