From edda3bb85d48ba0393d3da91f898ea648b66792c Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Wed, 21 Aug 2019 23:52:03 -0700 Subject: [PATCH] Added polygon_shift() --- geometry.scad | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/geometry.scad b/geometry.scad index fc809bf1..f9108e1e 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