1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-21 05:52:16 +02:00

refacto: swap when leng == 2

This commit is contained in:
Justin Lin
2022-04-09 18:48:35 +08:00
parent 18e0ecceae
commit 410c4153f4

View File

@@ -6,6 +6,7 @@ function _cmp(a, b) =
function _convex_hull_sort_by_xyz(pts) =
let(leng = len(pts))
leng <= 1 ? pts :
leng == 2 ? (_cmp(pts[1], pts[0]) ? pts : [pts[1], pts[0]]) :
let(
pivot = pts[0],
before = [for(j = 1; j < leng; j = j + 1) if(_cmp(pts[j], pivot)) pts[j]],