1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 13:01:37 +02:00
This commit is contained in:
Justin Lin
2020-12-04 15:55:51 +08:00
parent ced32c5615
commit b3076fb7b1
2 changed files with 7 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ function _vx_bezier_pt3(p1, p2, p3, p4, pts) =
_vx_bezier3(c, b2, a3, p4, _vx_bezier3(p1, a1, b1, c, concat(pts, [p]))); _vx_bezier3(c, b2, a3, p4, _vx_bezier3(p1, a1, b1, c, concat(pts, [p])));
function _vx_bezier3(p1, p2, p3, p4, pts) = function _vx_bezier3(p1, p2, p3, p4, pts) =
(abs(p1[0] - p4[0]) < 1 && abs(p1[1] - p4[1]) < 1 && abs(p1[2] - p4[2]) < 1) ? (abs(p1[0] - p4[0]) < 0.5 && abs(p1[1] - p4[1]) < 0.5 && abs(p1[2] - p4[2]) < 0.5) ?
pts : pts :
_vx_bezier_pt3(p1, p2, p3, p4, pts); _vx_bezier_pt3(p1, p2, p3, p4, pts);
@@ -28,6 +28,6 @@ function _vx_bezier_pt2(p1, p2, p3, p4, pts) =
_vx_bezier2(c, b2, a3, p4, _vx_bezier2(p1, a1, b1, c, concat(pts, [p]))); _vx_bezier2(c, b2, a3, p4, _vx_bezier2(p1, a1, b1, c, concat(pts, [p])));
function _vx_bezier2(p1, p2, p3, p4, pts) = function _vx_bezier2(p1, p2, p3, p4, pts) =
(abs(p1[0] - p4[0]) < 1 && abs(p1[1] - p4[1]) < 1) ? (abs(p1[0] - p4[0]) < 0.5 && abs(p1[1] - p4[1]) < 0.5) ?
pts : pts :
_vx_bezier_pt2(p1, p2, p3, p4, pts); _vx_bezier_pt2(p1, p2, p3, p4, pts);

View File

@@ -1,11 +1,14 @@
use <__comm__/__to2d.scad>; use <__comm__/__to2d.scad>;
use <__comm__/__to3d.scad>; use <__comm__/__to3d.scad>;
use <_impl/_vx_bezier_impl.scad>; use <_impl/_vx_bezier_impl.scad>;
use <../util/sort.scad>;
use <../util/dedup.scad>;
function vx_bezier(p1, p2, p3, p4) = function vx_bezier(p1, p2, p3, p4) =
let( let(
is2d = len(p1) == 2, is2d = len(p1) == 2,
pts = is2d ? _vx_bezier2(__to3d(p1), __to3d(p2), __to3d(p3), __to3d(p4), []) : pts = is2d ? _vx_bezier2(__to3d(p1), __to3d(p2), __to3d(p3), __to3d(p4), []) :
_vx_bezier3(p1, p2, p3, p4, []) _vx_bezier3(p1, p2, p3, p4, []),
sorted = dedup(sort(pts, by = "vt"), sorted = true)
) )
is2d ? [for(p = pts) __to2d(p)] : pts; is2d ? [for(p = sorted) __to2d(p)] : sorted;