1
0
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:
Justin Lin
2022-04-09 18:22:11 +08:00
parent 544c6e6d46
commit fd404de056

View File

@@ -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]];