[OpenSCAD] recursion crash

Peter Falke stempeldergeschichte at googlemail.com
Thu Apr 2 10:06:34 EDT 2015


Now, what I want, can be done in user space: redefining mirror, so to
accept keep=true.
I'm using multimarix to avoid a recursive definition.
Using the reflection matrix:

[image: \mathbf{A} = \begin{bmatrix} 1 - 2 a^2 & - 2 a b & - 2 a c \\ - 2 a
b & 1 - 2 b^2 & - 2 b c \\ - 2 a c & - 2 b c & 1 - 2c^2 \end{bmatrix}]

from:
http://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations
If it can be done in user space, this could be an argument not to include
it into the core language.
But I still think: it makes it easier for newbies and it makes cde easier
to read and write if this is included into OpenSCAD.

module mirror(v,keep=false){
    if(keep)children();
        u=v/norm(v);
        a=u.x;
        b=u.y;
        c=u.z;
    multmatrix(m = [
                [1-2*a*a, -2*a*b, -2*a*c, 0],
                [-2*a*b,1-2*b*b, -2*b*c, 0],
                [-2*a*c, -2*b*c, 1-2*c*c, 0],
                [0, 0, 0,  1]
    ])
        children();
}

mirror([1,1,1],true)cube(1);



2015-04-02 15:32 GMT+02:00 Peter Falke <stempeldergeschichte at googlemail.com>
:

> What I want is:
>
> mirror(v,keep=true)
>
> But, I may not get it. ;)
>
> I posted it only, because it crashes and I think Kintel tries hard to fix
> OpenSCAD crashing at all.
>
> 2015-04-02 14:50 GMT+02:00 Martin Herdieckerhoff <
> Martin.Herdieckerhoff at mnet-mail.de>:
>
>>  You redefine the predefined module mirror.
>> What you want is probably this:
>>
>> module mirror_duplicate(v){
>>     children();
>>     mirror(v) children();
>> }
>>
>> mirror_duplicate([1,0,0]) cube();
>>
>>
>> Am 02.04.2015 um 13:41 schrieb Peter Falke:
>>
>>  This crushes on Win 7 with version 2015.03
>>
>> module mirror(v){
>>     children();
>>     mirror(v)children();
>> }
>>
>> mirror([1,0,0])cube();
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss at lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>
>
> --
> stempeldergeschichte at googlemail.com <karsten at rohrbach.de>
>
> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
> Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
> schreiben.
> Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
>
> P.S. In case my e-mail is shorter than you enjoy:
> I am currently trying short replies instead of no replies at all.
> Please let me know, if you like to read more.
>
> Enjoy!
>



-- 
stempeldergeschichte at googlemail.com <karsten at rohrbach.de>

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150402/92427217/attachment-0002.html>


More information about the Discuss mailing list