I know that we can sweep a polygon around a circle like this, making a 3D
object. :
rotate_extrude($fn=100) polygon(points = MyPts);
Recently, however, I wanted to construct a cover for a lathe that had
curved sides, but when viewed face-on had an irregular shape. It's shaped
like a triangle with curved corners. It would have been very nice to
create a polygon for the side contour and then been able to sweep it around
my custom shape.
Can OpenSCAD do this? If not, would it be a complex feature to add?
Thanks in advance,
Kevin T
kdtop wrote
...
Recently, however, I wanted to construct a cover for a lathe that had
curved sides, but when viewed face-on had an irregular shape. It's shaped
like a triangle with curved corners. It would have been very nice to
create a polygon for the side contour and then been able to sweep it
around
my custom shape.
Can OpenSCAD do this? If not, would it be a complex feature to add?
Thanks in advance,
Kevin T
OpenSCAD mailing list
Discuss@.openscad
I'm not visualising it well, a picture is worth a thousand lines of code...
I suspect sweep() would be suited, can someone point to the latest sweep()
I'm out of date on the topic.
Admin - email* me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
Sent from: http://forum.openscad.org/
please use the forum search for questions like this. sweep and minkowski are
your search items.
--
Sent from: http://forum.openscad.org/
Thanks for the replies.
Here is a link to the object I ultimately created -- though I would like a
better way of having done it: https://www.thingiverse.com/thing:3246547
[image: Screen Shot 2018-12-01 at 9.17.02 AM.png]
Here is a picture that shows the shape with the side pieces spaced out.
[image: Screen Shot 2018-12-01 at 8.48.25 AM.png]
To make my 3D shape, I simply put many many more of these side pieces
together so that there were no gaps. The problem is that each side piece
is a 3D object with a flat back and a given width. So the side walls ended
up with jags. And it is ultimately an inefficient way of doing this. (a
CGAL render takes 1-2 HOURS!) The sides really should be a 2D object that
is then swept around a path defining the outer curves.
I don't think minkowski() would have any application in this situation.
And a hull() would make a solid object, not concave like I want.
Apparently someone has made a sweep() function, which I didn't realize. I
searched the forums as recommended and found this discussion about sweep():
http://forum.openscad.org/Two-annoyances-tt12935.html#a13514
It appears that the sweep() is part of a library rather than an intrinsic
function of OpenSCAD. Is this correct ? If so, then which is the best or
recommended library to use?
I found these links.
https://github.com/openscad/list-comprehension-demos/blob/master/sweep-test.scad
Questions:
use <sweep.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
Is the \scad-utils\ folder a standard thing with anOpenSCAD install? I.e.
can I use this directly? I.e. is there a way in OpenSCAD to set up a
search path for library folders? So far I have been putting a copy of any
library used into the folder containing my current project. Thus I have
many copies scattered across my various projects. I am on mac OSX. I
went to the application folder, right-clicked on OpenSCAD, chose "show
package content" and from there found a folder
.\Content\Resources\libraries\MCAD. This contains many files that would
seem to be helpful libraries. How is one supposed to use these? Copy them
to a working folder? Figure out the long complex path and link to that
directly?
Thanks in advance,
Kevin
On Sat, Dec 1, 2018 at 6:35 AM Parkinbot rudolf@digitaldocument.de wrote:
please use the forum search for questions like this. sweep and minkowski
are
your search items.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Kevin,
Sweep is not a built-in OpenScad operator neither it is included as a
standard library. AFIK, there is two main sweep libraries around there: one
was written by Oskar Linde and is part of the list comprehension demos you
have found, the other was created by Parkinbot. Linde's sweep is a module
that receives a planar 2D section and a sequence of affine transformations.
The transformations are applied to each section to position them in the 3D
space and the set of such sections is wraped in a OpenScad polyhedron. No
boolean operation is used so the process is relatively fast. An utility
function - paths_transforms - can be used to compute the sequence (list,
array) of transformations from a sweep path. The affine transforms
generated by that function are restricted to rigid body transforms. To help
several tasks, Linde has written a bunch of general use libraries under the
name scad-utils that can be found at:
https://github.com/OskarLinde/scad-utils
A copy of that set of libraries should be in an appropriate location in
order to be found by <use> or <include>.
Parkinbot's sweep on the other hand expects as input a sequence of 3D
planar polygons already positioned in the space and, as Linde's sweep does,
wrap it in a polyhedron. No utility function is included in Parkinbot's
sweep library to generate the 3D planar polygon. However, Parkinbot's
approach is more general than Linde's one as it allows that each 3D planar
polygon has it own shape provided that all polygons have the same number of
vertices.
The contribution you have found in my Github repository is deeply based on
Linde's approach and restricted to: commenting the code, cleaning some
functions and adopting a different way to compute the path transforms that
avoids some wild twist the original strategy may produce. That new
computation is based on a Linde's proposal published in this forum that
have never been included in the list comprehension demo repository. My
codes also requires functions of scad-utils.
None of those sweeps can be used blindly. The OpenScad render geometric
engine - CGAL - will complaint if the resulting polyhedron has
self-intersections. It is the user responsibility to avoid them.
Ronaldo Persiano
Em sáb, 1 de dez de 2018 às 14:34, Kevin Toppenberg kdtop3@gmail.com
escreveu:
Thanks for the replies.
Here is a link to the object I ultimately created -- though I would like a
better way of having done it: https://www.thingiverse.com/thing:3246547
[image: Screen Shot 2018-12-01 at 9.17.02 AM.png]
Here is a picture that shows the shape with the side pieces spaced out.
[image: Screen Shot 2018-12-01 at 8.48.25 AM.png]
To make my 3D shape, I simply put many many more of these side pieces
together so that there were no gaps. The problem is that each side piece
is a 3D object with a flat back and a given width. So the side walls ended
up with jags. And it is ultimately an inefficient way of doing this. (a
CGAL render takes 1-2 HOURS!) The sides really should be a 2D object that
is then swept around a path defining the outer curves.
I don't think minkowski() would have any application in this situation.
And a hull() would make a solid object, not concave like I want.
Apparently someone has made a sweep() function, which I didn't realize. I
searched the forums as recommended and found this discussion about sweep():
http://forum.openscad.org/Two-annoyances-tt12935.html#a13514
It appears that the sweep() is part of a library rather than an intrinsic
function of OpenSCAD. Is this correct ? If so, then which is the best or
recommended library to use?
I found these links.
- here someone says they improved sweep:
http://forum.openscad.org/more-sweep-issues-tt22926.html#a22927
-
https://github.com/openscad/list-comprehension-demos/blob/master/sweep-test.scad
- And here is another version of sweep:
https://github.com/RonaldoCMP/list-comprehension-demos
Questions:
use <sweep.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
Is the \scad-utils\ folder a standard thing with anOpenSCAD install? I.e.
can I use this directly? I.e. is there a way in OpenSCAD to set up a
search path for library folders? So far I have been putting a copy of any
library used into the folder containing my current project. Thus I have
many copies scattered across my various projects. I am on mac OSX. I
went to the application folder, right-clicked on OpenSCAD, chose "show
package content" and from there found a folder
.\Content\Resources\libraries\MCAD. This contains many files that would
seem to be helpful libraries. How is one supposed to use these? Copy them
to a working folder? Figure out the long complex path and link to that
directly?
Thanks in advance,
Kevin
On Sat, Dec 1, 2018 at 6:35 AM Parkinbot rudolf@digitaldocument.de
wrote:
please use the forum search for questions like this. sweep and minkowski
are
your search items.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
this is not the fastest code, but it does what you se3m want
difference()
{
triag(10, 9);
triag(9, 10);
}
module triag(r = 10, h)
hull()
{
forN(50, 3) sphere(r);
forN(50, 3) cylinder(r=r, h=h);
}
module forN(r, n)
for(i=[0:n-1]) rotate([0,0,360/n*i]) translate([r, 0, 0]) children();
--
Sent from: http://forum.openscad.org/
Ronaldo,
Thank you for this helpful information. I will work on this and see if I
can get it going.
Thanks again
Kevin
On Sat, Dec 1, 2018 at 12:21 PM Ronaldo Persiano rcmpersiano@gmail.com
wrote:
Kevin,
Sweep is not a built-in OpenScad operator neither it is included as a
standard library. AFIK, there is two main sweep libraries around there: one
was written by Oskar Linde and is part of the list comprehension demos you
have found, the other was created by Parkinbot. Linde's sweep is a module
that receives a planar 2D section and a sequence of affine transformations.
The transformations are applied to each section to position them in the 3D
space and the set of such sections is wraped in a OpenScad polyhedron. No
boolean operation is used so the process is relatively fast. An utility
function - paths_transforms - can be used to compute the sequence (list,
array) of transformations from a sweep path. The affine transforms
generated by that function are restricted to rigid body transforms. To help
several tasks, Linde has written a bunch of general use libraries under the
name scad-utils that can be found at:
https://github.com/OskarLinde/scad-utils
A copy of that set of libraries should be in an appropriate location in
order to be found by <use> or <include>.
Parkinbot's sweep on the other hand expects as input a sequence of 3D
planar polygons already positioned in the space and, as Linde's sweep does,
wrap it in a polyhedron. No utility function is included in Parkinbot's
sweep library to generate the 3D planar polygon. However, Parkinbot's
approach is more general than Linde's one as it allows that each 3D planar
polygon has it own shape provided that all polygons have the same number of
vertices.
The contribution you have found in my Github repository is deeply based on
Linde's approach and restricted to: commenting the code, cleaning some
functions and adopting a different way to compute the path transforms that
avoids some wild twist the original strategy may produce. That new
computation is based on a Linde's proposal published in this forum that
have never been included in the list comprehension demo repository. My
codes also requires functions of scad-utils.
None of those sweeps can be used blindly. The OpenScad render geometric
engine - CGAL - will complaint if the resulting polyhedron has
self-intersections. It is the user responsibility to avoid them.
Ronaldo Persiano
Em sáb, 1 de dez de 2018 às 14:34, Kevin Toppenberg kdtop3@gmail.com
escreveu:
Thanks for the replies.
Here is a link to the object I ultimately created -- though I would like
a better way of having done it:
https://www.thingiverse.com/thing:3246547
[image: Screen Shot 2018-12-01 at 9.17.02 AM.png]
Here is a picture that shows the shape with the side pieces spaced out.
[image: Screen Shot 2018-12-01 at 8.48.25 AM.png]
To make my 3D shape, I simply put many many more of these side pieces
together so that there were no gaps. The problem is that each side piece
is a 3D object with a flat back and a given width. So the side walls ended
up with jags. And it is ultimately an inefficient way of doing this. (a
CGAL render takes 1-2 HOURS!) The sides really should be a 2D object that
is then swept around a path defining the outer curves.
I don't think minkowski() would have any application in this situation.
And a hull() would make a solid object, not concave like I want.
Apparently someone has made a sweep() function, which I didn't realize.
I searched the forums as recommended and found this discussion about
sweep(): http://forum.openscad.org/Two-annoyances-tt12935.html#a13514
It appears that the sweep() is part of a library rather than an intrinsic
function of OpenSCAD. Is this correct ? If so, then which is the best or
recommended library to use?
I found these links.
- here someone says they improved sweep:
http://forum.openscad.org/more-sweep-issues-tt22926.html#a22927
-
https://github.com/openscad/list-comprehension-demos/blob/master/sweep-test.scad
- And here is another version of sweep:
https://github.com/RonaldoCMP/list-comprehension-demos
Questions:
use <sweep.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
Is the \scad-utils\ folder a standard thing with anOpenSCAD install?
I.e. can I use this directly? I.e. is there a way in OpenSCAD to set up a
search path for library folders? So far I have been putting a copy of any
library used into the folder containing my current project. Thus I have
many copies scattered across my various projects. I am on mac OSX. I
went to the application folder, right-clicked on OpenSCAD, chose "show
package content" and from there found a folder
.\Content\Resources\libraries\MCAD. This contains many files that would
seem to be helpful libraries. How is one supposed to use these? Copy them
to a working folder? Figure out the long complex path and link to that
directly?
Thanks in advance,
Kevin
On Sat, Dec 1, 2018 at 6:35 AM Parkinbot rudolf@digitaldocument.de
wrote:
please use the forum search for questions like this. sweep and minkowski
are
your search items.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
And if want different radii, you can use minkowski over a hull of cylinders
or alternatively hull over three tori for the lower part.
http://forum.openscad.org/file/t887/pool.png
$fn = 50;
difference()
{
triag(r=30, rm=10, R=50, h=19);
triag(r=29, rm=8, R=50, h=30);
}
module triag(r = 10, R = 50, rm = 3, h)
{
hull()
{
minkowski()
{
hull()
forN(R, 3) cylinder(r=r, 1);
sphere(rm);
}
forN(50, 3) cylinder(r=r+rm, h=h);
}
}
module forN(r, n)
for(i=[0:n-1]) rotate([0,0,360/n*i]) translate([r, 0, 0]) children();
--
Sent from: http://forum.openscad.org/
Parkinbot,
You solved my problem without the need for sweep(). I hadn't thought about
subtracting 2 hull()'s. While I still want to learn how to use the sweep
library (for other situations), I like your solution. I had in my mind
that hull() was a computationally expensive function. But your code
finished a CGAL (F6) render in about 10 seconds. So clearly it is better
than my prior method.
In my model, one of the sides bulged out, but I could solve that by putting
some more posts in there before calling the hull().
Thanks again,
Kevin
On Sat, Dec 1, 2018 at 3:04 PM Parkinbot rudolf@digitaldocument.de wrote:
And if want different radii, you can use minkowski over a hull of cylinders
or alternatively hull over three tori for the lower part.
http://forum.openscad.org/file/t887/pool.png
$fn = 50;
difference()
{
triag(r=30, rm=10, R=50, h=19);
triag(r=29, rm=8, R=50, h=30);
}
module triag(r = 10, R = 50, rm = 3, h)
{
hull()
{
minkowski()
{
hull()
forN(R, 3) cylinder(r=r, 1);
sphere(rm);
}
forN(50, 3) cylinder(r=r+rm, h=h);
}
}
module forN(r, n)
for(i=[0:n-1]) rotate([0,0,360/n*i]) translate([r, 0, 0]) children();
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Your problem appears to be solved, but for what it's worth, I wrote a 'loft'
function a while ago that sweeps the interpolation between two
two-dimensional profiles along a three-dimensional path. It is very similar
to the other 'sweep' libraries mentioned (except mine is poorly documented
and the code probably unreadable, sorry ;-)). The transformations along the
path are computed using quaternions and the usual restrictions apply
(profiles have to be singly-connected and have the same number of points in
them, no self-intersections).
Maybe it is useful to somebody...
Marko
function flatten(vec) = [for (v=vec) for(e=v) e];
function Q_im(q) = [q[1], q[2], q[3]];
function Q_conj(q) = [q[0], -q[1], -q[2], -q[3]];
function Q_mult(q,p) =
[(q[0]*p[0]-q[1]*p[1]-q[2]*p[2]-q[3]*p[3]),(q[1]*p[0]+q[0]*p[1]+q[2]*p[3]-q[3]*p[2]),(q[2]*p[0]+q[0]*p[2]-q[1]*p[3]+q[3]*p[1]),(q[3]*p[0]+q[0]*p[3]+q[1]*p[2]-q[2]p[1])];
function rotQ(q, a, n) = Q_mult(flatten([cos(a/2),nsin(a/2)]),q);
function poly_rotQ(list, q) = [for (v=list)
Q_im(Q_mult(q,Q_mult([0,v.x,v.y,v.z],Q_conj(q))))];
function poly_rot2d(list, a) = [for (x=list) [cos(a)*x[0]+sin(a)*x[1],
-sin(a)x[0]+cos(a)x[1]]];
function poly_translate(list, d) = [for (v=list) v+d];
function interp_lists(l1, w1, l2, w2) = [for (i=[0:len(l1)-1])
w1l1[i]+w2l2[i]];
function poly_loft_faces (N_z, N_x, closed=false) = flatten([
(closed ? ([for (i=[0:N_x-1]) [(N_z-1)*N_x+i, (N_z-1)*N_x+(i+1)%N_x,
i],
for (i=[0:N_x-1]) [(i+1)%N_x, i, (N_z-1)N_x+(i+1)%N_x]])
: concat([[for (i=[0:N_x-1]) N_x-1-i]], [[for (i=[0:N_x-1])
(N_z-1)N_x+i]])), // caps
for (i=[0:N_z-2],j=[0:N_x-1]) [[(i+1)N_x+j, iN_x+j,
iN_x+((j+1)%N_x)],[iN_x+((j+1)%N_x), (i+1)*N_x+((j+1)%N_x),
(i+1)*N_x+j]]]);
// extrude a cross section linearly interpolated between cross sections cr1
and cr2 along path 'path',
// with optional tangential twist linearly increasing along path
module loft (path, cr1, cr2, twist=0) {
p = flatten([path, [2path[len(path)-1]-path[len(path)-2]]]);
pts = flatten([
for (i=1, d=p[1]-p[0], u=cross([0,0,1], d), un=norm(u), dn=norm(d),
a=asin(un/dn),
q=un>0?rotQ([1,0,0,0],a,u/un) : [1,0,0,0], n=d/dn, cr=cr1;
i<len(p);
d=p[i]-path[i-1], u=cross(n, d), un=norm(u), dn=norm(d),
a=asin(un/dn),
n=d/dn,q=un>0?rotQ(q,a,u/un):q,
cr=interp_lists(cr1,1-(i-1)/(len(p)-1),cr2,(i-1)/(len(p)-1)), i=i+1)
poly_translate(poly_rotQ(twist!=0?[for(v=poly_rot2d([for (v=cr)
[v.x,v.y,0]],itwist/(len(p)-1))) [v.x,v.y,0]]:[for (v=cr) [v.x,v.y,0]], q),
p[i-1])
]);
fcs = poly_loft_faces(len(path), len(cr1));
polyhedron(pts, fcs, convexity=8);
}
pH = [[-1, 1], [-0.8,1], [-0.8, 0.1], [0.8, 0.1], [0.8, 1], [1, 1],
[1, -1], [0.8, -1], [0.8, -0.1], [-0.8, -0.1], [-0.8, -1], [-1, -1]];
pH2 = [for (v=pH) 2v];
phelix = [for (i=[0:6:3360]) 5*[cos(i), sin(i), i/360]];
loft(phelix, pH, pH2, -170);
--
Sent from: http://forum.openscad.org/