Skip to content

Commit 596f999

Browse files
William FisetWilliam Fiset
William Fiset
authored and
William Fiset
committed
Redo Thumbnail icons
1 parent bea8404 commit 596f999

File tree

6 files changed

+4
-3
lines changed

6 files changed

+4
-3
lines changed
Binary file not shown.
616 KB
Binary file not shown.
49.9 KB
Binary file not shown.
-1.76 KB
Binary file not shown.
24.3 KB
Binary file not shown.

src/main/java/com/williamfiset/algorithms/geometry/MinimumCostConvexPolygonTriangulation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ private static double cost(Point2D i, Point2D j, Point2D k) {
1818
return i.distance(j) + i.distance(k) + j.distance(k);
1919
}
2020

21-
public static double minimumCostTriangulation(Point2D[] points) {
22-
int len = points.length;
21+
// Input must be a convex polygon with points in CW or CCW order.
22+
public static double minimumCostTriangulation(Point2D[] polygon) {
23+
int len = polygon.length;
2324
if (len < 3) return 0;
2425

2526
double[][] dp = new double[len][len];
@@ -30,7 +31,7 @@ public static double minimumCostTriangulation(Point2D[] points) {
3031
dp[j][j + i] =
3132
Math.min(
3233
dp[j][j + i],
33-
dp[j][k] + dp[k][j + i] + cost(points[j], points[j + i], points[k]));
34+
dp[j][k] + dp[k][j + i] + cost(polygon[j], polygon[j + i], polygon[k]));
3435
}
3536
}
3637
}

0 commit comments

Comments
 (0)