Alignment mystery?

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

Alignment mystery?

tobject
Hey folks. Having some alignment issue. AlignRight2() suppose to
produce same result as AlignRight but it does not. Any suggestions?

Thanks in advance

//====
include <relativity/relativity.scad>;



module AlignRight2() {
    rod(d=10,h=2, anchor=[-1,0,0])



    align([[1,0,0],[1,0,0],[1,0,0]])
    rod(d=10,h=2, anchor=[-1,0,0]);

}

 module AlignRight() {
    rod(d=10,h=2, anchor=[-1,0,0])
    align([1,0,0])
    rod(d=10,h=2, anchor=[-1,0,0])
    align([1,0,0])
    rod(d=10,h=2, anchor=[-1,0,0])
    align([1,0,0])
    rod(d=10,h=2, anchor=[-1,0,0]);


 }

AlignRight();

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

Alignright.jpg (47K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Alignment mystery?

grit
Hi tobject!

I think the result is not the same for the two modules due to AlignRight2
manipulates the same object. Try to change AlignRight2 to:

module AlignRight2() {
    rod(d=10,h=2, anchor=[-1,0,0])



    align([[1,0,0],[4,0,0],[8,0,0]])
    rod(d=10,h=2, anchor=[-1,0,0]);

}

and you will see the other rods in a row.

//BR Henrik



--
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: Alignment mystery?

tobject
You are right! I was treating these guys as siblings, in fact they are
generations instead. But your solution uses undocumented feature of
the library (which maybe a bug). Instead, recursion solves the
problem.

module AlignRight3(n) {

    if (n>0) {

        rod(d=10,h=2, anchor=[-1,0,0])
        align([1,0,0])
        AlignRight3(n-1);

    }
    else
    {

        rod(d=10,h=2, anchor=[-1,0,0]);

    }


}

AlignRight3(3);



On 6/14/19, grit <[hidden email]> wrote:

> Hi tobject!
>
> I think the result is not the same for the two modules due to AlignRight2
> manipulates the same object. Try to change AlignRight2 to:
>
> module AlignRight2() {
>     rod(d=10,h=2, anchor=[-1,0,0])
>
>
>
>     align([[1,0,0],[4,0,0],[8,0,0]])
>     rod(d=10,h=2, anchor=[-1,0,0]);
>
> }
>
> and you will see the other rods in a row.
>
> //BR Henrik
>
>
>
> --
> 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