mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-20 05:21:38 +02:00
renamed module name
This commit is contained in:
@@ -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)
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -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 <hull_polyline3d.scad>;
|
||||
include <bezier.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
|
||||
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);
|
||||
|
||||

|
||||

|
@@ -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)
|
||||
];
|
Reference in New Issue
Block a user