Changeset 10198 for branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs
- Timestamp:
- 12/05/13 15:23:48 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs
r10097 r10198 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 25 using MIConvexHull; 24 26 25 27 namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers { … … 67 69 return volume; 68 70 } 71 72 public static double CalculateVolumeNew(List<double[]> convexHull) { 73 double volume = 0.0; 74 75 int dim = convexHull.First().Length; 76 if (dim > convexHull.Count) 77 throw new ArgumentException("Nr. of points for volume calculation must be greater than dimension", "convexHull"); 78 79 var triangulation = Triangulation.CreateDelaunay(ConvertToVertex(convexHull)); 80 var simplices = ConvertFromTriangulation(triangulation); 81 foreach (var simplex in simplices) { 82 volume += CalculateSimplexVolume(simplex.ToList()); 83 } 84 85 return volume; 86 } 87 88 private static List<double[][]> ConvertFromTriangulation(ITriangulation<DefaultVertex, DefaultTriangulationCell<DefaultVertex>> triangulation) { 89 List<double[][]> results = new List<double[][]>(); 90 91 foreach (var cell in triangulation.Cells) { 92 results.Add(cell.Vertices.Select(x => x.Position).ToArray()); 93 } 94 95 return results; 96 } 97 98 private static List<DefaultVertex> ConvertToVertex(List<double[]> data) { 99 List<DefaultVertex> result = new List<DefaultVertex>(); 100 for (int i = 0; i < data.Count(); i++) { 101 double[] d = data[i]; 102 DefaultVertex vertex = new DefaultVertex(); 103 vertex.Position = d; 104 result.Add(vertex); 105 } 106 return result; 107 } 69 108 } 70 109 }
Note: See TracChangeset
for help on using the changeset viewer.