1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib2x-bezier_smooth.md

55 lines
1.2 KiB
Markdown
Raw Normal View History

2017-05-17 18:02:57 +08:00
# bezier_smooth
2017-05-17 18:11:53 +08:00
Given a path, the `bezier_smooth` function uses bazier curves to smooth all corners. You can use it to create smooth lines or rounded shapes.
2017-05-17 18:02:57 +08:00
## Parameters
- `path_pts` : A list of points represent the path.
- `round_d` : Used to create the other two control points at the corner.
- `t_step` : The distance between two points of the Bézier path at the corner. It defaults to 0.1.
- `closed` : It defaults to `false`. If you have a closed path, set it to `true`.
## Examples
2020-01-28 17:51:20 +08:00
use <hull_polyline3d.scad>;
use <bezier_smooth.scad>;
2017-05-17 18:02:57 +08:00
width = 2;
round_d = 15;
path_pts = [
[0, 0, 0],
[40, 60, 10],
[-50, 90, 30],
[-10, -10, 50]
];
hull_polyline3d(
path_pts, width
);
smoothed_path_pts = bezier_smooth(path_pts, round_d);
color("red") translate([30, 0, 0]) hull_polyline3d(
smoothed_path_pts, width
);
2020-03-30 20:13:47 +08:00
![bezier_smooth](images/lib2x-bezier_smooth-1.JPG)
2017-05-17 18:02:57 +08:00
2020-01-28 17:51:20 +08:00
use <bezier_smooth.scad>;
2017-05-17 18:02:57 +08:00
round_d = 10;
path_pts = [
[0, 0],
[40, 0],
[0, 60]
];
polygon(path_pts);
smoothed_path_pts = bezier_smooth(path_pts, round_d, closed = true);
translate([50, 0, 0]) polygon(smoothed_path_pts);
2020-03-30 20:13:47 +08:00
![bezier_smooth](images/lib2x-bezier_smooth-2.JPG)