diff --git a/geometry.scad b/geometry.scad index fc809bf..f9108e1 100644 --- a/geometry.scad +++ b/geometry.scad @@ -580,6 +580,23 @@ function polygon_area(vertices) = 0.5*sum([for(i=[0:len(vertices)-1]) det2(select(vertices,i,i+1))]); +// Function: polygon_shift() +// Usage: +// polygon_shift(poly, i); +// Description: +// Given a polygon `poly`, rotates the point ordering so that the first point in the polygon path is the one at index `i`. +// Arguments: +// poly = The list of points in the polygon path. +// i = The index of the point to shift to the front of the path. +// Example: +// polygon_shift([[3,4], [8,2], [0,2], [-4,0]], 2); // Returns [[0,2], [-4,0], [3,4], [8,2]] +function polygon_shift(poly, i) = + assert(i