Hello,
Generating a polyhedron from two polygons is not too difficult when the
polygon has a limited number of vertices. However I have a polygon with
several tens in order to represent curves correctly.
Now my idea is to generate a second polygon from the original one, in a
plane parallel to the first one, scale and translate it a little bit and
then generate a polyhedron from the original and the new polygon.
As I want to achieve this repeatedly and possibly with different polygons,
do you think it would be possible to create a short algorithm to generate a
suitable path whatever the number of vertices? Which data
structures/strategies would you use then?
Thank you in advance.
--
Sent from: http://forum.openscad.org/
I have code which does this, it basically generates a lot of triangles. In
my code I do everything with 3d points, and then do a step at the end which
first turns the all of the points into a list of unique vertices, and them
converts the list of triangles into references to the vertices
On Wed, 17 Jun 2020, 16:13 amundsen, roald.baudoux@brutele.be wrote:
Hello,
Generating a polyhedron from two polygons is not too difficult when the
polygon has a limited number of vertices. However I have a polygon with
several tens in order to represent curves correctly.
Now my idea is to generate a second polygon from the original one, in a
plane parallel to the first one, scale and translate it a little bit and
then generate a polyhedron from the original and the new polygon.
As I want to achieve this repeatedly and possibly with different polygons,
do you think it would be possible to create a short algorithm to generate a
suitable path whatever the number of vertices? Which data
structures/strategies would you use then?
Thank you in advance.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Was it difficulte to code such an algorithm? Any advice?
--
Sent from: http://forum.openscad.org/
This sort of thing has been done many times by many people.
There is a library called list-comprehension-demos that is perhaps one of
the first to do it and it displays a method for doing it. And dotSCAD also
has code for this. https://github.com/JustinSDK/dotSCAD
In BOSL2 (a library which is still in development):
https://github.com/revarbat/BOSL2/wiki/skin.scad
you can see code that does this, and the wiki shows examples of the results.
If you understand how to use list comprehensions then it is not difficult to
construct a polyhedron by connecting two polygons with the same number of
vertices, located anywhere in 3-space, though if you generate
self-intersecting sides the resulting polyhedron will be invalid. You
simply have to construct the list of vertices and then write a list
comprehension that assembles the appropriate face list.
I wrote a skin() routine to connect a sequence of polygons with different
numbers of vertices using three different methods. The most sophisticated
is a quadratic programming method to find a minimum edge length vertex
alignment for creating triangular faces between the two polygons. I would
say that was a fairly tricky business.
The sweep() operation of taking a given fixed shape and applying
transformations is straight forward if you specify the transformations
completely but tricky when you try to sweep along a path, because a path
doesn't provide enough information to fully define the transformations for
each polygon.
--
Sent from: http://forum.openscad.org/
this one is mine. The tricky part, which I just ignored for this
example, is the starting and ending face. As long as they are
reasonable, flat polyhedrons, this should work, although my actual
code triangularises them (a more annoying problem)
On Wed, Jun 17, 2020 at 5:36 PM amundsen roald.baudoux@brutele.be wrote:
Was it difficulte to code such an algorithm? Any advice?
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
of course, I should have expected an error in the part of the code I
don't actually use...
The only change in this is to reverse the last polygon, as the end cap
needs to be flipped
On Wed, Jun 17, 2020 at 6:37 PM A. Craig West acraigwest@gmail.com wrote:
this one is mine. The tricky part, which I just ignored for this
example, is the starting and ending face. As long as they are
reasonable, flat polyhedrons, this should work, although my actual
code triangularises them (a more annoying problem)
On Wed, Jun 17, 2020 at 5:36 PM amundsen roald.baudoux@brutele.be wrote:
Was it difficulte to code such an algorithm? Any advice?
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thank you @acwest and @adrianv! I'll have a look to all of this.
--
Sent from: http://forum.openscad.org/
I'm not entirely clear on what you want to do, but could a hull() work?
--
Sent from: http://forum.openscad.org/
So far I've got the best results with BOSL's convex_hull (see example below).
BOSL2's skin would be perfect for that purpose but I couldn't even run the
first example without error messages. Is BOSL2 too early in its development
or is it me?
The basic hull won't do it for sure.
use <BOSL/convex_hull.scad>
steps = 100;
height = 10;
startshape = [for(i=[0:steps]) [cos(i/steps * 360) * 2 + 3, sin(i/steps *
360) * 4 + 7, 0]];
endshape = [for(i=[0:steps]) [cos(i/steps * 360) * 10 - 15, sin(i/steps *
360) * 5 - 12, height]];
allpoints = concat(startshape, endshape);
polyhedron(points = allpoints, faces = convex_hull3d(allpoints));
--
Sent from: http://forum.openscad.org/
I managed to use BOSL2's skin function. The examples were lacking the
required use<> code.
So, here's a basic example of what I want to do.
use <BOSL2/skin.scad>
use <BOSL2/rounding.scad>
$fn=32;
polygon_steps = 100;
random_range = 1;
startshape = [for(i=[0:polygon_steps]) [cos(i/polygon_steps * 360) * 2 + 3,
sin(i/polygon_steps * 360) * 4 + 7]];
endshape = [for(i=[0:polygon_steps]) [cos(i/polygon_steps * 360) * 10 - 15 +
rands(-random_range, random_range,1)[0], sin(i/polygon_steps * 360) * 5 - 12
skin([startshape, endshape], z=[0,10], slices=10);
--
Sent from: http://forum.openscad.org/