mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 09:14:29 +02:00
refactor
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
function _sort(pts, i) =
|
||||
let(leng = len(pts))
|
||||
leng <= 1 ? pts :
|
||||
function _sort(lt, i) =
|
||||
let(leng = len(lt))
|
||||
leng <= 1 ? lt :
|
||||
let(
|
||||
pivot = pts[0],
|
||||
before = [for(j = 1; j < leng; j = j + 1) if(pts[j][i] < pivot[i]) pts[j]],
|
||||
after = [for(j = 1; j < leng; j = j + 1) if(pts[j][i] >= pivot[i]) pts[j]]
|
||||
pivot = lt[0],
|
||||
before = [for(j = 1; j < leng; j = j + 1) if(lt[j][i] < pivot[i]) lt[j]],
|
||||
after = [for(j = 1; j < leng; j = j + 1) if(lt[j][i] >= pivot[i]) lt[j]]
|
||||
)
|
||||
concat(_sort(before, i), [pivot], _sort(after, i));
|
||||
|
||||
function sort(points, by, idx = -1) =
|
||||
function sort(lt, by, idx = -1) =
|
||||
let(
|
||||
i = by == "x" ? 0 : (
|
||||
by == "y" ? 1 : (
|
||||
by == "z" ? 2 : idx
|
||||
)
|
||||
)
|
||||
dict = [["x", 0], ["y", 1], ["z", 0], ["idx", idx]],
|
||||
i = dict[search(by, dict)[0]][1]
|
||||
)
|
||||
_sort(points, i);
|
||||
_sort(lt, i);
|
Reference in New Issue
Block a user