making vases, perhaps with InkScape

classic Classic list List threaded Threaded
50 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
Parkinbot wrote
> Jon,
>
> I think your project is just another example, why a more general interface
> for linear_extrude() would make sense. Of course sweep/skin functionality
> will also do as it provides the most general interface for extrusions.
> ...

I think it's also a good example of how the scope is endless.


Jon_Bondy wrote
> ...
> I thought of creating the curves with Bezier curves inside OpenSCAD, but
> most implementations are limited to 4 control points; and working in
> OpenSCAD by typing in numbers could be both laborious and non-intuitive.
> ...

OpenSCAD may not be suitable for the sort of development process you're
looking for.

IIRC N-point bezier is not that hard to do.

function nbezier(points,t)=
    1>=len(points)?
        points[0]
    :
        nbezier(
            [for(i=[0:len(points)-2]) points[i]*t+points[i+1]*(1-t)],
            t
        );

module segment (a,b,r=0.1) {
   d=(b-a);
   phi=atan2(sqrt(d.x*d.x+d.y*d.y),d.z);
   theta=atan2(d.y,d.x);
   len=sqrt(d*d);
   translate(a)
       rotate(a=theta)
            rotate(v=[0,1,0],a=phi)
                cylinder(r=r,h=len);
}


list=[ [0,1,0],[4,-1,-4],[-5,-5,-5],[2,3,3],[5,5,0] ];

shape=[for (t=[0:0.05:1]) nbezier(list,t)];

for(i=[0:len(shape)-2]) {
   segment(shape[i],shape[i+1]);
}





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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

jon_bondy
Thanks for the n-point Bezier code!


On 2/16/2018 12:04 PM, NateTG wrote:

> Parkinbot wrote
>> Jon,
>>
>> I think your project is just another example, why a more general interface
>> for linear_extrude() would make sense. Of course sweep/skin functionality
>> will also do as it provides the most general interface for extrusions.
>> ...
> I think it's also a good example of how the scope is endless.
>
>
> Jon_Bondy wrote
>> ...
>> I thought of creating the curves with Bezier curves inside OpenSCAD, but
>> most implementations are limited to 4 control points; and working in
>> OpenSCAD by typing in numbers could be both laborious and non-intuitive.
>> ...
> OpenSCAD may not be suitable for the sort of development process you're
> looking for.
>
> IIRC N-point bezier is not that hard to do.
>
> function nbezier(points,t)=
>      1>=len(points)?
>          points[0]
>      :
>          nbezier(
>              [for(i=[0:len(points)-2]) points[i]*t+points[i+1]*(1-t)],
>              t
>          );
>
> module segment (a,b,r=0.1) {
>     d=(b-a);
>     phi=atan2(sqrt(d.x*d.x+d.y*d.y),d.z);
>     theta=atan2(d.y,d.x);
>     len=sqrt(d*d);
>     translate(a)
>         rotate(a=theta)
>              rotate(v=[0,1,0],a=phi)
>                  cylinder(r=r,h=len);
> }
>
>
> list=[ [0,1,0],[4,-1,-4],[-5,-5,-5],[2,3,3],[5,5,0] ];
>
> shape=[for (t=[0:0.05:1]) nbezier(list,t)];
>
> for(i=[0:len(shape)-2]) {
>     segment(shape[i],shape[i+1]);
> }
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>

--
Sent from my desktop computer.
I do not receive emails while away from my desk,
nor do I receive texts on my main phone number
(which is a land line).
If you know that I am on the road, please text me.
If you know that I am home, please email me.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
I made an error so that produces the bezier line reversing the order of the
vertices.  You can switch t and (1-t) to get the  version that goes in the
correct direction:

> function nbezier(points,t)=
>      1>=len(points)?
>          points[0]
>      :
>          nbezier(
>              [for(i=[0:len(points)-2]) points[i]*(1-t)+points[i+1]*t],
>              t
>          );



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

atnbueno
In reply to this post by jon_bondy
In case you are still interested in drawing the "weird vase" in Inkscape...

Inkscape allows you to interpolate between two shapes. That detail was the inspiration for this:

First, a couple of shapes: imagine the "weird vase" cut by the XY and the YZ planes
Imágenes integradas 1

One of the shapes must be copied and mirrored
Imágenes integradas 2

Then a couple of Inkscape's path interpolations, and save as SVG
Imágenes integradas 3

Importing the SVG file into OpenSCAD we can arrange the "planes" like this
Imágenes integradas 4

And cutting vertical slices and "hulling" each of them ends up like this
Imágenes integradas 5

This is the code:

width = 90;
height = 120;
planes = 13;

module plane(n) {
linear_extrude(height=1, center=true) intersection() {
translate([width*(n-floor(planes/2)), 0]) import(str(planes, "planes.svg"));
square([width, height], true);
}
}

module planes() {
for(i=[1:planes-1]) rotate([90, 0, 180/(planes-1)*i]) plane(i);
}

for(i=[-height/2:height/2]) hull() {
intersection() {
planes();
translate([0, 0, i]) cube([width, width, 1], true);
}
}

The attached file includes the .scad, the .svg and a rendered .amf


2018-02-16 18:52 GMT+01:00 jon <[hidden email]>:
Thanks for the n-point Bezier code!



On 2/16/2018 12:04 PM, NateTG wrote:
Parkinbot wrote
Jon,

I think your project is just another example, why a more general interface
for linear_extrude() would make sense. Of course sweep/skin functionality
will also do as it provides the most general interface for extrusions.
...
I think it's also a good example of how the scope is endless.


Jon_Bondy wrote
...
I thought of creating the curves with Bezier curves inside OpenSCAD, but
most implementations are limited to 4 control points; and working in
OpenSCAD by typing in numbers could be both laborious and non-intuitive.
...
OpenSCAD may not be suitable for the sort of development process you're
looking for.

IIRC N-point bezier is not that hard to do.

function nbezier(points,t)=
     1>=len(points)?
         points[0]
     :
         nbezier(
             [for(i=[0:len(points)-2]) points[i]*t+points[i+1]*(1-t)],
             t
         );

module segment (a,b,r=0.1) {
    d=(b-a);
    phi=atan2(sqrt(d.x*d.x+d.y*d.y),d.z);
    theta=atan2(d.y,d.x);
    len=sqrt(d*d);
    translate(a)
        rotate(a=theta)
             rotate(v=[0,1,0],a=phi)
                 cylinder(r=r,h=len);
}


list=[ [0,1,0],[4,-1,-4],[-5,-5,-5],[2,3,3],[5,5,0] ];

shape=[for (t=[0:0.05:1]) nbezier(list,t)];

for(i=[0:len(shape)-2]) {
    segment(shape[i],shape[i+1]);
}





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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



--
Sent from my desktop computer.
I do not receive emails while away from my desk,
nor do I receive texts on my main phone number
(which is a land line).
If you know that I am on the road, please text me.
If you know that I am home, please email me.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



--
Saludos,
Antonio



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

weird_vase.7z (127K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

jon_bondy

Very creative!


On 2/16/2018 4:33 PM, Antonio Bueno wrote:
In case you are still interested in drawing the "weird vase" in Inkscape...

Inkscape allows you to interpolate between two shapes. That detail was the inspiration for this:

First, a couple of shapes: imagine the "weird vase" cut by the XY and the YZ planes
Imágenes integradas 1


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Ronaldo
In reply to this post by Ronaldo
2018-02-16 12:21 GMT-02:00 jon <[hidden email]>:

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.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

RevarBat
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:

Relevant docs:

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 <[hidden email]> wrote:

2018-02-16 12:21 GMT-02:00 jon <[hidden email]>:

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.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Parkinbot
In reply to this post by Ronaldo
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
In reply to this post by RevarBat
> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

RevarBat
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 <[hidden email]> 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
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

kintel
Administrator
> On Feb 18, 2018, at 6:10 PM, Revar Desmera <[hidden email]> 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


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
In reply to this post by RevarBat
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Ronaldo
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 <[hidden email]>:
FWIW I did write a face triangulator:

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



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
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

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Ronaldo
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 <[hidden email]>:
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

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Ronaldo
This one was missing:

function to3d(p) = [for(pi=p) [pi[0], pi[1], 0] ];
  


2018-02-19 17:50 GMT-03:00 Ronaldo Persiano <[hidden email]>:
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 ]));



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Gadgetmind
In reply to this post by RevarBat
On 18/02/18 23:10, Revar Desmera wrote:
Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience.

This is why I have my own version of skin () that triangulates the top and bottom. Sometimes the render retries and it all works but more often it barfs out an error with no clue as to which bit of geometry.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
In reply to this post by Ronaldo
Wow... maybe I should go to the school for children that can't math good.


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



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

Ronaldo
Don't be so severe with yourself! Your code is cleaner than my own. I haven't checked it in depth but it seems to be ok now. Nice work.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: making vases, perhaps with InkScape

NateTG
Ronaldo wrote
> Don't be so severe with yourself! Your code is cleaner than my own. I
> haven't checked it in depth but it seems to be ok now. Nice work.
> ...

It can get in trouble when there are colinear points.

Something like:
test=[ [10,0],[0,0],[10,-30],[10,-20],[10,-10]];

Is a legitimate (ish) polygon, but the algorithm will clip point 1 first,
and be left with 4 vertices on a line which it can't handle.

Also, it should really have input checking.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
123