Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

curve

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

like image 984
R OMS Avatar asked Jan 09 '19 17:01

R OMS


2 Answers

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.

like image 188
a_manthey_67 Avatar answered Nov 16 '22 14:11

a_manthey_67


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);
like image 33
R OMS Avatar answered Nov 16 '22 14:11

R OMS