1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 13:01:37 +02:00

support 3D points

This commit is contained in:
Justin Lin
2020-12-04 09:13:39 +08:00
parent 9ff6229628
commit d2065f5410
2 changed files with 13 additions and 4 deletions

View File

@@ -5,11 +5,12 @@ function _vx_bezier_pt(p1, p2, p3, p4, pts) =
a3 = (p3 + p4) * 0.5,
b1 = (a1 + a2) * 0.5,
b2 = (a2 + a3) * 0.5,
c = (b1 + b2) * 0.5
c = (b1 + b2) * 0.5,
p = [round(c[0]), round(c[1]), round(c[0])]
)
_vx_bezier(c, b2, a3, p4, _vx_bezier(p1, a1, b1, c, concat(pts, [[round(c[0]), round(c[1])]])));
_vx_bezier(c, b2, a3, p4, _vx_bezier(p1, a1, b1, c, concat(pts, [p])));
function _vx_bezier(p1, p2, p3, p4, pts) =
(abs(p1[0] - p4[0]) < 1 && abs(p1[1] - p4[1]) < 1) ?
(abs(p1[0] - p4[0]) < 1 && abs(p1[1] - p4[1]) < 1 && abs(p1[2] - p4[2]) < 1) ?
pts :
_vx_bezier_pt(p1, p2, p3, p4, pts);

View File

@@ -1,3 +1,11 @@
use <__comm__/__to2d.scad>;
use <__comm__/__to3d.scad>;
use <_impl/_vx_bezier_impl.scad>;
function vx_bezier(p1, p2, p3, p4) = _vx_bezier(p1, p2, p3, p4, []);
function vx_bezier(p1, p2, p3, p4) =
let(
is2d = len(p1) == 2,
pts = is2d ? _vx_bezier(__to3d(p1), __to3d(p2), __to3d(p3), __to3d(p4), []) :
_vx_bezier(p1, p2, p3, p4, [])
)
is2d ? [for(p = pts) __to2d(p)] : pts;