1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/docs/lib3x-bezier_smooth.md

57 lines
1.3 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`.
2021-02-11 14:39:09 +08:00
- `angle_threshold` : Default to 0. If the angle between two line segments is bigger than `angle_threshold`, smooth those two segments. **Since:** 3.0
2017-05-17 18:02:57 +08:00
## Examples
2022-06-06 13:11:46 +08:00
use <polyline_join.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]
];
2021-11-18 08:08:50 +08:00
polyline_join(path_pts)
sphere(width / 2);
2017-05-17 18:02:57 +08:00
smoothed_path_pts = bezier_smooth(path_pts, round_d);
2021-11-18 08:08:50 +08:00
color("red")
translate([30, 0, 0])
polyline_join(smoothed_path_pts)
sphere(width / 2);
2017-05-17 18:02:57 +08:00
2021-02-11 14:39:09 +08:00
![bezier_smooth](images/lib3x-bezier_smooth-1.JPG)
2017-05-17 18:02:57 +08:00
2022-06-06 13:11:46 +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);
2022-04-06 17:44:11 +08:00
translate([50, 0, 0])
polygon(smoothed_path_pts);
2017-05-17 18:02:57 +08:00
2021-02-11 14:39:09 +08:00
![bezier_smooth](images/lib3x-bezier_smooth-2.JPG)