private void CongealVertexAngles() { // Get internal angles. int n = vertices.Length; double[] absangles = new double[n]; // always positive angles = new double[n]; // retains left/right sign for (int i = 0; i < n; ++i) { int a = i - 1; int b = i; int c = i + 1; if (a < 0) { a = n - 1; // wrap left } if (c >= n) { c = 0; // wrap right } absangles[i] = Geometry.Rad2Deg(Geometry.AngleDescribedBy(vertices[a], vertices[b], vertices[c])); angles[i] = Geometry.Rad2Deg(Geometry.CurveDescribedBy(vertices[a], vertices[b], vertices[c])); } // Group angles into heuristic buckets -- no two groups closer than 12°. ScalarPartitioning sp = new ScalarPartitioning(absangles); idealangles = sp.Partition(12.0); // Retain original sign (left/right curvature) of angle. for (int i = 0; i < n; ++i) { idealangles[i] = Math.Sign(angles[i]) * idealangles[i]; } }
// // Implementation private void CongealSideLengths() { // Get side lengths. int n = vertices.Length; sidelengths = new double[n]; for (int i=0; i < n; ++i) { int a=i; int b=i+1; if (b >= n) b = 0; // wrap sidelengths[i] = Geometry.DistanceBetween(vertices[a],vertices[b]); } // Group them into heuristic buckets -- no two groups closer than 500 isu. ScalarPartitioning sp = new ScalarPartitioning(sidelengths); idealsidelengths = sp.Partition(500.0); }
// // Implementation private void CongealSideLengths() { // Get side lengths. int n = vertices.Length; sidelengths = new double[n]; for (int i = 0; i < n; ++i) { int a = i; int b = i + 1; if (b >= n) { b = 0; // wrap } sidelengths[i] = Geometry.DistanceBetween(vertices[a], vertices[b]); } // Group them into heuristic buckets -- no two groups closer than 500 isu. ScalarPartitioning sp = new ScalarPartitioning(sidelengths); idealsidelengths = sp.Partition(500.0); }
private void CongealVertexAngles() { // Get internal angles. int n = vertices.Length; double[] absangles = new double[n]; // always positive angles = new double[n]; // retains left/right sign for (int i=0; i < n; ++i) { int a=i-1; int b=i; int c=i+1; if (a < 0) a = n-1; // wrap left if (c >= n) c = 0; // wrap right absangles[i] = Geometry.Rad2Deg(Geometry.AngleDescribedBy(vertices[a],vertices[b],vertices[c])); angles[i] = Geometry.Rad2Deg(Geometry.CurveDescribedBy(vertices[a],vertices[b],vertices[c])); } // Group angles into heuristic buckets -- no two groups closer than 12°. ScalarPartitioning sp = new ScalarPartitioning(absangles); idealangles = sp.Partition(12.0); // Retain original sign (left/right curvature) of angle. for (int i=0; i < n; ++i) idealangles[i] = Math.Sign(angles[i]) * idealangles[i]; }