bezier_smooth


給定一個路徑,這個函式會使用貝茲曲線來讓轉角變得和緩,可以使用這個函式來將建立和緩的曲線或圓角多邊形。

相依:bezier_curve 函式。

參數

  • path_pts : 代表路徑的座標清單。
  • round_d : 建立圓角時用來建立另兩個控制點之用。
  • t_step : 轉折處建立之貝茲曲線兩點間的距離。預設為 0.1。
  • closed : 預設為 false。如果要建立封閉曲線,可設為 true

範例

include <hull_polyline3d.scad>;
include <bezier_curve.scad>;
include <bezier_smooth.scad>;

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
);

bezier_smooth

include <bezier_curve.scad>;
include <bezier_smooth.scad>;

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);

bezier_smooth