2017-04-08 06:48:36 +08:00
|
|
|
# bezier_curve
|
2017-03-22 10:47:09 +08:00
|
|
|
|
2021-12-04 10:57:29 +08:00
|
|
|
Given a set of control points, the `bezier_curve` function returns points of the Bézier path.
|
2017-03-22 10:47:09 +08:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
- `t_step` : The distance between two points of the Bézier path.
|
2019-07-28 18:24:48 +08:00
|
|
|
- `points` : A list of `[x, y]` or `[x, y, z]` control points.
|
2017-03-22 10:47:09 +08:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2021-12-04 10:57:29 +08:00
|
|
|
If you have four control points:
|
2017-03-22 10:47:09 +08:00
|
|
|
|
2021-12-04 10:57:29 +08:00
|
|
|
use <polyline_join.scad>;
|
2020-01-28 17:51:20 +08:00
|
|
|
use <bezier_curve.scad>;
|
2017-03-30 14:22:48 +08:00
|
|
|
|
2017-03-22 10:47:09 +08:00
|
|
|
t_step = 0.05;
|
2021-12-04 10:57:29 +08:00
|
|
|
radius = 2;
|
2017-03-22 10:47:09 +08:00
|
|
|
|
|
|
|
p0 = [0, 0, 0];
|
|
|
|
p1 = [40, 60, 35];
|
|
|
|
p2 = [-50, 90, 0];
|
|
|
|
p3 = [0, 200, -35];
|
|
|
|
|
2017-04-08 06:48:36 +08:00
|
|
|
points = bezier_curve(t_step,
|
2017-03-22 10:47:09 +08:00
|
|
|
[p0, p1, p2, p3]
|
|
|
|
);
|
|
|
|
|
2021-12-04 10:57:29 +08:00
|
|
|
polyline_join(points)
|
|
|
|
sphere(radius);
|
2017-03-22 10:47:09 +08:00
|
|
|
|
2021-02-24 21:09:54 +08:00
|
|
|
![bezier_curve](images/lib3x-bezier_curve-1.JPG)
|