[OpenSCAD] bend a pipe/tube

Chow Loong Jin hyperair at debian.org
Fri May 1 13:09:53 EDT 2015


On Thu, Apr 30, 2015 at 09:52:03AM -0700, biskero wrote:
> Ciao,
> 
> I looked at what you said about changing the following code but not sure how
> to do it with the lib you mention:
> 
> translate([0,0,-r2-1]) 
>                         linear_extrude(height=2*r2+2) 
>         polygon([ 
>                             [0,0], 
>                             [trx * cos(a0), try * sin(a0)], 
>                             [trx * cos(a1), try * sin(a1)], 
>                             [trx * cos(a2), try * sin(a2)], 
>                             [trx * cos(a3), try * sin(a3)], 
>                             [trx * cos(a4), try * sin(a4)], 
>                             [0,0] 
>                        ]);

translate([0,0,-r2-1])
linear_extrude(height=2*r2+2)
pieSlice (size = max (trx, try), start_angle = start_angle, end_angle = end_angle);

By the way, I'll just leave this here as another sweep() example:

use <MCAD/general/sweep.scad>
use <MCAD/general/facets.scad>
use <scad-utils/shapes.scad>
use <scad-utils/transformations.scad>

$fs = 0.4;
$fa = 1;


function cot (angle) = 1 / tan (angle);

module elliptical_torus (r_x, r_y, cross_section_r)
{
    cross_section = circle (r = cross_section_r,
        $fn = get_fragments_from_r (cross_section_r));

    // from http://math.stackexchange.com/questions/432902/
    function radius_at_angle (angle) = (
        (r_x * r_y) /
        sqrt (pow (r_x * sin (angle), 2) + pow (r_y * cos (angle), 2))
    );

    // g, flattening factor as per wiki
    flattening_factor = 1 - r_y / r_x;
    function tangential_angle (polar_angle) = (
        ((polar_angle % 360 > 180) ? 180 : 0) +
        atan (-1 / (tan (polar_angle) / pow (1 - flattening_factor, 2)))
    );

    sweep (
        cross_section,
        [
            for (t = gen_facet_series (min (r_x, r_y)))
            let (angle = t * 360)
            translation ([r_x * cos (angle), r_y * sin (angle), 0]) *
            rotation ([0, 0, 90 + tangential_angle (angle)]) *
            rotation ([90, 0, 0])
        ],
        true
    );
}

elliptical_torus (r_x = 40, r_y = 20, cross_section_r = 2);


-- 
Kind regards,
Loong Jin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150502/764abaec/attachment.asc>


More information about the Discuss mailing list