path_extrude


將一個 2D 圖形沿著路徑拉伸,適用於連續函式產生的路徑。

使用此模組時,要使用座標點來表示 2D 圖形。如果 2D 圖案不是實心的話,必須指定 triangles 參數,詳見 polysections 說明。

相依於 rotate_ppolysections

參數

  • shape_pts : 代表 2D 圖形的座標點,詳見底下範例。
  • path_pts : 代表路徑的座標點。
  • triangles : "SOLID"(預設)、"HOLLOW" 或自定義索引。詳見底下範例。
  • twist : 沿路徑推移時扭轉的角度。
  • scale : 沿路徑推移的縮放,可以單一值或者是 [x, y] 形式。
  • closed : 如果路徑的第一個點與最後一個點重合,將 closed 設為 true 可以自動閉合。

範例

include <rotate_p.scad>;
include <polysections.scad>;
include <path_extrude.scad>;
include <bezier_curve.scad>;

t_step = 0.05;
width = 2;

p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
p3 = [20, 150, -35];
p4 = [30, 50, -3];

shape_pts = [   
    [5, -5],
    [3, 4],
    [0, 5],
    [-5, -5] 
];

path_pts = bezier_curve(t_step, 
    [p0, p1, p2, p3, p4]
);

path_extrude(shape_pts, path_pts);

path_extrude

include <rotate_p.scad>;
include <polysections.scad>;
include <path_extrude.scad>;
include <bezier_curve.scad>;

t_step = 0.05;

p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
p3 = [20, 150, -35];
p4 = [30, 50, -3];

shape_pts = [
    // 外輪廓
    [5, 0],
    [3, 9],
    [0, 10],    
    [-5, 0],
    // 內輪廓
    [3, 2],
    [2, 7],
    [0, 7],
    [-3, 2]
];

path_pts = bezier_curve(t_step, 
    [p0, p1, p2, p3, p4]
);

path_extrude(shape_pts, path_pts, triangles = "HOLLOW");

path_extrude

include <rotate_p.scad>;
include <polysections.scad>;
include <path_extrude.scad>;
include <bezier_curve.scad>;

t_step = 0.05;

p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
p3 = [20, 150, -5];
p4 = [50, 50, -3];

shape_pts = [
    // 外輪廓
    [10, 0],
    [-5, 10],
    [-10, 0],
    // 內輪廓
    [7, 1],
    [-4, 8],
    [-7, 1]
];

path_pts = bezier_curve(t_step, 
    [p0, p1, p2, p3, p4]
);

path_extrude(
    shape_pts, 
    path_pts,      
    triangles = [
        [0, 4, 3],
        [0, 1, 4],
        [1, 5, 4],
        [1, 2, 5],
        [2, 3, 5],
        [2, 0, 3]
    ]
);

path_extrude