【问题标题】:How to a make a curved sheet (cube) in OpenSCAD?如何在 OpenSCAD 中制作曲面片(立方体)?
【发布时间】:2020-09-19 18:10:11
【问题描述】:

如何弯曲一张表(立方体)?我想控制弯曲/曲线的角度。

例如

立方体([50,50,2]);

【问题讨论】:

    标签: curve openscad


    【解决方案1】:

    您可以rotate_extrude() 一个带有参数角度的矩形。这需要 openscad 版本 2016.xx 或更高版本,请参阅 documentation。 需要安装开发快照,见download openscad

    $fn= 360;
    
    width = 10;   // width of rectangle
    height = 2;   // height of rectangle
    r = 50;       // radius of the curve
    a = 30;       // angle of the curve
    
    rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
    

    看起来像这样:

    曲线由半径和角度定义。我认为在此草图中使用其他尺寸(例如长度或 dh)更现实

    并计算半径和角度

    $fn= 360;
    
    w = 10;       // width of rectangle
    h = 2;       // height of rectangle
    l = 25;      // length of chord of the curve
    dh = 2;           // delta height of the curve
    
    module curve(width, height, length, dh) {
        // calculate radius and angle
        r = ((length/2)*(length/2) - dh*dh)/(2*dh);
        a = asin((length/2)/r);
        rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
    }
    
    curve(w, h, l, dh);
    

    编辑 30.09.2019: 考虑到 Cfreitas 的评论,另外将生成的形状移动到原点,因此可以在坐标轴上看到尺寸

    $fn= 360;
    
    w = 10;       // width of rectangle
    h = 2;       // height of rectangle
    l = 30;      // length of chord of the curve
    dh = 4;           // delta height of the curve
    
    module curve(width, height, length, dh) {
        r = (pow(length/2, 2) + pow(dh, 2))/(2*dh);
        a = 2*asin((length/2)/r);
        translate([-(r -dh), 0, -width/2]) rotate([0, 0, -a/2])         rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
    }
    
    curve(w, h, l, dh);
    

    结果:

    编辑 19.09.2020:上次编辑中有错字:在第一个“翻译”中,应使用本地“宽度”而不是“w”。在上面的代码中更正了它。

    【讨论】:

    • 加上一个想法。但是对 a 和 r 的计算是错误的。正确的公式是 b:r = (length*length + 4*dh*dh)/(8*dh);a = 2*asin(length/(2*r));
    • @CFreitas:正确,请参阅我的答案的编辑,新公式与您的相同
    【解决方案2】:

    我可以这样做,但如果您可以将#degrees 中的弯曲/曲线指定为函数的参数会更好:

    $fn=300;
    module oval(w, h, height, center = false) {
     scale([1, h/w, 1]) cylinder(h=height, r=w, center=center);
    }
    
    module curved(w,l,h) {
        difference() {
          oval(w,l,h);
          translate([0.5,-1,-1]) color("red") oval(w,l+2,h+2);
        }
    }
    
    
    curved(10,20,30);
    

    【讨论】:

      【解决方案3】:

      使用 a_manthey_67 使用的概念,纠正数学并将结果对象居中(将弦与 y 轴对齐):

      module bentCube(width, height, length, dh) {
      // calculate radius and angle
      r = (length*length + 4*dh*dh)/(8*dh);
      a = 2*asin(length/(2*r));
      translate([-r,0,0]) rotate([0,0,-a/2])
      rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);}
      

      【讨论】:

        【解决方案4】:

        或者,如果您只想要具有固定长度和一定弯曲角度的东西,请执行以下操作:

        module curve(width, height, length, a) {
            if( a > 0 ) {
                r = (360 * (length/a)) / (2 * pi);
                translate( [-r-height/2,0,0] )
                rotate_extrude(angle = a)
                    translate([r, 0, 0])
                        square(size = [height, width], center = false);
            } else {
                translate( [-height/2,0,width] )
                rotate( a=270, v=[1,0,0] )
                linear_extrude( height = length )
                    square(size = [height, width], center = false);
        
            }
        }
        

        当弯曲角度为0时需要if (a > 0)语句进行异常处理(如果绘制曲面,将导致无限半径)。

        Animated GIF here

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-09-27
          • 1970-01-01
          相关资源
          最近更新 更多