discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

connecting cylinders at arbitrary angles

JB
Jordan Brown
Fri, Nov 17, 2017 11:48 PM

In order to make things like this:

I have a module that takes a list of points and connects them with
cylinders, with spheres at the junctions.

Geometrically, those junctions would be perfect and smooth.  However,
given the quantization of round things, it's not so good:

Preview performance on this model is awful, and it takes ~13 minutes to
render.  I have to wonder whether some of that performance is due to
having to manage all of these little microstructures.

Increasing the resolution of the round things makes the result prettier,
but slows down rendering because it's just trading these ugly
microstructures for a larger number of prettier microstructures.

Anybody have any ideas or tricks for doing this in a way that performs well?

(Probably the real answer for this particular case, where the diameter
is only 2mm, is to model these round pieces as rectangles; in theory
that would mean something like 12 triangles per segment.  However,
that's not very satisfying in the general case.)

In order to make things like this: I have a module that takes a list of points and connects them with cylinders, with spheres at the junctions. Geometrically, those junctions would be perfect and smooth.  However, given the quantization of round things, it's not so good: Preview performance on this model is awful, and it takes ~13 minutes to render.  I have to wonder whether some of that performance is due to having to manage all of these little microstructures. Increasing the resolution of the round things makes the result prettier, but slows down rendering because it's just trading these ugly microstructures for a larger number of prettier microstructures. Anybody have any ideas or tricks for doing this in a way that performs well? (Probably the real answer for this particular case, where the diameter is only 2mm, is to model these round pieces as rectangles; in theory that would mean something like 12 triangles per segment.  However, that's not very satisfying in the general case.)
AB
Antonio Bueno
Sat, Nov 18, 2017 12:04 AM

Hi.

My first try would be to use spheres as points and hull() them in pairs,
but I have no idea of how many points you're working with. Maybe it
wouldn't be fast enough.

For optimal hull-ing and overall prettyness I'd rotate each sphere/point to
the average angle between each pair of segments.

2017-11-18 0:48 GMT+01:00 Jordan Brown openscad@jordan.maileater.net:

In order to make things like this:

I have a module that takes a list of points and connects them with
cylinders, with spheres at the junctions.

Geometrically, those junctions would be perfect and smooth.  However,
given the quantization of round things, it's not so good:

Preview performance on this model is awful, and it takes ~13 minutes to
render.  I have to wonder whether some of that performance is due to having
to manage all of these little microstructures.

Increasing the resolution of the round things makes the result prettier,
but slows down rendering because it's just trading these ugly
microstructures for a larger number of prettier microstructures.

Anybody have any ideas or tricks for doing this in a way that performs
well?

(Probably the real answer for this particular case, where the diameter is
only 2mm, is to model these round pieces as rectangles; in theory that
would mean something like 12 triangles per segment.  However, that's not
very satisfying in the general case.)


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
Regards,
Antonio

Hi. My first try would be to use spheres as points and hull() them in pairs, but I have no idea of how many points you're working with. Maybe it wouldn't be fast enough. For optimal hull-ing and overall prettyness I'd rotate each sphere/point to the average angle between each pair of segments. 2017-11-18 0:48 GMT+01:00 Jordan Brown <openscad@jordan.maileater.net>: > In order to make things like this: > > I have a module that takes a list of points and connects them with > cylinders, with spheres at the junctions. > > Geometrically, those junctions would be perfect and smooth. However, > given the quantization of round things, it's not so good: > > Preview performance on this model is awful, and it takes ~13 minutes to > render. I have to wonder whether some of that performance is due to having > to manage all of these little microstructures. > > Increasing the resolution of the round things makes the result prettier, > but slows down rendering because it's just trading these ugly > microstructures for a larger number of prettier microstructures. > > Anybody have any ideas or tricks for doing this in a way that performs > well? > > (Probably the real answer for this particular case, where the diameter is > only 2mm, is to model these round pieces as rectangles; in theory that > would mean something like 12 triangles per segment. However, that's not > very satisfying in the general case.) > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > -- Regards, Antonio
RP
Ronaldo Persiano
Sat, Nov 18, 2017 1:35 AM

To render the union of a large set of primitives is usually very slow. Even
the preview may be slow if you have thousands of facets. What you need is a
sweep operator: given a path and a planar section, it builds a generalized
cylinder along the path with the given section. Sweep operator usually does
that by using the primitive polyhedron which is a lot faster than the union
of many stuffs, but each sweep should not have self-intersections. That
kind of sweep may be much faster but remember that the union of many sweeps
may require some time to render.

Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep
examples in https://github.com/openscad/list-comprehension-demos.

To render the union of a large set of primitives is usually very slow. Even the preview may be slow if you have thousands of facets. What you need is a sweep operator: given a path and a planar section, it builds a generalized cylinder along the path with the given section. Sweep operator usually does that by using the primitive polyhedron which is a lot faster than the union of many stuffs, but each sweep should not have self-intersections. That kind of sweep may be much faster but remember that the union of many sweeps may require some time to render. Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep examples in https://github.com/openscad/list-comprehension-demos.
FV
Frank van der Hulst
Sat, Nov 18, 2017 2:27 AM

There's a Bezier curve library on Thingiverse which allows extruding a
specific shape along a curve.

On 18/11/2017 14:36, "Ronaldo Persiano" rcmpersiano@gmail.com wrote:

To render the union of a large set of primitives is usually very slow.
Even the preview may be slow if you have thousands of facets. What you need
is a sweep operator: given a path and a planar section, it builds a
generalized cylinder along the path with the given section. Sweep operator
usually does that by using the primitive polyhedron which is a lot faster
than the union of many stuffs, but each sweep should not have
self-intersections. That kind of sweep may be much faster but remember that
the union of many sweeps may require some time to render.

Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep
examples in https://github.com/openscad/list-comprehension-demos.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

There's a Bezier curve library on Thingiverse which allows extruding a specific shape along a curve. On 18/11/2017 14:36, "Ronaldo Persiano" <rcmpersiano@gmail.com> wrote: > To render the union of a large set of primitives is usually very slow. > Even the preview may be slow if you have thousands of facets. What you need > is a sweep operator: given a path and a planar section, it builds a > generalized cylinder along the path with the given section. Sweep operator > usually does that by using the primitive polyhedron which is a lot faster > than the union of many stuffs, but each sweep should not have > self-intersections. That kind of sweep may be much faster but remember that > the union of many sweeps may require some time to render. > > Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep > examples in https://github.com/openscad/list-comprehension-demos. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
RD
Revar Desmera
Sat, Nov 18, 2017 4:39 AM

There is are bezier extrusion type calls in my BOSL library that can sweep a 2D path perpendicularly along a 3D bezier path. It creates it as a polyhedron.

https://github.com/revarbat/BOSL

Look for extrude_bezier_along_bezier() in BOSL/bezier.scad

  • Revar

On Nov 17, 2017, at 6:27 PM, Frank van der Hulst drifter.frank@gmail.com wrote:

There's a Bezier curve library on Thingiverse which allows extruding a specific shape along a curve.

On 18/11/2017 14:36, "Ronaldo Persiano" rcmpersiano@gmail.com wrote:
To render the union of a large set of primitives is usually very slow. Even the preview may be slow if you have thousands of facets. What you need is a sweep operator: given a path and a planar section, it builds a generalized cylinder along the path with the given section. Sweep operator usually does that by using the primitive polyhedron which is a lot faster than the union of many stuffs, but each sweep should not have self-intersections. That kind of sweep may be much faster but remember that the union of many sweeps may require some time to render.

Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep examples in https://github.com/openscad/list-comprehension-demos.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

There is are bezier extrusion type calls in my BOSL library that can sweep a 2D path perpendicularly along a 3D bezier path. It creates it as a polyhedron. https://github.com/revarbat/BOSL Look for extrude_bezier_along_bezier() in BOSL/bezier.scad - Revar > On Nov 17, 2017, at 6:27 PM, Frank van der Hulst <drifter.frank@gmail.com> wrote: > > There's a Bezier curve library on Thingiverse which allows extruding a specific shape along a curve. > >> On 18/11/2017 14:36, "Ronaldo Persiano" <rcmpersiano@gmail.com> wrote: >> To render the union of a large set of primitives is usually very slow. Even the preview may be slow if you have thousands of facets. What you need is a sweep operator: given a path and a planar section, it builds a generalized cylinder along the path with the given section. Sweep operator usually does that by using the primitive polyhedron which is a lot faster than the union of many stuffs, but each sweep should not have self-intersections. That kind of sweep may be much faster but remember that the union of many sweeps may require some time to render. >> >> Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep examples in https://github.com/openscad/list-comprehension-demos. >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
RM
Roland Mieslinger
Sun, Nov 19, 2017 12:24 PM

This could be a middle ground between what you have and the other proposals:

module curved_pipe(r = 1, h = 1, curve_angle = 0, curve_radius = 0, twist = 0) {
off = r + curve_radius;
er = curve_angle == 0 ? 0 : 90 * (1 - sign(curve_angle));
rotate([0, 0, twist + er]) {
cylinder(r = r, h = h);
translate([-off, 0, h]) rotate([90, 0, 0])
rotate_extrude(angle = abs(curve_angle))
translate([off, 0, 0]) circle(r = r);
translate([-off, 0, h]) rotate([0, -abs(curve_angle), 0])
translate([off, 0, 0]) rotate([0, 0, er]) children();
}
}

Basically a parametric cylinder, plus a curved connection element, that connects itself to

its children (note that there is only one semicolon after each example).

can be used like here:

curved_pipe(h = 5, curve_angle = -72, curve_radius = 5)
curved_pipe(h = 5, curve_angle = -72, curve_radius = 5)
curved_pipe(h = 5, curve_angle = -72, curve_radius = 5)
curved_pipe(h = 5, curve_angle = -72, curve_radius = 5)
curved_pipe(h = 5, curve_angle = -72, curve_radius = 5);

or just with curved elements

curved_pipe(h = 0, curve_angle = 30, curve_radius = 1)
curved_pipe(h = 0, curve_angle = 30, curve_radius = 3)
curved_pipe(h = 0, curve_angle = 10, curve_radius = 5)
curved_pipe(h = 0, curve_angle = 40, curve_radius = 7)
curved_pipe(h = 0, curve_angle = 60, curve_radius = 9);

If you want to define the elements in an array use eg.:

module curved_pipe_path(parameters, index = 0) {
if(index < len(parameters)) {
element = parameters[index];
curved_pipe(r = 5, h = element[0], curve_angle = element[1])
curved_pipe_path(parameters, index = index + 1);
}
}

params = [[5, 52], [5, 62], [5, 72], [5.7, 82], [7.9, 92]];

curved_pipe_path(params);

Limitations: Artifacts are created if you use twist and/or positive and negative curvature

in the same object. To avoid them ensure that fundamental circle is made of 360/twist

elements (or a multiple of that), ge. using $fn.

--

Roland

Gesendet: Samstag, 18. November 2017 um 00:48 Uhr
Von: "Jordan Brown" <openscad@jordan.maileater.net>
An: "OpenSCAD general discussion" <discuss@lists.openscad.org>
Betreff: [OpenSCAD] connecting cylinders at arbitrary angles

In order to make things like this:

I have a module that takes a list of points and connects them with cylinders, with spheres at the junctions.

Geometrically, those junctions would be perfect and smooth. However, given the quantization of round things, it's not so good:

Preview performance on this model is awful, and it takes ~13 minutes to render. I have to wonder whether some of that performance is due to having to manage all of these little microstructures.

Increasing the resolution of the round things makes the result prettier, but slows down rendering because it's just trading these ugly microstructures for a larger number of prettier microstructures.

Anybody have any ideas or tricks for doing this in a way that performs well?

(Probably the real answer for this particular case, where the diameter is only 2mm, is to model these round pieces as rectangles; in theory that would mean something like 12 triangles per segment. However, that's not very satisfying in the general case.)

_______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

RP
Ronaldo Persiano
Wed, Nov 22, 2017 4:55 AM

2017-11-19 10:24 GMT-02:00 Roland Mieslinger rmie@gmx.de:

Limitations: Artifacts are created if you use twist and/or positive and
negative curvature
in the same object. To avoid them ensure that fundamental circle is made
of 360/twist
elements (or a multiple of that), ge. using $fn.

The artifact that emerges from inflections disappears when $fn is even.
​The twist artifact may be fully eliminated with proper rotations of the
circles and cylinders.

module curved_pipe(r = 1, h = 1, curve_angle = 0, curve_radius = 0, twist =
0) {
off = r + curve_radius;
er = curve_angle == 0 ? 0 : 90 * (1 - sign(curve_angle));
ttwist = $total_twist==undef? twist: $total_twist + twist; //<<<
inserted lines
rotate([0, 0, twist + er]) {
rotate(-ttwist) //<<<
cylinder(r = r, h = h);
translate([-off, 0, h]) rotate([90, 0, 0])
rotate_extrude(angle = abs(curve_angle))
translate([off, 0, 0])
rotate(ttwist) //<<<
circle(r = r);

  let($total_twist = ttwist) { //<<< pass the current total down the

tree
translate([-off, 0, h])
rotate([0, -abs(curve_angle), 0])
translate([off, 0, 0])
rotate([0, 0, er])
children();
} //<<<
}
}

The variable $total_twist adds up the twists of a sequence of curved_pipe.

2017-11-19 10:24 GMT-02:00 Roland Mieslinger <rmie@gmx.de>: > Limitations: Artifacts are created if you use twist and/or positive and > negative curvature > in the same object. To avoid them ensure that fundamental circle is made > of 360/twist > elements (or a multiple of that), ge. using $fn. > > The artifact that emerges from inflections disappears when $fn is even. ​The twist artifact may be fully eliminated with proper rotations of the circles and cylinders. module curved_pipe(r = 1, h = 1, curve_angle = 0, curve_radius = 0, twist = 0) { off = r + curve_radius; er = curve_angle == 0 ? 0 : 90 * (1 - sign(curve_angle)); ttwist = $total_twist==undef? twist: $total_twist + twist; //<<< inserted lines rotate([0, 0, twist + er]) { rotate(-ttwist) //<<< cylinder(r = r, h = h); translate([-off, 0, h]) rotate([90, 0, 0]) rotate_extrude(angle = abs(curve_angle)) translate([off, 0, 0]) rotate(ttwist) //<<< circle(r = r); let($total_twist = ttwist) { //<<< pass the current total down the tree translate([-off, 0, h]) rotate([0, -abs(curve_angle), 0]) translate([off, 0, 0]) rotate([0, 0, er]) children(); } //<<< } } The variable $total_twist adds up the twists of a sequence of curved_pipe.
G
Gadgetmind
Wed, Nov 22, 2017 12:03 PM

On 2017-11-18 02:27, Frank van der Hulst wrote:

Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep
examples

I've used spline libraries and skin () to create various curved handles,
etc. for teapots. I create some control points, which also can specify
size and angle (and distortion) of a circle, use splines to "smooth"
this data, and then create the points to be skinned.

All OpenSCAD code is there and there are urls of the various libraries used.
https://www.thingiverse.com/thing:2590540

That shape you show should be perfectly doable and rendering should be
very fast, particularly if you have a variable for how smooth to make
the splines.

On 2017-11-18 02:27, Frank van der Hulst wrote: > > Look for Parkinbot's sweep in Thingverse or check sweep.scad and sweep > examples I've used spline libraries and skin () to create various curved handles, etc. for teapots. I create some control points, which also can specify size and angle (and distortion) of a circle, use splines to "smooth" this data, and then create the points to be skinned. All OpenSCAD code is there and there are urls of the various libraries used. https://www.thingiverse.com/thing:2590540 That shape you show should be perfectly doable and rendering should be *very* fast, particularly if you have a variable for how smooth to make the splines.