有没有办法在 OpenSCAD 中沿 z 轴弯曲三角形?

时间:2021-05-10 13:37:31

标签: 3d openscad

我在 openSCAD 中使用函数/模块绘制了一个三角形,使其边缘变圆(主要是因为我有点懒,但也因为我不想弄乱它)。我现在想将三角形​​从顶部弯曲到底部。

        
fn=128;


    RoundedPolygon([[0,0],[120,260],[230,0]],25,fn);

module RoundedPolygon(P,r,fn)
{
    rotate(a=90, v=[0,0,1]){
    rotate([90,180,180]) scale([1,1,5]) 
        {
    v = rounded_polygon_v(P,r,fn);
    polygon(v);};};
    
}

function bezier_smooth(path_pts, round_d, t_step = 0.1, closed = false, angle_threshold = 0) =
    _bezier_smooth_impl(path_pts, round_d, t_step, closed, angle_threshold);

function rounded_polygon_v(P,r,fn) =
let
(
    step = 360 / fn,
    n = len(P),
    o_v = [ for(i=[0:n-1]) atan2(P[(i+1)%n][1] - P[i][1], P[(i+1)%n][0] - P[i][0]) + 90 + 360 ]
)
[ 
        for(i=[0:n-1])
            let 
            (
                n1 = i, 
                n2 = (i+1)%n,
                w1 = o_v[n1],
                w2 = (o_v[n2] < w1) ? o_v[n2] : o_v[n2] - 360
            )
            for (w=[w1:-step:w2]) 
                [ cos(w)*r+P[n2][0], sin(w)*r+P[n2][1] ] 
] ;

它可以工作,但无论我如何尝试弯曲它(从下到上或从上到下,沿着 z 轴(我认为无论如何你都会这样描述它)。

有没有人在 openSCAD 中有任何技巧或技巧可以做到这一点?

0 个答案:

没有答案