From f55f1a2591fd345ba0db9772bbec5a0c50a158c1 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 8 Apr 2017 06:48:36 +0800 Subject: [PATCH] renamed module name --- README.md | 2 +- ...ib-bezier-1.JPG => lib-bezier_curve-1.JPG} | Bin docs/{lib-bezier.md => lib-bezier_curve.md} | 10 ++++---- src/{bezier.scad => bezier_curve.scad} | 22 +++++++++--------- 4 files changed, 17 insertions(+), 17 deletions(-) rename docs/images/{lib-bezier-1.JPG => lib-bezier_curve-1.JPG} (100%) rename docs/{lib-bezier.md => lib-bezier_curve.md} (55%) rename src/{bezier.scad => bezier_curve.scad} (62%) diff --git a/README.md b/README.md index e5139e2c..6ceed60c 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Some modules may depend on other modules. For example, the `polyline2d` module d - Path - [circle_path](https://openhome.cc/eGossip/OpenSCAD/lib-circle_path.html) - - [bezier](https://openhome.cc/eGossip/OpenSCAD/lib-bezier.html) + - [bezier_curve](https://openhome.cc/eGossip/OpenSCAD/lib-bezier_curve.html) - [helix](https://openhome.cc/eGossip/OpenSCAD/lib-helix.html) - [archimedean_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral.html) - [sphere_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral.html) diff --git a/docs/images/lib-bezier-1.JPG b/docs/images/lib-bezier_curve-1.JPG similarity index 100% rename from docs/images/lib-bezier-1.JPG rename to docs/images/lib-bezier_curve-1.JPG diff --git a/docs/lib-bezier.md b/docs/lib-bezier_curve.md similarity index 55% rename from docs/lib-bezier.md rename to docs/lib-bezier_curve.md index 012976d0..aec5b199 100644 --- a/docs/lib-bezier.md +++ b/docs/lib-bezier_curve.md @@ -1,6 +1,6 @@ -# bezier +# bezier_curve -Given a set of control points, the bezier function returns points of the Bézier path. Combined with the `polyline`, `polyline3d` or `hull_polyline3d` module defined in my lib-openscad, you can create a Bézier curve. +Given a set of control points, the bezier_curve function returns points of the Bézier path. Combined with the `polyline`, `polyline3d` or `hull_polyline3d` module defined in my lib-openscad, you can create a Bézier curve. ## Parameters @@ -12,7 +12,7 @@ Given a set of control points, the bezier function returns points of the Bézier If you have four control points and combine with the `hull_polyline3d` module: include ; - include ; + include ; t_step = 0.05; width = 2; @@ -22,10 +22,10 @@ If you have four control points and combine with the `hull_polyline3d` module: p2 = [-50, 90, 0]; p3 = [0, 200, -35]; - points = bezier(t_step, + points = bezier_curve(t_step, [p0, p1, p2, p3] ); hull_polyline3d(points, width); -![bezier](images/lib-bezier-1.JPG) +![bezier_curve](images/lib-bezier_curve-1.JPG) diff --git a/src/bezier.scad b/src/bezier_curve.scad similarity index 62% rename from src/bezier.scad rename to src/bezier_curve.scad index 832264f7..47729a17 100644 --- a/src/bezier.scad +++ b/src/bezier_curve.scad @@ -1,47 +1,47 @@ /** -* bezier.scad +* bezier_curve.scad * -* Given a set of control points, the bezier function returns points of the Bézier path. +* Given a set of control points, the bezier_curve function returns points of the Bézier path. * Combined with the polyline, polyline3d or hull_polyline3d module defined in my lib-openscad, * you can create a Bézier curve. * * @copyright Justin Lin, 2017 * @license https://opensource.org/licenses/lgpl-3.0.html * -* @see https://openhome.cc/eGossip/OpenSCAD/lib-bezier.html +* @see https://openhome.cc/eGossip/OpenSCAD/lib-bezier_curve.html * **/ function _combi(r, n) = n == 0 ? 1 : (_combi(r, n - 1) * (r - n + 1) / n); -function bezier_coordinate(t, pn, n, i = 0) = +function bezier_curve_coordinate(t, pn, n, i = 0) = i == n + 1 ? 0 : (_combi(n, i) * pn[i] * pow(1 - t, n - i) * pow(t, i) + - bezier_coordinate(t, pn, n, i + 1)); + bezier_curve_coordinate(t, pn, n, i + 1)); -function _bezier_point(t, points) = +function _bezier_curve_point(t, points) = let(n = len(points) - 1) [ - bezier_coordinate( + bezier_curve_coordinate( t, [points[0][0], points[1][0], points[2][0], points[3][0]], n ), - bezier_coordinate( + bezier_curve_coordinate( t, [points[0][1], points[1][1], points[2][1], points[3][1]], n ), - bezier_coordinate( + bezier_curve_coordinate( t, [points[0][2], points[1][2], points[2][2], points[3][2]], n ) ]; -function bezier(t_step, points) = +function bezier_curve(t_step, points) = [ for(t = [0: t_step: 1 + t_step]) - _bezier_point(t, points) + _bezier_curve_point(t, points) ]; \ No newline at end of file