mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 18:24:28 +02:00
refactor: sort by cross
This commit is contained in:
@@ -2,9 +2,5 @@ use <util/sort.scad>;
|
|||||||
use <experimental/convex_centroid.scad>;
|
use <experimental/convex_centroid.scad>;
|
||||||
|
|
||||||
function convex_ct_clk_order(points) =
|
function convex_ct_clk_order(points) =
|
||||||
let(
|
let(cpt = convex_centroid(points))
|
||||||
cpt = convex_centroid(points),
|
sort(points, by = function(p1, p2) cross(p2 - cpt, p1 - cpt));
|
||||||
pts_as = [for(p = points) [p, atan2(p.y - cpt.y, p.x - cpt.x)]],
|
|
||||||
sorted = sort(pts_as, by = "idx", idx = 1)
|
|
||||||
)
|
|
||||||
[for(v = sorted) v[0]];
|
|
Reference in New Issue
Block a user