1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-03-14 02:59:42 +01:00

refactor: sort by cross

This commit is contained in:
Justin Lin 2022-04-09 17:39:21 +08:00
parent 73067c7557
commit 544c6e6d46

View File

@ -2,8 +2,5 @@ use <../../util/sort.scad>;
use <_convex_centroid.scad>;
function _convex_ct_clk_order(points) =
let(
cpt = _convex_centroid(points),
pts_as = [for(p = points) [p, atan2(p.y - cpt.y, p.x - cpt.x)]]
)
[for(v = sort(pts_as, by = "idx", idx = 1)) v[0]];
let(cpt = _convex_centroid(points))
sort(points, by = function(p1, p2) cross(p2 - cpt, p1 - cpt));