Re: OpenSCAD Digest, Vol 23, Issue 14

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD Digest, Vol 23, Issue 14

Pierre Lecanu Wibee
Thank you
--
Cordialement

Pierre Lecanu
@wibee.eu




On Sunday 23 October 2011 20:28:05 [hidden email] wrote:

> Send OpenSCAD mailing list submissions to
> [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://rocklinux.net/mailman/listinfo/openscad
> or, via email, send a message with subject or body 'help' to
> [hidden email]
>
> You can reach the person managing the list at
> [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of OpenSCAD digest..."
>
>
> Today's Topics:
>
>    1. Re: OpenSCAD Digest, Vol 23, Issue 11 (nop head)
>    2. Re: OpenSCAD Digest, Vol 23, Issue 11 (nop head)
>    3. Re: OpenSCAD Digest, Vol 23, Issue 11 (William Adams)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 23 Oct 2011 19:14:31 +0100
> From: nop head <[hidden email]>
> Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
> To: [hidden email]
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Actually it does work. I forgot that you need a boolean. This works:
>
> function toto(k) = k > 0 ? toto(k - 1) + k : 0;
>
> On 23 October 2011 19:06, Whosawhatsis <[hidden email]> wrote:
> > Are you sure that the ternary operator exists in OpenSCAD? I've tried to
> > use it several times and it has never worked, forcing me to write a
> > significantly longer script to code around it. I've never used a function
> > in OpenSCAD (only modules), but if it doesn't work in functions, perhaps
> > there are other situations where it would be very useful but doesn't
> > work.
> >
> > On Sunday, October 23, 2011 at 10:48 AM, nop head wrote:
> >
> > It appears that you can have recursions because if a function calls
> > itself openscad crashes. But for some reason the ternary operator seems
> > to not work on functions. Is that just a bug or is there a fundamental
> > reason why it doesn't?
> >
> > If it did you could solve the problem with
> >
> > function toto(k) = k ? toto(k-1) + k : 0;
> >
> > On 23 October 2011 17:47, William Adams <[hidden email]> wrote:
> >  But of course RapCAD can do this!
> >
> > It sure would be useful if functions could have bodies, and recursion.
> > But, plenty can be done without it.
> >
> > You just have to leave typical notions of programming behind, and just do
> > your loops as part of a module, where instead of returning a result, you
> > code up an object directly.
> >
> > Another way OpenScad could be extended is if the child() module could
> > give you access to the various attributes of an object.  In particular
> > the points mesh.  Then I could stuff anything into the points mesh, and
> > read it somewhere else.  This is similar to what GLSL did in the early
> > days where 'texture' was just another name for 'random memory'.
> >
> > -- William
> >
> > ===============================
> > - Shaping clay is easier than digging it out of the ground.
> >
> > http://blog.nanotechstyles.com
> > http://www.thingiverse.com/WilliamAAdams
> > https://github.com/Wiladams
> >
> >
> >
> > ------------------------------
> > Date: Sun, 23 Oct 2011 16:55:36 +0100
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
> >
> >
> > Surely it's an AP:
> >
> > function toto(k) = (k+1) * k / 2;
> >
> > But that steps round the issue that there are no loops inside functions.
> >
> > On 23 October 2011 16:46, Giles Bathgate <[hidden email]> wrote:
> > > function toto(k) { return k + 1; }
> >
> > Syntax error you want:
> >  function toto(k) = k+1;
> >
> > Regards
> >
> > Giles
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://rocklinux.net/mailman/listinfo/openscad
> >
> >
> >
> > _______________________________________________ OpenSCAD mailing list
> > [hidden email] http://rocklinux.net/mailman/listinfo/openscad
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://rocklinux.net/mailman/listinfo/openscad
> >
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://rocklinux.net/mailman/listinfo/openscad
> >
> >
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://rocklinux.net/mailman/listinfo/openscad
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://rocklinux.net/pipermail/openscad/attachments/20111023/00bb5f28/atta
> chment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Sun, 23 Oct 2011 19:17:02 +0100
> From: nop head <[hidden email]>
> Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
> To: [hidden email]
> Message-ID:
> <CAEEmnrP9VZcYNEcTVLSn1MErqFrNVzm8s=[hidden email]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> And I seem to remember reading somewhere that any loop can be converted to
> tail recursion, so it would seem to be a complete solution for iteration in
> functions.
>
> On 23 October 2011 19:14, nop head <[hidden email]> wrote:
> > Actually it does work. I forgot that you need a boolean. This works:
> >
> > function toto(k) = k > 0 ? toto(k - 1) + k : 0;
> >
> > On 23 October 2011 19:06, Whosawhatsis <[hidden email]> wrote:
> >> Are you sure that the ternary operator exists in OpenSCAD? I've tried to
> >> use it several times and it has never worked, forcing me to write a
> >> significantly longer script to code around it. I've never used a
> >> function in OpenSCAD (only modules), but if it doesn't work in
> >> functions, perhaps there are other situations where it would be very
> >> useful but doesn't work.
> >>
> >> On Sunday, October 23, 2011 at 10:48 AM, nop head wrote:
> >>
> >> It appears that you can have recursions because if a function calls
> >> itself openscad crashes. But for some reason the ternary operator seems
> >> to not work on functions. Is that just a bug or is there a fundamental
> >> reason why it doesn't?
> >>
> >> If it did you could solve the problem with
> >>
> >> function toto(k) = k ? toto(k-1) + k : 0;
> >>
> >> On 23 October 2011 17:47, William Adams <[hidden email]> wrote:
> >>  But of course RapCAD can do this!
> >>
> >> It sure would be useful if functions could have bodies, and recursion.
> >> But, plenty can be done without it.
> >>
> >> You just have to leave typical notions of programming behind, and just
> >> do your loops as part of a module, where instead of returning a result,
> >> you code up an object directly.
> >>
> >> Another way OpenScad could be extended is if the child() module could
> >> give you access to the various attributes of an object.  In particular
> >> the points mesh.  Then I could stuff anything into the points mesh, and
> >> read it somewhere else.  This is similar to what GLSL did in the early
> >> days where 'texture' was just another name for 'random memory'.
> >>
> >> -- William
> >>
> >> ===============================
> >> - Shaping clay is easier than digging it out of the ground.
> >>
> >> http://blog.nanotechstyles.com
> >> http://www.thingiverse.com/WilliamAAdams
> >> https://github.com/Wiladams
> >>
> >>
> >>
> >> ------------------------------
> >> Date: Sun, 23 Oct 2011 16:55:36 +0100
> >> From: [hidden email]
> >> To: [hidden email]
> >> Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
> >>
> >>
> >> Surely it's an AP:
> >>
> >> function toto(k) = (k+1) * k / 2;
> >>
> >> But that steps round the issue that there are no loops inside functions.
> >>
> >> On 23 October 2011 16:46, Giles Bathgate <[hidden email]>wrote:
> >> > function toto(k) { return k + 1; }
> >>
> >> Syntax error you want:
> >>  function toto(k) = k+1;
> >>
> >> Regards
> >>
> >> Giles
> >> _______________________________________________
> >> OpenSCAD mailing list
> >> [hidden email]
> >> http://rocklinux.net/mailman/listinfo/openscad
> >>
> >>
> >>
> >> _______________________________________________ OpenSCAD mailing list
> >> [hidden email] http://rocklinux.net/mailman/listinfo/openscad
> >>
> >> _______________________________________________
> >> OpenSCAD mailing list
> >> [hidden email]
> >> http://rocklinux.net/mailman/listinfo/openscad
> >>
> >>
> >> _______________________________________________
> >> OpenSCAD mailing list
> >> [hidden email]
> >> http://rocklinux.net/mailman/listinfo/openscad
> >>
> >>
> >>
> >> _______________________________________________
> >> OpenSCAD mailing list
> >> [hidden email]
> >> http://rocklinux.net/mailman/listinfo/openscad
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://rocklinux.net/pipermail/openscad/attachments/20111023/2f0fe9f4/atta
> chment-0001.html
>
> ------------------------------
>
> Message: 3
> Date: Sun, 23 Oct 2011 18:28:01 +0000
> From: William Adams <[hidden email]>
> Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
> To: <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> More examples of ternary:
> function map_array(range, u) = (u*range) >= range ? range-1 :
> floor(u*range);
>
>
> and cascaded functions, with ternaries, that themselves call inbuilt
> functions, but not themselves: function SSCos(shape, phi) = pow(
> abs(cos(shape[0]*phi/4) / shape[4]), shape[2]); function SSSin(shape, phi)
> = pow(abs(sin(shape[0]*phi/4) / shape[5]), shape[3]); function SSR(shape,
> phi) = pow((SSCos(shape,phi) + SSSin(shape,phi)), 1/shape[1]);
>
> function _EvalSuperShape2D3(phi, r) =
> abs(r) == 0 ? [0,0,0] : [1/r * cos(phi), 1/r*sin(phi),0];
>
>
> function _EvalSuperShape2D2(phi, n1, t1, t2) =
>
> _EvalSuperShape2D3(phi, t1, t2, r=pow(t1+t2, 1/n1));
>
>
> function EvalSuperShape2D(shape, phi) = _EvalSuperShape2D2(phi, shape[1],
> t1=SSCos(shape,phi), t2=SSSin(shape,phi)); I've thought about tail
> recursion as a mechanism for unrolling loops, but haven't figured out a
> way to express that in OpenScad. Any ideas?
> -- William
>
> ===============================
>
> - Shaping clay is easier than digging it out of the ground.
>
>
> http://blog.nanotechstyles.com
> http://www.thingiverse.com/WilliamAAdams
> https://github.com/Wiladams
>
>
>
> Date: Sun, 23 Oct 2011 19:17:02 +0100
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
>
> And I seem to remember reading somewhere that any loop can be converted to
> tail recursion, so it would seem to be a complete solution for iteration
> in functions.
>
> On 23 October 2011 19:14, nop head <[hidden email]> wrote:
>
> Actually it does work. I forgot that you need a boolean. This works:
> function toto(k) = k > 0 ? toto(k - 1) + k : 0;
>
>
> On 23 October 2011 19:06, Whosawhatsis <[hidden email]> wrote:
>
>
>
>                 Are you sure that the ternary operator exists in OpenSCAD?
> I've tried to use it several times and it has never worked, forcing me to
> write a significantly longer script to code around it. I've never used a
> function in OpenSCAD (only modules), but if it doesn't work in functions,
> perhaps there are other situations where it would be very useful but
> doesn't work.
>
>
>
>
>                 On Sunday, October 23, 2011 at 10:48 AM, nop head wrote:
>
>                     It appears that you can have recursions because if a
> function calls itself openscad crashes. But for some reason the ternary
> operator seems to not work on functions. Is that just a bug or is there a
> fundamental reason why it doesn't?
>
>
>
> If it did you could solve the problem with
> function toto(k) = k ? toto(k-1) + k : 0;
>
> On 23 October 2011 17:47, William Adams <[hidden email]> wrote:
>
>
>
>
>
>
>
> But of course RapCAD can do this!
>
> It sure would be useful if functions could have bodies, and recursion.
> But, plenty can be done without it.
>
> You just have to leave typical notions of programming behind, and just do
> your loops as part of a module, where instead of returning a result, you
> code up an object directly.
>
>
>
>
> Another way OpenScad could be extended is if the child() module could give
> you access to the various attributes of an object.  In particular the
> points mesh.  Then I could stuff anything into the points mesh, and read
> it somewhere else.  This is similar to what GLSL did in the early days
> where 'texture' was just another name for 'random memory'.
>
>
>
>
> -- William
>
> ===============================
>
> - Shaping clay is easier than digging it out of the ground.
>
>
> http://blog.nanotechstyles.com
> http://www.thingiverse.com/WilliamAAdams
> https://github.com/Wiladams
>
>
>
>
>
>
> Date: Sun, 23 Oct 2011 16:55:36 +0100
> From: [hidden email]
> To: [hidden email]
>
>
>
> Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
>
> Surely it's an AP: function toto(k) = (k+1) * k / 2;
> But that steps round the issue that there are no loops inside functions.
>
> On 23 October 2011 16:46, Giles Bathgate <[hidden email]> wrote:
> > function toto(k) { return k + 1; }
>
> Syntax error you want:
>
>
>
>   function toto(k) = k+1;
>
>
>
> Regards
>
>
>
> Giles
>
> _______________________________________________
>
> OpenSCAD mailing list
>
> [hidden email]
>
> http://rocklinux.net/mailman/listinfo/openscad
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>
> _______________________________________________
>
> OpenSCAD mailing list
>
> [hidden email]
>
> http://rocklinux.net/mailman/listinfo/openscad
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
> OpenSCAD mailing list
>
> [hidden email]
>
> http://rocklinux.net/mailman/listinfo/openscad
>
>
>
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://rocklinux.net/pipermail/openscad/attachments/20111023/80b5867e/atta
> chment.html
>
> ------------------------------
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>
>
> End of OpenSCAD Digest, Vol 23, Issue 14
> ****************************************