discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] making vases, perhaps with InkScape

RP
Ronaldo Persiano
Sat, Feb 17, 2018 9:03 PM

2018-02-16 12:21 GMT-02:00 jon jon@jonbondy.com:

What would be helpful to me (and perhaps to others?) is a facility
something like this:

I define a list of 2D (or 3D?) points of arbitrary length (like pts = [[1,
2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]];)

I call a function (F()) passing in the points and a number between 0 and

  1. It is important that the points are passed in: if the points are
    referenced as a global, I can only do this once in a program.  Or I would
    have to create multiple copies of the code with minor variations in
    variable names.

The function (F()) returns a point somewhere along the curve.  So, if I
call F(0) I get [1, 2]; if I call F(1) I get [11, 12]; and if I call F(0.5)
I get the point between [5, 6] and [7, 8] (where "between" takes into
account the curve smoothing).  The curve smoothing algorithm could be
Bezier, but I suppose that it could be something else (polynomial
regression).

What you seem to want is some kind of interpolation.

​I don't believe that polynomial regression or higher degree Bezier curves
are the best way to go.  ​There is many interpolation schemes but, unless
you need a smooth curve (with continuous curvature), a Hermite
interpolation might be satisfactory. It will give you tangent continuity.
In the following, I will give you a specific way to do it based on the
subdivBezier3() function I mentioned before [1].

Given a list of points p to be interpolated, the following function
computes a list of points in a Hermite interpolation curve of those points:

function IntepolHerm(p, n=4) =
let( tgts = [ (p[1]-p[0])/3 ,
each [for(i=[1:len(p)-2]) p[i+1]-p[i-1] ]/6,
(p[len(p)-1]-p[len(p)-2])/3 ])
subdivBezier3([for(i=[0:len(p)-2]) each [ p[i], p[i]+tgts[i],
p[i+1]-tgts[i+1]], p[len(p)-1] ]);

The number of generated points by InterpHerm() depends exponentially on n
so keep it low: 3 or 4 should be enough.

An adequate parametrization of that curve in the interval [0,1] is the
following:

function F(t,pc) =
let( k = floor((len(pc)-1)*t),
s = (len(pc)-1)t - k )
k==len(pc)-1 ?
pc[len(pc)-1]
: pc[k]
(1-s) + pc[k+1]*s;

Given any t in the interval [0,1] and a Hermite interpolation pc computed
by InterpHerm(), the function F() produces a point in the curve such that:

F(0,pc) == pc[0]            and
F(1,pc) == pc[len(pc)-1]

So, typically you should compute
pc = IntepolHerm(p) once and call  F(t,pc) with as many values of t as you
want or need.

Note that with this setting, the input points p of  IntepolHerm(p)  may be
not only 2D or 3D points but may be any uniform list of lists of numbers.
So, you may define p such that:

p[i] = [ [ x[i], y[i], z[i] ], r[i], ang[i] ]; // the same structure for
all i

where [x,y,z] is a 3D point, r is a radius and ang is an angle. The
resulting "point" generated by  F(t,pc)  will have the same structure: a 3D
point, a radius and an angle. This way you can interpolate many different
parameter values in one go.

[1] http://forum.openscad.org/OpenSCAD-programming-question-
recursion-functions-and-modules-tp23197p23217.html

2018-02-16 12:21 GMT-02:00 jon <jon@jonbondy.com>: > What would be helpful to me (and perhaps to others?) is a facility > something like this: > > I define a list of 2D (or 3D?) points of arbitrary length (like pts = [[1, > 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]];) > > I call a function (F()) passing in the points and a number between 0 and > 1. It is important that the points are passed in: if the points are > referenced as a global, I can only do this once in a program. Or I would > have to create multiple copies of the code with minor variations in > variable names. > > The function (F()) returns a point somewhere along the curve. So, if I > call F(0) I get [1, 2]; if I call F(1) I get [11, 12]; and if I call F(0.5) > I get the point between [5, 6] and [7, 8] (where "between" takes into > account the curve smoothing). The curve smoothing algorithm could be > Bezier, but I suppose that it could be something else (polynomial > regression). > What you seem to want is some kind of interpolation. ​ ​I don't believe that polynomial regression or higher degree Bezier curves are the best way to go. ​There is many interpolation schemes but, unless you need a smooth curve (with continuous curvature), a Hermite interpolation might be satisfactory. It will give you tangent continuity. In the following, I will give you a specific way to do it based on the subdivBezier3() function I mentioned before [1]. Given a list of points p to be interpolated, the following function computes a list of points in a Hermite interpolation curve of those points: function IntepolHerm(p, n=4) = let( tgts = [ (p[1]-p[0])/3 , each [for(i=[1:len(p)-2]) p[i+1]-p[i-1] ]/6, (p[len(p)-1]-p[len(p)-2])/3 ]) subdivBezier3([for(i=[0:len(p)-2]) each [ p[i], p[i]+tgts[i], p[i+1]-tgts[i+1]], p[len(p)-1] ]); The number of generated points by InterpHerm() depends exponentially on n so keep it low: 3 or 4 should be enough. An adequate parametrization of that curve in the interval [0,1] is the following: function F(t,pc) = let( k = floor((len(pc)-1)*t), s = (len(pc)-1)*t - k ) k==len(pc)-1 ? pc[len(pc)-1] : pc[k]*(1-s) + pc[k+1]*s; Given any t in the interval [0,1] and a Hermite interpolation pc computed by InterpHerm(), the function F() produces a point in the curve such that: F(0,pc) == pc[0] and F(1,pc) == pc[len(pc)-1] So, typically you should compute pc = IntepolHerm(p) once and call F(t,pc) with as many values of t as you want or need. Note that with this setting, the input points p of IntepolHerm(p) may be not only 2D or 3D points but may be any uniform list of lists of numbers. So, you may define p such that: p[i] = [ [ x[i], y[i], z[i] ], r[i], ang[i] ]; // the same structure for all i where [x,y,z] is a 3D point, r is a radius and ang is an angle. The resulting "point" generated by F(t,pc) will have the same structure: a 3D point, a radius and an angle. This way you can interpolate many different parameter values in one go. [1] http://forum.openscad.org/OpenSCAD-programming-question- recursion-functions-and-modules-tp23197p23217.html
RD
Revar Desmera
Sun, Feb 18, 2018 8:04 AM

If it’s helpful for you, I just tweaked my BOSL library’s bezier.scad to accept N-order beziers by giving an N= argument to the related bezier functions and modules.

Library code:
https://github.com/revarbat/BOSL/

Relevant docs:
https://github.com/revarbat/BOSL/wiki/paths.scad
https://github.com/revarbat/BOSL/wiki/beziers.scad

Some modules still have problems extruding concave paths, though. I’m having troubles getting a good function working to triangulate the end faces. Functional programming is like pulling teeth for this sort of thing. shakes fist impotently Any pointers would be appreciated, if anybody has done this.

  • Revar

On Feb 17, 2018, at 1:03 PM, Ronaldo Persiano rcmpersiano@gmail.com wrote:

2018-02-16 12:21 GMT-02:00 jon jon@jonbondy.com:

What would be helpful to me (and perhaps to others?) is a facility something like this:

I define a list of 2D (or 3D?) points of arbitrary length (like pts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]];)

I call a function (F()) passing in the points and a number between 0 and 1.  It is important that the points are passed in: if the points are referenced as a global, I can only do this once in a program.  Or I would have to create multiple copies of the code with minor variations in variable names.
The function (F()) returns a point somewhere along the curve.  So, if I call F(0) I get [1, 2]; if I call F(1) I get [11, 12]; and if I call F(0.5) I get the point between [5, 6] and [7, 8] (where "between" takes into account the curve smoothing).  The curve smoothing algorithm could be Bezier, but I suppose that it could be something else (polynomial regression).

What you seem to want is some kind of interpolation.​ ​I don't believe that polynomial regression or higher degree Bezier curves are the best way to go.  ​There is many interpolation schemes but, unless you need a smooth curve (with continuous curvature), a Hermite interpolation might be satisfactory. It will give you tangent continuity. In the following, I will give you a specific way to do it based on the subdivBezier3() function I mentioned before [1].

Given a list of points p to be interpolated, the following function computes a list of points in a Hermite interpolation curve of those points:

function IntepolHerm(p, n=4) =
let( tgts = [ (p[1]-p[0])/3 ,
each [for(i=[1:len(p)-2]) p[i+1]-p[i-1] ]/6,
(p[len(p)-1]-p[len(p)-2])/3 ])
subdivBezier3([for(i=[0:len(p)-2]) each [ p[i], p[i]+tgts[i], p[i+1]-tgts[i+1]], p[len(p)-1] ]);

The number of generated points by InterpHerm() depends exponentially on n so keep it low: 3 or 4 should be enough.

An adequate parametrization of that curve in the interval [0,1] is the following:

function F(t,pc) =
let( k = floor((len(pc)-1)*t),
s = (len(pc)-1)t - k )
k==len(pc)-1 ?
pc[len(pc)-1]
: pc[k]
(1-s) + pc[k+1]*s;

Given any t in the interval [0,1] and a Hermite interpolation pc computed by InterpHerm(), the function F() produces a point in the curve such that:

F(0,pc) == pc[0]            and
F(1,pc) == pc[len(pc)-1]

So, typically you should compute pc = IntepolHerm(p) once and call  F(t,pc) with as many values of t as you want or need.

Note that with this setting, the input points p of  IntepolHerm(p)  may be not only 2D or 3D points but may be any uniform list of lists of numbers. So, you may define p such that:

p[i] = [ [ x[i], y[i], z[i] ], r[i], ang[i] ]; // the same structure for all i

where [x,y,z] is a 3D point, r is a radius and ang is an angle. The resulting "point" generated by  F(t,pc)  will have the same structure: a 3D point, a radius and an angle. This way you can interpolate many different parameter values in one go.

[1] http://forum.openscad.org/OpenSCAD-programming-question-recursion-functions-and-modules-tp23197p23217.html


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

If it’s helpful for you, I just tweaked my BOSL library’s bezier.scad to accept N-order beziers by giving an N= argument to the related bezier functions and modules. Library code: https://github.com/revarbat/BOSL/ Relevant docs: https://github.com/revarbat/BOSL/wiki/paths.scad https://github.com/revarbat/BOSL/wiki/beziers.scad Some modules still have problems extruding concave paths, though. I’m having troubles getting a good function working to triangulate the end faces. Functional programming is like pulling teeth for this sort of thing. *shakes fist impotently* Any pointers would be appreciated, if anybody has done this. - Revar > On Feb 17, 2018, at 1:03 PM, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > > 2018-02-16 12:21 GMT-02:00 jon <jon@jonbondy.com>: >> What would be helpful to me (and perhaps to others?) is a facility something like this: >> >> I define a list of 2D (or 3D?) points of arbitrary length (like pts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]];) >> >> I call a function (F()) passing in the points and a number between 0 and 1. It is important that the points are passed in: if the points are referenced as a global, I can only do this once in a program. Or I would have to create multiple copies of the code with minor variations in variable names. >> The function (F()) returns a point somewhere along the curve. So, if I call F(0) I get [1, 2]; if I call F(1) I get [11, 12]; and if I call F(0.5) I get the point between [5, 6] and [7, 8] (where "between" takes into account the curve smoothing). The curve smoothing algorithm could be Bezier, but I suppose that it could be something else (polynomial regression). >> > What you seem to want is some kind of interpolation.​ ​I don't believe that polynomial regression or higher degree Bezier curves are the best way to go. ​There is many interpolation schemes but, unless you need a smooth curve (with continuous curvature), a Hermite interpolation might be satisfactory. It will give you tangent continuity. In the following, I will give you a specific way to do it based on the subdivBezier3() function I mentioned before [1]. > > Given a list of points p to be interpolated, the following function computes a list of points in a Hermite interpolation curve of those points: > > function IntepolHerm(p, n=4) = > let( tgts = [ (p[1]-p[0])/3 , > each [for(i=[1:len(p)-2]) p[i+1]-p[i-1] ]/6, > (p[len(p)-1]-p[len(p)-2])/3 ]) > subdivBezier3([for(i=[0:len(p)-2]) each [ p[i], p[i]+tgts[i], p[i+1]-tgts[i+1]], p[len(p)-1] ]); > > The number of generated points by InterpHerm() depends exponentially on n so keep it low: 3 or 4 should be enough. > > An adequate parametrization of that curve in the interval [0,1] is the following: > > function F(t,pc) = > let( k = floor((len(pc)-1)*t), > s = (len(pc)-1)*t - k ) > k==len(pc)-1 ? > pc[len(pc)-1] > : pc[k]*(1-s) + pc[k+1]*s; > > Given any t in the interval [0,1] and a Hermite interpolation pc computed by InterpHerm(), the function F() produces a point in the curve such that: > > F(0,pc) == pc[0] and > F(1,pc) == pc[len(pc)-1] > > So, typically you should compute pc = IntepolHerm(p) once and call F(t,pc) with as many values of t as you want or need. > > Note that with this setting, the input points p of IntepolHerm(p) may be not only 2D or 3D points but may be any uniform list of lists of numbers. So, you may define p such that: > > p[i] = [ [ x[i], y[i], z[i] ], r[i], ang[i] ]; // the same structure for all i > > where [x,y,z] is a 3D point, r is a radius and ang is an angle. The resulting "point" generated by F(t,pc) will have the same structure: a 3D point, a radius and an angle. This way you can interpolate many different parameter values in one go. > > [1] http://forum.openscad.org/OpenSCAD-programming-question-recursion-functions-and-modules-tp23197p23217.html > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
P
Parkinbot
Sun, Feb 18, 2018 10:37 AM

Ronaldo wrote

What you seem to want is some kind of interpolation.

I don't see how a line-oriented interpolation scheme operating over a
sequence of N-points will result in a vase, unless the N-points are fed into
some generator function, which Jon seemingly wants to avoid.

  1. For the description of a 2-manifold some 2D-interpolation scheme
    operating over a grid, a sequence of polygons or similar is needed.
  2. Further, boundary conditions are of interest whenever a sequence is not
    circular. E.g. to describe the bottom and the top of the vase.
  3. With an interpolation scheme you can only describe smooth surfaces. This
    is not always wanted. Therefore a Bezier-base approach is richer ...

--
Sent from: http://forum.openscad.org/

Ronaldo wrote > What you seem to want is some kind of interpolation. > ​ I don't see how a line-oriented interpolation scheme operating over a sequence of N-points will result in a vase, unless the N-points are fed into some generator function, which Jon seemingly wants to avoid. 1. For the description of a 2-manifold some 2D-interpolation scheme operating over a grid, a sequence of polygons or similar is needed. 2. Further, boundary conditions are of interest whenever a sequence is not circular. E.g. to describe the bottom and the top of the vase. 3. With an interpolation scheme you can only describe smooth surfaces. This is not always wanted. Therefore a Bezier-base approach is richer ... -- Sent from: http://forum.openscad.org/
N
NateTG
Sun, Feb 18, 2018 2:47 PM

Some modules still have problems extruding concave paths, though. I’m

having troubles getting a good function working to triangulate the end
faces.

Detecting self-intersection is a bit of a chore.  Detecting 0-length
segments is easy.  Once you have those two pieces worked out, polyhedron
accepts faces with more than 3 edges now.

--
Sent from: http://forum.openscad.org/

> Some modules still have problems extruding concave paths, though. I’m having troubles getting a good function working to triangulate the end faces. Detecting self-intersection is a bit of a chore. Detecting 0-length segments is easy. Once you have those two pieces worked out, polyhedron accepts faces with more than 3 edges now. -- Sent from: http://forum.openscad.org/
RD
Revar Desmera
Sun, Feb 18, 2018 11:10 PM

Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience.

  • Revar

On Feb 18, 2018, at 6:47 AM, NateTG nate-openscadforum@pedantic.org wrote:

Some modules still have problems extruding concave paths, though. I’m

having troubles getting a good function working to triangulate the end
faces.

Detecting self-intersection is a bit of a chore.  Detecting 0-length
segments is easy.  Once you have those two pieces worked out, polyhedron
accepts faces with more than 3 edges now.

--
Sent from: http://forum.openscad.org/


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

Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience. - Revar On Feb 18, 2018, at 6:47 AM, NateTG <nate-openscadforum@pedantic.org> wrote: >> Some modules still have problems extruding concave paths, though. I’m > having troubles getting a good function working to triangulate the end > faces. > > Detecting self-intersection is a bit of a chore. Detecting 0-length > segments is easy. Once you have those two pieces worked out, polyhedron > accepts faces with more than 3 edges now. > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
MK
Marius Kintel
Mon, Feb 19, 2018 4:36 AM

On Feb 18, 2018, at 6:10 PM, Revar Desmera revarbat@gmail.com wrote:

Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience.

In OpenSCAD, we work around this by first giving CGAL the know good coplanar face, and if it throws an exception, we send it a triangulated version.

-Marius

> On Feb 18, 2018, at 6:10 PM, Revar Desmera <revarbat@gmail.com> wrote: > > Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience. > In OpenSCAD, we work around this by first giving CGAL the know good coplanar face, and if it throws an exception, we send it a triangulated version. -Marius
N
NateTG
Mon, Feb 19, 2018 10:15 AM

RevarBat wrote

Sadly, CGAL will barf frequently even with known good coplanar face
points. CGAL is only really reliable with triangles, in my experience.

  • Revar
    ...

FWIW I did write a face triangulator:

triangulate.scad http://forum.openscad.org/file/t2140/triangulate.scad

It's not particularly clever or efficient, but it should work.

--
Sent from: http://forum.openscad.org/

RevarBat wrote > Sadly, CGAL will barf frequently even with known good coplanar face > points. CGAL is only really reliable with triangles, in my experience. > > - Revar > ... FWIW I did write a face triangulator: triangulate.scad <http://forum.openscad.org/file/t2140/triangulate.scad> It's not particularly clever or efficient, but it should work. -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Mon, Feb 19, 2018 3:45 PM

It seems that your ear clipping method doesn't work properly in some cases:

face = [[20, 0], [15.5279, 8.96503], [10, 17.3205], [0, 8.85357], [-10,
17.3205], [-31.0929, 17.9515], [-20, 0], [-33.2343, -19.1878], [-10,
-17.3205], [0, -14.4569], [10, -17.3205], [19.0507, -10.9989]]

face = [[20, 0], [31.8838, 18.4081], [10, 17.3205], [0, 7.34213], [-10,
17.3205], [-27.7456, 16.019], [-20, 0], [-5.22655, -3.01755], [-10,
-17.3205], [0, -29.8851], [10, -17.3205], [4.12534, -2.38177]]

face = [[20, 0], [24.6573, 14.2359], [10, 17.3205], [0, 6.03876], [-10,
17.3205], [-20.8959, 12.0643], [-20, 0], [-19.3807, -11.1895], [-10,
-17.3205], [0, -27.649], [10, -17.3205], [11.166, -6.44668]]

2018-02-19 7:15 GMT-03:00 NateTG nate-openscadforum@pedantic.org:

FWIW I did write a face triangulator:

triangulate.scad http://forum.openscad.org/file/t2140/triangulate.scad

It seems that your ear clipping method doesn't work properly in some cases: face = [[20, 0], [15.5279, 8.96503], [10, 17.3205], [0, 8.85357], [-10, 17.3205], [-31.0929, 17.9515], [-20, 0], [-33.2343, -19.1878], [-10, -17.3205], [0, -14.4569], [10, -17.3205], [19.0507, -10.9989]] face = [[20, 0], [31.8838, 18.4081], [10, 17.3205], [0, 7.34213], [-10, 17.3205], [-27.7456, 16.019], [-20, 0], [-5.22655, -3.01755], [-10, -17.3205], [0, -29.8851], [10, -17.3205], [4.12534, -2.38177]] face = [[20, 0], [24.6573, 14.2359], [10, 17.3205], [0, 6.03876], [-10, 17.3205], [-20.8959, 12.0643], [-20, 0], [-19.3807, -11.1895], [-10, -17.3205], [0, -27.649], [10, -17.3205], [11.166, -6.44668]] 2018-02-19 7:15 GMT-03:00 NateTG <nate-openscadforum@pedantic.org>: > FWIW I did write a face triangulator: > > triangulate.scad <http://forum.openscad.org/file/t2140/triangulate.scad> > >
N
NateTG
Mon, Feb 19, 2018 7:06 PM

Ronaldo wrote

It seems that your ear clipping method doesn't work properly in some
cases:face = [[20, 0], [15.5279, 8.96503], [10, 17.3205], [0, 8.85357],
[-10,17.3205], [-31.0929, 17.9515], [-20, 0], [-33.2343, -19.1878],
[-10,-17.3205], [0, -14.4569], [10, -17.3205], [19.0507, -10.9989]]face =
[[20, 0], [31.8838, 18.4081], [10, 17.3205], [0, 7.34213], [-10,17.3205],
[-27.7456, 16.019], [-20, 0], [-5.22655, -3.01755], [-10,-17.3205], [0,
-29.8851], [10, -17.3205], [4.12534, -2.38177]]face = [[20, 0], [24.6573,
14.2359], [10, 17.3205], [0, 6.03876], [-10,17.3205], [-20.8959, 12.0643],
[-20, 0], [-19.3807, -11.1895], [-10,-17.3205], [0, -27.649], [10,
-17.3205], [11.166, -6.44668]]...

Thanks for the test cases.  This should be fixed: triangulate.scad
http://forum.openscad.org/file/t2140/triangulate.scad

--
Sent from: http://forum.openscad.org/

Ronaldo wrote > It seems that your ear clipping method doesn't work properly in some > cases:face = [[20, 0], [15.5279, 8.96503], [10, 17.3205], [0, 8.85357], > [-10,17.3205], [-31.0929, 17.9515], [-20, 0], [-33.2343, -19.1878], > [-10,-17.3205], [0, -14.4569], [10, -17.3205], [19.0507, -10.9989]]face = > [[20, 0], [31.8838, 18.4081], [10, 17.3205], [0, 7.34213], [-10,17.3205], > [-27.7456, 16.019], [-20, 0], [-5.22655, -3.01755], [-10,-17.3205], [0, > -29.8851], [10, -17.3205], [4.12534, -2.38177]]face = [[20, 0], [24.6573, > 14.2359], [10, 17.3205], [0, 6.03876], [-10,17.3205], [-20.8959, 12.0643], > [-20, 0], [-19.3807, -11.1895], [-10,-17.3205], [0, -27.649], [10, > -17.3205], [11.166, -6.44668]]... Thanks for the test cases. This should be fixed: triangulate.scad <http://forum.openscad.org/file/t2140/triangulate.scad> -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Mon, Feb 19, 2018 8:50 PM

Nice but I still have caught some other cases with this test code:

b = 20;
seed =floor(rands(0,10000,1)[0]); // some problematic seeds:  2517, 4041,
2033
echo(seed=seed); // to reproduce problematic cases
a = rands(b/5, 2*b, 12,seed);

star = [ for(i=[0:30:360-1]) (i%60 ? a[i/30]:b)*[cos(i), sin(i)] ];

color("red")
translate([0,0,-5])
polygon(star);

star3 = to3d(star);
polyhedron( star3, triangulate_face(star3,[for(i=[0:len(star)-1]) i ]));

2018-02-19 16:06 GMT-03:00 NateTG nate-openscadforum@pedantic.org:

Ronaldo wrote
It seems that your ear clipping method doesn't work properly in some
cases: face = [[20, 0], [15.5279, 8.96503], [10, 17.3205], [0, 8.85357],
[-10, 17.3205], [-31.0929, 17.9515], [-20, 0], [-33.2343, -19.1878], [-10,
-17.3205], [0, -14.4569], [10, -17.3205], [19.0507, -10.9989]] face = [[20,
0], [31.8838, 18.4081], [10, 17.3205], [0, 7.34213], [-10, 17.3205],
[-27.7456, 16.019], [-20, 0], [-5.22655, -3.01755], [-10, -17.3205], [0,
-29.8851], [10, -17.3205], [4.12534, -2.38177]] face = [[20, 0], [24.6573,
14.2359], [10, 17.3205], [0, 6.03876], [-10, 17.3205], [-20.8959, 12.0643],
[-20, 0], [-19.3807, -11.1895], [-10, -17.3205], [0, -27.649], [10,
-17.3205], [11.166, -6.44668]] ...

Thanks for the test cases. This should be fixed: triangulate.scad
http://forum.openscad.org/file/t2140/triangulate.scad

Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


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

Nice but I still have caught some other cases with this test code: b = 20; seed =floor(rands(0,10000,1)[0]); // some problematic seeds: 2517, 4041, 2033 echo(seed=seed); // to reproduce problematic cases a = rands(b/5, 2*b, 12,seed); star = [ for(i=[0:30:360-1]) (i%60 ? a[i/30]:b)*[cos(i), sin(i)] ]; color("red") translate([0,0,-5]) polygon(star); star3 = to3d(star); polyhedron( star3, triangulate_face(star3,[for(i=[0:len(star)-1]) i ])); 2018-02-19 16:06 GMT-03:00 NateTG <nate-openscadforum@pedantic.org>: > Ronaldo wrote > It seems that your ear clipping method doesn't work properly in some > cases: face = [[20, 0], [15.5279, 8.96503], [10, 17.3205], [0, 8.85357], > [-10, 17.3205], [-31.0929, 17.9515], [-20, 0], [-33.2343, -19.1878], [-10, > -17.3205], [0, -14.4569], [10, -17.3205], [19.0507, -10.9989]] face = [[20, > 0], [31.8838, 18.4081], [10, 17.3205], [0, 7.34213], [-10, 17.3205], > [-27.7456, 16.019], [-20, 0], [-5.22655, -3.01755], [-10, -17.3205], [0, > -29.8851], [10, -17.3205], [4.12534, -2.38177]] face = [[20, 0], [24.6573, > 14.2359], [10, 17.3205], [0, 6.03876], [-10, 17.3205], [-20.8959, 12.0643], > [-20, 0], [-19.3807, -11.1895], [-10, -17.3205], [0, -27.649], [10, > -17.3205], [11.166, -6.44668]] ... > > Thanks for the test cases. This should be fixed: triangulate.scad > <http://forum.openscad.org/file/t2140/triangulate.scad> > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >