R OMS
R OMS

Reputation: 662

How to a make a curved sheet (cube) in OpenSCAD?

How can I curve a sheet (cube)? I'd like to control the angle of the bend/curve.

curve

e.g.

cube([50,50,2]);

Upvotes: 6

Views: 8531

Answers (4)

a_manthey_67
a_manthey_67

Reputation: 4286

You can rotate_extrude() an rectangle with the parameter angle. This requires the openscad version 2016.xx or newer, see documentation. It is necessary to install a development snapshot, see 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);

looks like this:

enter image description here

The curve is defined by radius and angle. I think it is more realistic, to use other dimensions like length or dh in this sketch

enter image description here

and calculate radius and angle

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

Edit 30.09.2019: considering comment of Cfreitas, additionally moved the resulting shape to origin, so dimensions can be seen on axes of coordinates

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

and the result:

enter image description here

Edit 19.09.2020: There was a typo in the last edit: In the first 'translate' the local 'width' should be used instead of 'w'. Corrected it in the code above.

Upvotes: 9

Tomas Smits
Tomas Smits

Reputation: 1

Or, if you just want something with a fixed length, and a certain bent angle do this:

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

    }
}

The if (a > 0) statement is needed to make an exception when the bending angle is 0 (which, if drawing a curved surface, would result in an infinite radius).

Animated GIF here

Upvotes: 0

CFreitas
CFreitas

Reputation: 1775

Using the concept used by a_manthey_67, corrected the math and centered (aligned the chord with y axis) the resulting object:

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

Upvotes: 0

R OMS
R OMS

Reputation: 662

I can do it this way but it would be better if you could specify the bend/curve in #degrees as an argument to the function:

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

Upvotes: 1

Related Questions