function_grapher


指定一組 [x, y, f(x, y)],其中 f(x, y) 是個數學函式的運算結果(也就是 z 值),這個模組可以繪製 f(x, y) 的模型。

這個模組相依於 line3dpolyline3dhull_polyline3d,記得含括 line3d.scad, polyline3d.scad, hull_polyline3d.scad。

參數

  • points : 一組 [x, y, f(x, y)]。詳見底下範例。
  • thickness : 圖形面的厚度或線的寬度。
  • style : 圖形風格。可以指定的值有 "FACES""LINES""HULL_FACES""HULL_LINES"。預設為 "FACES",也就是單純地使用 f(x, y) - thickness 作為底部。如果圖形中有斜率很高的面,可能會有厚度上的問題,這時可以試著改用 "HULL_FACES",不過繪製速度會比較慢。指定為 "LINES",只會畫出圖形的骨架。"HULL_LINES" 會超級慢,不過在低的 $fn 時線會看來比較光滑。
  • slicing : 切割方向。一個四邊形可以有兩種三角形的切法,這個模組預設使用 "SLASH",也就是右上左下切法,使用 "BACK_SLASH" 的話,會是左上右下切法。
  • $fa, $fs, $fn : 用來控制內部用到的 circlesphere 模組,用來調整圖形的細緻度,然而也會影響繪圖速度,例如 $fn 設高的話,繪圖速度會變慢。詳見 circlesphere 的說明。

範例

include <line3d.scad>;
include <polyline3d.scad>;
include <hull_polyline3d.scad>;
include <function_grapher.scad>;

points = [
    [[0, 0, 1], [1, 0, 2], [2, 0, 2], [3, 0, 3]],
    [[0, 1, 1], [1, 1, 4], [2, 1, 0], [3, 1, 3]],
    [[0, 2, 1], [1, 2, 3], [2, 2, 1], [3, 2, 3]],
    [[0, 3, 1], [1, 3, 3], [2, 3, 1], [3, 3, 3]]
];

thickness = 0.5;

function_grapher(points, thickness);

function_grapher

include <line3d.scad>;
include <polyline3d.scad>;
include <hull_polyline3d.scad>;
include <function_grapher.scad>;

function f(x, y) = 
   30 * (
       cos(sqrt(pow(x, 2) + pow(y, 2))) + 
       cos(3 * sqrt(pow(x, 2) + pow(y, 2)))
   );

thickness = 2;
min_value =  -200;
max_value = 200;
resolution = 10;

points = [
    for(y = [min_value:resolution:max_value])
        [
            for(x = [min_value:resolution:max_value]) 
                [x, y, f(x, y)]
        ]
];

function_grapher(points, thickness);

function_grapher

include <line3d.scad>;
include <polyline3d.scad>;
include <hull_polyline3d.scad>;
include <function_grapher.scad>;

function f(x, y) = 
   30 * (
       cos(sqrt(pow(x, 2) + pow(y, 2))) + 
       cos(3 * sqrt(pow(x, 2) + pow(y, 2)))
   );

thickness = 2;
min_value =  -200;
max_value = 200;
resolution = 10;
style = "LINES"; 

points = [
    for(y = [min_value:resolution:max_value])
        [
            for(x = [min_value:resolution:max_value]) 
                [x, y, f(x, y)]
        ]
];

function_grapher(points, thickness, style);

function_grapher

include <line3d.scad>;
include <polyline3d.scad>;
include <hull_polyline3d.scad>;
include <function_grapher.scad>;

function f(x, y) = 
   30 * (
       cos(sqrt(pow(x, 2) + pow(y, 2))) + 
       cos(3 * sqrt(pow(x, 2) + pow(y, 2)))
   );

thickness = 2;
min_value =  -200;
max_value = 200;
resolution = 10;
style = "LINES"; 
slicing = "BACK_SLASH";

points = [
    for(y = [min_value:resolution:max_value])
        [
            for(x = [min_value:resolution:max_value]) 
                [x, y, f(x, y)]
        ]
];

function_grapher(points, thickness, style, slicing);

function_grapher