discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Sweeping polygon over irregular shape?

R
runsun
Wed, Dec 5, 2018 12:34 AM

Hi Marko,

A minor issue that I think not that much a bit deal --- when the resolution
is low, it seems to have hard time producing a real square.

phelix = [for (i=[0:5:45]) 5*[cos(i), sin(i), i/360]];

or

phelix = [for (i=[0:9:45]) 5*[cos(i), sin(i), i/360]];

loft(phelix, pcircle, psquare);


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer ); $ Tips ; $ Snippets

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

Hi Marko, A minor issue that I think not that much a bit deal --- when the resolution is low, it seems to have hard time producing a real square. phelix = [for (i=[0:5:45]) 5*[cos(i), sin(i), i/360]]; or phelix = [for (i=[0:9:45]) 5*[cos(i), sin(i), i/360]]; loft(phelix, pcircle, psquare); ----- $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer ); $ Tips ; $ Snippets -- Sent from: http://forum.openscad.org/
R
runsun
Wed, Dec 5, 2018 12:47 AM

I am wondering,  Marko, if it's possible to use your approach to achieve the
sweeping through a series of points with sharp turns, as shown in

http://forum.openscad.org/Two-annoyances-tp12935p13110.html

I suppose it needs some modifications. I've that code shown in that page but
it's far more complicated than yours.


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer ); $ Tips ; $ Snippets

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

I am wondering, Marko, if it's possible to use your approach to achieve the sweeping through a series of points with sharp turns, as shown in http://forum.openscad.org/Two-annoyances-tp12935p13110.html I suppose it needs some modifications. I've that code shown in that page but it's far more complicated than yours. ----- $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer ); $ Tips ; $ Snippets -- Sent from: http://forum.openscad.org/
B
berkenb
Wed, Dec 5, 2018 1:04 AM

Hi Runsun,
I think that's a bug in the routine. In the interpolation inside the loft,
the weights are computed as (i-1)/(len(p)-1), that should really be
(i-1)/(len(p)-2) - loft internally adds an extra unused point to the path to
get a value for the last tangent...
Thanks for finding this.
Marko

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

Hi Runsun, I think that's a bug in the routine. In the interpolation inside the loft, the weights are computed as (i-1)/(len(p)-1), that should really be (i-1)/(len(p)-2) - loft internally adds an extra unused point to the path to get a value for the last tangent... Thanks for finding this. Marko -- Sent from: http://forum.openscad.org/
B
berkenb
Wed, Dec 5, 2018 1:09 AM

I suppose as is, the code might produce self intersections in sharp turns and
thus not be terribly useful. Dealing with that probably requires a lot more
code.
Marko

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

I suppose as is, the code might produce self intersections in sharp turns and thus not be terribly useful. Dealing with that probably requires a lot more code. Marko -- Sent from: http://forum.openscad.org/
P
Parkinbot
Wed, Dec 5, 2018 2:10 PM

Of course sweep() cannot check for self intersection with respect to runtime.
Also interpolation schemes are prone to produce self intersection.

Btw. I wouldn't model the two techniques (interpolation and sweep) into a
single scheme. There are several steps involved, which can be implemented in
a more general fashion to get a more general scheme.

  1. define some resampling function to unify the # of vertices (not needed if
    skin() is used)
  2. define an interpolation function that interpolates between the two
    polygons according to some value k between 0 and 1.
  3. use a composer function to model the extrusion trajectory (the final
    shape)
  4. use any sweep() for the dirty work (e.g. my Naca_sweep lib)

while 3) is the function that does the final shape, and 4) is library stuff,

  1. and 2) are simply:

example($t);  // set up an animation to view the interpolation
module example(k=.4, n=3, N=120)
{
p = interpol(circle(r=5, N=N), resample(circle(N=n), N/n), k);
polygon(p);
}

function interpol(p1, p2, k=0) = let(n= len(p1))
(n!=len(p2))? undef: [for (i=[0:n-1]) p1[i]*(1-k) + p2[i]*k];

function resample(p, n=1) = let(m = len(p))[for(i=[0:m-1], j=[0:n-1])
p[i]+(p[(i+1)%m] - p[i])/n*j];

function circle(r=5,N=12) = [for(i=[0:N-1]) r*[cos(360/Ni), sin(360/Ni)]];

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

Of course sweep() cannot check for self intersection with respect to runtime. Also interpolation schemes are prone to produce self intersection. Btw. I wouldn't model the two techniques (interpolation and sweep) into a single scheme. There are several steps involved, which can be implemented in a more general fashion to get a more general scheme. 1. define some resampling function to unify the # of vertices (not needed if skin() is used) 2. define an interpolation function that interpolates between the two polygons according to some value k between 0 and 1. 3. use a composer function to model the extrusion trajectory (the final shape) 4. use any sweep() for the dirty work (e.g. my Naca_sweep lib) while 3) is the function that does the final shape, and 4) is library stuff, 1) and 2) are simply: example($t); // set up an animation to view the interpolation module example(k=.4, n=3, N=120) { p = interpol(circle(r=5, N=N), resample(circle(N=n), N/n), k); polygon(p); } function interpol(p1, p2, k=0) = let(n= len(p1)) (n!=len(p2))? undef: [for (i=[0:n-1]) p1[i]*(1-k) + p2[i]*k]; function resample(p, n=1) = let(m = len(p))[for(i=[0:m-1], j=[0:n-1]) p[i]+(p[(i+1)%m] - p[i])/n*j]; function circle(r=5,N=12) = [for(i=[0:N-1]) r*[cos(360/N*i), sin(360/N*i)]]; -- Sent from: http://forum.openscad.org/
R
roland78
Sun, Dec 9, 2018 7:58 PM

hi. why is not working to me this code? i get this  ERROR: Experimental
feature not enabled: 'lc-for-c'. Please check preferences. any idea?

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

hi. why is not working to me this code? i get this ERROR: Experimental feature not enabled: 'lc-for-c'. Please check preferences. any idea? -- Sent from: http://forum.openscad.org/
NH
nop head
Sun, Dec 9, 2018 8:06 PM

You need a recent snapshot version of OpenSCAD and then you need to enable
it in Preferences / Features by ticking the box.

[image: image.png]

On Sun, 9 Dec 2018 at 19:59, roland78 davidroland78@gmail.com wrote:

hi. why is not working to me this code? i get this  ERROR: Experimental
feature not enabled: 'lc-for-c'. Please check preferences. any idea?

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


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

You need a recent snapshot version of OpenSCAD and then you need to enable it in Preferences / Features by ticking the box. [image: image.png] On Sun, 9 Dec 2018 at 19:59, roland78 <davidroland78@gmail.com> wrote: > hi. why is not working to me this code? i get this ERROR: Experimental > feature not enabled: 'lc-for-c'. Please check preferences. any idea? > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
roland78
Mon, Dec 10, 2018 6:42 PM

Thank you . Now is good.

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

Thank you . Now is good. -- Sent from: http://forum.openscad.org/