mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Simplified list_rotate() and polygon_shift()
This commit is contained in:
parent
f19179e232
commit
faea648e66
2 changed files with 2 additions and 6 deletions
|
@ -180,8 +180,7 @@ function reverse(list) =
|
|||
function list_rotate(list,n=1) =
|
||||
assert(is_list(list)||is_string(list))
|
||||
assert(is_num(n))
|
||||
let(n = posmod(n,len(list)))
|
||||
n==0? list : concat(select(list,n,-1), select(list,0,n-1));
|
||||
select(list,n,n+len(list)-1);
|
||||
|
||||
|
||||
// Function: deduplicate()
|
||||
|
|
|
@ -926,10 +926,7 @@ function polygon_area(vertices) =
|
|||
// 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<len(poly))
|
||||
let(
|
||||
poly = cleanup_path(poly)
|
||||
) select(poly,i,i+len(poly)-1);
|
||||
list_rotate(cleanup_path(poly), i);
|
||||
|
||||
|
||||
// Function: polygon_shift_to_closest_point()
|
||||
|
|
Loading…
Reference in a new issue