1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-17 20:11:50 +02: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>; use <_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)]]
)
[for(v = sort(pts_as, by = "idx", idx = 1)) v[0]];