discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Polyhedron()

R
runsun
Tue, Nov 10, 2015 4:49 PM

doug.moen wrote

I think that the underlying topic of discussion is: polyhedron() is
difficult to use. Is there an easier way to convert a collection of
vertices into a 3D object?
......
The raw output from a 3D scanner is a point cloud. There exists software
for converting this point cloud into a polyhedral mesh. I think it would
be
interesting to add a point_cloud() operation to OpenSCAD, for converting a
list of vertices into a manifold 3D object. The algorithm should exist
somewhere as open source. It's probably slower than polyhedron(), but much
easier to use.

The point_cloud() primitive would give us very simple and easy to write
code for generating an ellipsoid. Something like this:

a=30;  b=20;  c=10;    //half-axes of ellipse
Step=10;

point_cloud(
[for (v=[0: Step: 180])
for (u=[0: Step: 360])
P(u,v)
]);

function P(u,v)=[a*cos(u)sin(v),bsin(u)sin(v),ccos(v)];

The underlying approach could be simplified into generating simple shapes.
For example, the ellipsoid shape, if watched closely, is basically the same
as the "chain" object described in my  faces.scad
http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html
tool topologically. So a point_cloud() primitive can be easily coded as
such:

a=30;  b=20;  c=10;    //half-axes of ellipse
Step=10;

function P(u,v)=[ a*cos(u)sin(v)
, b
sin(u)sin(v)
, c
cos(v) ];

module

point_cloud

( pts, shape, nside, nseg ){
polyhedron( points=pts, faces=

faces(shape, nside, nseg)

);
}

pts = [for (v=[Step: Step: 180-Step])
for (u=[Step: Step: 360])
P(u,v)
];

point_cloud(
pts
, shape="chain"
, nside= 360/Step
, nseg= 180/Step-2
);

In fact, this approach is why I made  faces.scad
http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html
in the first place. As seen in the link mentioned, generating a basic form
of polyhedron is a simple matter of generating points and picking a shape.


$  Runsun Pan, PhD

$ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git );

$ tips: hash( 1 , 2 ), sweep , var , lerp , animGif

--
View this message in context: http://forum.openscad.org/Polyhedron-tp14338p14349.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

doug.moen wrote > I think that the underlying topic of discussion is: polyhedron() is > difficult to use. Is there an easier way to convert a collection of > vertices into a 3D object? > ...... > The raw output from a 3D scanner is a point cloud. There exists software > for converting this point cloud into a polyhedral mesh. I think it would > be > interesting to add a point_cloud() operation to OpenSCAD, for converting a > list of vertices into a manifold 3D object. The algorithm should exist > somewhere as open source. It's probably slower than polyhedron(), but much > easier to use. > > The point_cloud() primitive would give us very simple and easy to write > code for generating an ellipsoid. Something like this: > > a=30; b=20; c=10; //half-axes of ellipse > Step=10; > > point_cloud( > [for (v=[0: Step: 180]) > for (u=[0: Step: 360]) > P(u,v) > ]); > > function P(u,v)=[a*cos(u)*sin(v),b*sin(u)*sin(v),c*cos(v)]; The underlying approach could be simplified into generating simple shapes. For example, the ellipsoid shape, if watched closely, is basically the same as the "chain" object described in my faces.scad <http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html> tool topologically. So a *point_cloud()* primitive can be easily coded as such: > a=30; b=20; c=10; //half-axes of ellipse > Step=10; > > function P(u,v)=[ a*cos(u)*sin(v) > , b*sin(u)*sin(v) > , c*cos(v) ]; > > module * > point_cloud * > ( pts, shape, nside, nseg ){ > polyhedron( points=pts, faces= * > faces(shape, nside, nseg) * > ); > } > > pts = [for (v=[Step: Step: 180-Step]) > for (u=[Step: Step: 360]) > P(u,v) > ]; > > point_cloud( > pts > , shape="chain" > , nside= 360/Step > , nseg= 180/Step-2 > ); In fact, this approach is why I made faces.scad <http://forum.openscad.org/A-faces-function-for-simple-polyhedrons-td12809.html> in the first place. As seen in the link mentioned, generating a basic form of polyhedron is a simple matter of generating points and picking a shape. ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var , lerp , animGif -- View this message in context: http://forum.openscad.org/Polyhedron-tp14338p14349.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Tue, Nov 10, 2015 6:15 PM

On Nov 10, 2015, at 10:33 AM, doug moen doug@moens.org wrote:

Peter Falke has suggested the idea of feeding a collection of points to hull().

This would be as simple as adding an optional ‘points’ parameter to hull; i.e. pass points=[…] instead of children will just hull the points. I’m uncertain if this should perhaps be a separate module, to avoid mixing group nodes and leaf nodes.

I think it would be interesting to add a point_cloud() operation to OpenSCAD, for converting a list of vertices into a manifold 3D object. The algorithm should exist somewhere as open source.

This would be cool. One challenge could be that the output of such an operation is depending on which algorithm was used, which would potentially lock us into one particular library or implementation where people start to depend on specific artifacts (similar to how people are using cylinder($fn=6) to create prisms).

-Marius

> On Nov 10, 2015, at 10:33 AM, doug moen <doug@moens.org> wrote: > > Peter Falke has suggested the idea of feeding a collection of points to hull(). This would be as simple as adding an optional ‘points’ parameter to hull; i.e. pass points=[…] instead of children will just hull the points. I’m uncertain if this should perhaps be a separate module, to avoid mixing group nodes and leaf nodes. > I think it would be interesting to add a point_cloud() operation to OpenSCAD, for converting a list of vertices into a manifold 3D object. The algorithm should exist somewhere as open source. This would be cool. One challenge could be that the output of such an operation is depending on which algorithm was used, which would potentially lock us into one particular library or implementation where people start to depend on specific artifacts (similar to how people are using cylinder($fn=6) to create prisms). -Marius
MK
Marius Kintel
Tue, Nov 10, 2015 6:17 PM

On Nov 10, 2015, at 10:33 AM, doug moen doug@moens.org wrote:

I think that the underlying topic of discussion is: polyhedron() is difficult to use. Is there an easier way to convert a collection of vertices into a 3D object?

Another potential operator: skin
-> create and orient a bunch of 2D polygons in 3D space and create a skin around the result.

This is already possible in user-space, but requires building 2D shapes manually:
https://github.com/openscad/list-comprehension-demos#extrusionscad

-Marius

> On Nov 10, 2015, at 10:33 AM, doug moen <doug@moens.org> wrote: > > I think that the underlying topic of discussion is: polyhedron() is difficult to use. Is there an easier way to convert a collection of vertices into a 3D object? Another potential operator: skin -> create and orient a bunch of 2D polygons in 3D space and create a skin around the result. This is already possible in user-space, but requires building 2D shapes manually: https://github.com/openscad/list-comprehension-demos#extrusionscad -Marius
TP
Torsten Paul
Tue, Nov 10, 2015 6:24 PM

On 11/10/2015 04:33 PM, doug moen wrote:

Peter Falke has suggested the idea of feeding a collection of points to hull().

See also there: https://github.com/openscad/openscad/pull/1168

I guess that would really be a simple way to quickly create some type
of models. The restriction to convex models does restrict the general
usage though.

Unfortunately the generalized extrusion topic did not advance a lot
lately. This would also bring a very powerful tool that is much easier
to use than directly generating polyhedrons.

The raw output from a 3D scanner is a point cloud. There exists software for
converting this point cloud into a polyhedral mesh. I think it would be
interesting to add a point_cloud() operation to OpenSCAD, for converting a
list of vertices into a manifold 3D object. The algorithm should exist
somewhere as open source. It's probably slower than polyhedron(), but much
easier to use.

CGAL supports that, see http://doc.cgal.org/latest/Surface_reconstruction_points_3

I guess the concern here is how much geometry is generated, similar to the
issues with surface() that were discussed some days ago.

Still it would probably be a nice addition to the tool set.

ciao,
Torsten.

On 11/10/2015 04:33 PM, doug moen wrote: > Peter Falke has suggested the idea of feeding a collection of points to hull(). > See also there: https://github.com/openscad/openscad/pull/1168 I guess that would really be a simple way to quickly create some type of models. The restriction to convex models does restrict the general usage though. Unfortunately the generalized extrusion topic did not advance a lot lately. This would also bring a very powerful tool that is much easier to use than directly generating polyhedrons. > The raw output from a 3D scanner is a point cloud. There exists software for > converting this point cloud into a polyhedral mesh. I think it would be > interesting to add a point_cloud() operation to OpenSCAD, for converting a > list of vertices into a manifold 3D object. The algorithm should exist > somewhere as open source. It's probably slower than polyhedron(), but much > easier to use. > CGAL supports that, see http://doc.cgal.org/latest/Surface_reconstruction_points_3 I guess the concern here is how much geometry is generated, similar to the issues with surface() that were discussed some days ago. Still it would probably be a nice addition to the tool set. ciao, Torsten.
MK
Marius Kintel
Tue, Nov 10, 2015 6:44 PM

On Nov 10, 2015, at 13:24 PM, Torsten Paul Torsten.Paul@gmx.de wrote:

On 11/10/2015 04:33 PM, doug moen wrote:

Peter Falke has suggested the idea of feeding a collection of points to hull().

Ah, right. The old CGAL dependency issue.
I’m thinking we should stop looking at CGAL as a library, but as a collection of tools, write wrappers for each of these tools separately, and keep the library dependency decoupled from any interfaces.

-Marius

> On Nov 10, 2015, at 13:24 PM, Torsten Paul <Torsten.Paul@gmx.de> wrote: > > On 11/10/2015 04:33 PM, doug moen wrote: >> Peter Falke has suggested the idea of feeding a collection of points to hull(). >> > See also there: https://github.com/openscad/openscad/pull/1168 > Ah, right. The old CGAL dependency issue. I’m thinking we should stop looking at CGAL as a library, but as a collection of tools, write wrappers for each of these tools separately, and keep the library dependency decoupled from any interfaces. -Marius
C
ctchin
Thu, Nov 12, 2015 4:12 AM

(I'm re-posting this, due to a tech issue, hope I'm not annoying anyone)

kintel wrote

This would be cool. One challenge could be that the output of such an
operation is depending on which algorithm was used, which would
potentially lock us into one particular library or implementation where
people start to depend on specific artifacts (similar to how people are
using cylinder($fn=6) to create prisms).

Actually... upon looking into Wikipedia, the convex hull of a point cloud is
well-defined and not implementation/algorithm dependent.  Someone might
decide to write, say, Chan's algorithm
(https://en.wikipedia.org/wiki/Chan%27s_algorithm) into a OpenSCAD library,
with calling convention as doug suggested.

On the other hand, the non-convex solid defined by a point cloud is
ill-posed.

doug.moen wrote

this technique is not general, since it can't be used to
construct a non-convex object.

Consider the simple case of 9 points:

Which are the 8 vertices of a cube plus its center point.  A polyhedron with
all these vertices can be
a cube minus a pyramid but which way should the concave side face?  There
problem is ill-posed.

I have my imperfect solution to using polyhedron() to generate highly
complex solids, I understand
the desire to make it easier to use (thanks to doug's post for
summarizing/clarifying the topic)
but someone need to come up with a rigourously posed question before someone
else could come up with a general solution.

--
View this message in context: http://forum.openscad.org/Polyhedron-tp14338p14387.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

(I'm re-posting this, due to a tech issue, hope I'm not annoying anyone) kintel wrote > This would be cool. One challenge could be that the output of such an > operation is depending on which algorithm was used, which would > potentially lock us into one particular library or implementation where > people start to depend on specific artifacts (similar to how people are > using cylinder($fn=6) to create prisms). Actually... upon looking into Wikipedia, the convex hull of a point cloud is well-defined and not implementation/algorithm dependent. Someone might decide to write, say, Chan's algorithm (https://en.wikipedia.org/wiki/Chan%27s_algorithm) into a OpenSCAD library, with calling convention as doug suggested. On the other hand, the non-convex solid defined by a point cloud is ill-posed. doug.moen wrote > this technique is not general, since it can't be used to > construct a non-convex object. Consider the simple case of 9 points: Which are the 8 vertices of a cube plus its center point. A polyhedron with all these vertices can be a cube minus a pyramid but which way should the concave side face? There problem is ill-posed. I have my imperfect solution to using polyhedron() to generate highly complex solids, I understand the desire to make it easier to use (thanks to doug's post for summarizing/clarifying the topic) but someone need to come up with a rigourously posed question before someone else could come up with a general solution. -- View this message in context: http://forum.openscad.org/Polyhedron-tp14338p14387.html Sent from the OpenSCAD mailing list archive at Nabble.com.