Mirror operator

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Mirror operator

jim_klessig
Relatively New user here, and having trouble with the "mirror" operation.
As I understand the documentation the mirror operation should create a mirrored copy of the object(s) within its scope.

When I do that to a set of objects, it creates the mirrored items, but not the original (unmirrored) ones.

I my understanding wrong, or am I missing something?

as an example
bigd=10;
smalld=3;
h1=20;

mirror(v=[1,0,0]) translate ([-10,-12,-10]) union () {
    cylinder (d1=bigd,d2=smalld, h=h1+.2 );
    translate ([-1.75,0,0]) cube ([3,6,h1+.2] );
}


gives me only one object, not the two, mirrored ones I was expecting.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mirror operator

louijp
The result is as expected.

If you need the two objects, you need to define both.

define the first one, then define the mirrored one.


Jean-Paul
N1JPL


> On Mar 14, 2017, at 8:21 PM, jim_klessig <[hidden email]> wrote:
>
> Relatively New user here, and having trouble with the "mirror" operation.
> As I understand the documentation the mirror operation should create a
> mirrored copy of the object(s) within its scope.
>
> When I do that to a set of objects, it creates the mirrored items, but not
> the original (unmirrored) ones.
>
> I my understanding wrong, or am I missing something?
>
> as an example
> bigd=10;
> smalld=3;
> h1=20;
>
> mirror(v=[1,0,0]) translate ([-10,-12,-10]) union () {
>    cylinder (d1=bigd,d2=smalld, h=h1+.2 );
>    translate ([-1.75,0,0]) cube ([3,6,h1+.2] );
> }
>
>
> gives me only one object, not the two, mirrored ones I was expecting.
>
>
>
>
>
> --
> View this message in context: http://forum.openscad.org/Mirror-operator-tp20900.html
> 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
|  
Report Content as Inappropriate

Re: Mirror operator

Ronaldo
In reply to this post by jim_klessig
mirror() is an operator like rotate(): it transforms objetcs, doesn't create copies. See: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Create_a_mirrored_object_while_retaining_the_original


2017-03-14 21:21 GMT-03:00 jim_klessig <[hidden email]>:
Relatively New user here, and having trouble with the "mirror" operation.
As I understand the documentation the mirror operation should create a
mirrored copy of the object(s) within its scope.

When I do that to a set of objects, it creates the mirrored items, but not
the original (unmirrored) ones.

I my understanding wrong, or am I missing something?

as an example
bigd=10;
smalld=3;
h1=20;

mirror(v=[1,0,0]) translate ([-10,-12,-10]) union () {
    cylinder (d1=bigd,d2=smalld, h=h1+.2 );
    translate ([-1.75,0,0]) cube ([3,6,h1+.2] );
}


gives me only one object, not the two, mirrored ones I was expecting.





--
View this message in context: http://forum.openscad.org/Mirror-operator-tp20900.html
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
|  
Report Content as Inappropriate

Re: Mirror operator

jim_klessig
In reply to this post by louijp
Ok, thanks.
That does not agree with what the example seems to indicate, and does make it a fairly useless operator imo.



Sent from my U.S. Cellular® Smartphone

-------- Original message --------
From: "louijp [via OpenSCAD]" <[hidden email]>
Date: 3/14/17 5:41 PM (GMT-08:00)
To: jim_klessig <[hidden email]>
Subject: Re: Mirror operator

The result is as expected.

If you need the two objects, you need to define both.

define the first one, then define the mirrored one.


Jean-Paul
N1JPL


> On Mar 14, 2017, at 8:21 PM, jim_klessig <[hidden email]> wrote:
>
> Relatively New user here, and having trouble with the "mirror" operation.
> As I understand the documentation the mirror operation should create a
> mirrored copy of the object(s) within its scope.
>
> When I do that to a set of objects, it creates the mirrored items, but not
> the original (unmirrored) ones.
>
> I my understanding wrong, or am I missing something?
>
> as an example
> bigd=10;
> smalld=3;
> h1=20;
>
> mirror(v=[1,0,0]) translate ([-10,-12,-10]) union () {
>    cylinder (d1=bigd,d2=smalld, h=h1+.2 );
>    translate ([-1.75,0,0]) cube ([3,6,h1+.2] );
> }
>
>
> gives me only one object, not the two, mirrored ones I was expecting.
>
>
>
>
>
> --
> View this message in context: http://forum.openscad.org/Mirror-operator-tp20900.html
> 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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/Mirror-operator-tp20900p20901.html
To unsubscribe from Mirror operator, click here.
NAML
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mirror operator

Ronaldo
2017-03-14 22:01 GMT-03:00 jim_klessig <[hidden email]>:
That does not agree with what the example seems to indicate, and does make it a fairly useless operator imo.

You are perfectly right regarding the manual: the first examples are misleading and need to be corrected. But mirror() is as useful as rotate() and other operators that do not make copies.


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

Re: Mirror operator

MichaelAtOz
Administrator
Examples corrected.
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mirror operator

Parkinbot
In reply to this post by Ronaldo
Ronaldo wrote
But mirror() is as useful as rotate()
besides the fact that it has really some funny implementation. Try this:

mirror([0, .2, 0]) cube (10);
mirror([1, .2, 0]) cube (10);
mirror([1, 1, .1]) cube (10);
mirror([1, 1, 1]) cube (10);
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mirror operator

nophead

>and does make it a fairly useless operator imo

It creates a mirror image of an object. I don't think there is another way to do that except by using multmatrix (which can also do rotate, translate, scale, etc.) so it is useful for me. For example, to make left and right hand versions of brackets.

On 15 March 2017 at 14:45, Parkinbot <[hidden email]> wrote:
Ronaldo wrote
> But mirror() is as useful as rotate()

besides the fact that it has really some funny implementation. Try this:


> mirror([0, .2, 0]) cube (10);
> mirror([1, .2, 0]) cube (10);
> mirror([1, 1, .1]) cube (10);
> mirror([1, 1, 1]) cube (10);





--
View this message in context: http://forum.openscad.org/Mirror-operator-tp20900p20921.html
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
|  
Report Content as Inappropriate

Re: Mirror operator

Antonio Bueno
In reply to this post by jim_klessig
Hi.

2017-03-15 2:01 GMT+01:00 jim_klessig <[hidden email]>:
[...] does make it a fairly useless operator imo.

I've lost count of the number of times mirror() has saved me time. So it doesn't imo :-)

In any case is almost trivial to get what you want. Just define you own function (mirror2?) and use it instead of mirror(). For example, I've used this many times:

module mirror2(v) {
  children();
  mirror(v) children();
}

hth :-)


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

Re: Mirror operator

thehans
In reply to this post by nophead
You could always just scale to -1

scale([-1,1,1]) text("redrum");

On Wed, Mar 15, 2017 at 10:43 AM, nop head <[hidden email]> wrote:

>
>>and does make it a fairly useless operator imo
>
> It creates a mirror image of an object. I don't think there is another way
> to do that except by using multmatrix (which can also do rotate, translate,
> scale, etc.) so it is useful for me. For example, to make left and right
> hand versions of brackets.
>
> On 15 March 2017 at 14:45, Parkinbot <[hidden email]> wrote:
>>
>> Ronaldo wrote
>> > But mirror() is as useful as rotate()
>>
>> besides the fact that it has really some funny implementation. Try this:
>>
>>
>> > mirror([0, .2, 0]) cube (10);
>> > mirror([1, .2, 0]) cube (10);
>> > mirror([1, 1, .1]) cube (10);
>> > mirror([1, 1, 1]) cube (10);
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://forum.openscad.org/Mirror-operator-tp20900p20921.html
>> 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
>

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

Re: Mirror operator

Peter Falke
This subject comes up every few years.
For a long time I thought the best way to deal with this is to add an option mirror(v,keep=fales/true).
In the hope that this will it make it easier for people to learn OpenSCAD and to have shorter code.



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

Re: Mirror operator

cacb
On 16. mars 2017 17:24, Peter Falke wrote:
> This subject comes up every few years.
> For a long time I thought the best way to deal with this is to add an
> option mirror(v,keep=fales/true).
> In the hope that this will it make it easier for people to learn
> OpenSCAD and to have shorter code.

I don't think so, it would solidify confusion unless you want to do the
same for translate, rotate, scale and mirror. And multmatrix too.

These are all just variants of the same thing: different ways of
expressing a transformation via a 4x4 homogeneous transformation matrix.
They all simply transform the object to which the transformation is
applied, no children left behind.

Carsten Arnholm


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

Re: Mirror operator

jim_klessig
I would disagree that it "solidifies confusion".

I think the confusion is inherent in the name "mirror".
Scale, rotate, and translate do not carry the same basic connotation (that "mirror" does) of "creating a copy".
To me "reflect" would have been less confusing. Far more confusing to this new user, was the combination of the words and the illustrations used in the example.




Sent from my U.S. Cellular® Smartphone

-------- Original message --------
From: "cacb [via OpenSCAD]" <[hidden email]>
Date: 3/16/17 11:59 AM (GMT-08:00)
To: jim_klessig <[hidden email]>
Subject: Re: Mirror operator

On 16. mars 2017 17:24, Peter Falke wrote:
> This subject comes up every few years.
> For a long time I thought the best way to deal with this is to add an
> option mirror(v,keep=fales/true).
> In the hope that this will it make it easier for people to learn
> OpenSCAD and to have shorter code.

I don't think so, it would solidify confusion unless you want to do the
same for translate, rotate, scale and mirror. And multmatrix too.

These are all just variants of the same thing: different ways of
expressing a transformation via a 4x4 homogeneous transformation matrix.
They all simply transform the object to which the transformation is
applied, no children left behind.

Carsten Arnholm


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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/Mirror-operator-tp20900p20936.html
To unsubscribe from Mirror operator, click here.
NAML
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mirror operator

louijp
I do not understand the confusion.
A real life mirror do not create two images. What you see is a mirror image, but you do not see the original object.

So why OpenSCAD should be different? you apply mirror() to an object, and you get the mirror image, not the original object. Nothing is wrong with that.

My $0.02,
Jean-Paul
N1JPL



> On Mar 16, 2017, at 7:19 PM, jim_klessig <[hidden email]> wrote:
>
> I would disagree that it "solidifies confusion".
>
> I think the confusion is inherent in the name "mirror".
> Scale, rotate, and translate do not carry the same basic connotation (that "mirror" does) of "creating a copy".
> To me "reflect" would have been less confusing. Far more confusing to this new user, was the combination of the words and the illustrations used in the example.
>
>
>
>
> Sent from my U.S. Cellular® Smartphone
>
> -------- Original message --------
> From: "cacb [via OpenSCAD]" <[hidden email]>
> Date: 3/16/17 11:59 AM (GMT-08:00)
> To: jim_klessig <[hidden email]>
> Subject: Re: Mirror operator
>
> On 16. mars 2017 17:24, Peter Falke wrote:
> > This subject comes up every few years.
> > For a long time I thought the best way to deal with this is to add an
> > option mirror(v,keep=fales/true).
> > In the hope that this will it make it easier for people to learn
> > OpenSCAD and to have shorter code.
>
> I don't think so, it would solidify confusion unless you want to do the
> same for translate, rotate, scale and mirror. And multmatrix too.
>
> These are all just variants of the same thing: different ways of
> expressing a transformation via a 4x4 homogeneous transformation matrix.
> They all simply transform the object to which the transformation is
> applied, no children left behind.
>
> Carsten Arnholm
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.openscad.org/Mirror-operator-tp20900p20936.html
> To unsubscribe from Mirror operator, click here.
> NAML
>
> View this message in context: Re: Mirror operator
> 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
|  
Report Content as Inappropriate

Re: Mirror operator

louijp
In reply to this post by jim_klessig
I do not understand the confusion.
A real life mirror do not create two images. What you see is a mirror image, but you do not see the original object.

So why OpenSCAD should be different? you apply mirror() to an object, and you get the mirror image, not the original object. Nothing is wrong with that.

My $0.02,
Jean-Paul
N1JPL



> On Mar 16, 2017, at 7:19 PM, jim_klessig <[hidden email]> wrote:
>
> I would disagree that it "solidifies confusion".
>
> I think the confusion is inherent in the name "mirror".
> Scale, rotate, and translate do not carry the same basic connotation (that "mirror" does) of "creating a copy".
> To me "reflect" would have been less confusing. Far more confusing to this new user, was the combination of the words and the illustrations used in the example.
>
>
>
>
> Sent from my U.S. Cellular® Smartphone
>
> -------- Original message --------
> From: "cacb [via OpenSCAD]" <[hidden email]>
> Date: 3/16/17 11:59 AM (GMT-08:00)
> To: jim_klessig <[hidden email]>
> Subject: Re: Mirror operator
>
> On 16. mars 2017 17:24, Peter Falke wrote:
> > This subject comes up every few years.
> > For a long time I thought the best way to deal with this is to add an
> > option mirror(v,keep=fales/true).
> > In the hope that this will it make it easier for people to learn
> > OpenSCAD and to have shorter code.
>
> I don't think so, it would solidify confusion unless you want to do the
> same for translate, rotate, scale and mirror. And multmatrix too.
>
> These are all just variants of the same thing: different ways of
> expressing a transformation via a 4x4 homogeneous transformation matrix.
> They all simply transform the object to which the transformation is
> applied, no children left behind.
>
> Carsten Arnholm
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://forum.openscad.org/Mirror-operator-tp20900p20936.html
> To unsubscribe from Mirror operator, click here.
> NAML
>
> View this message in context: Re: Mirror operator
> 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
|  
Report Content as Inappropriate

Re: Mirror operator

cacb
In reply to this post by jim_klessig
On 2017-03-17 00:19, jim_klessig wrote:
> I would disagree that it "solidifies confusion".
>
> I think the confusion is inherent in the name "mirror".
> Scale, rotate, and translate do not carry the same basic connotation
> (that "mirror" does) of "creating a copy".
> To me "reflect" would have been less confusing. Far more confusing to
> this new user, was the combination of the words and the illustrations
> used in the example.

The words translate, rotate, scale and mirror are universal terms in the
context of 3d transformations expressed as 4x4 homogeneous
transformation matrices, just look up any book on transformations in
computer graphics, CAD systems, or finite elements. OpenSCAD has simply
adopted the established nomenclature and interpretation. Applying a new
meaning to these terms would indeed cause more confusion.

Carsten Arnholm

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

Re: Mirror operator

jim_klessig
That argument doesn't quite fly for me. In most cad systems I have ever used, a mirror operation, creates a mirror imaged copy. In many cases with the option of deleting or keeping the original.

The mere fact that we are even having this discussion, illustrates that there EXISTS a "confusion", no matter what it's origination.



Sent from my U.S. Cellular® Smartphone

-------- Original message --------
From: "cacb [via OpenSCAD]" <[hidden email]>
Date: 3/17/17 12:01 AM (GMT-08:00)
To: jim_klessig <[hidden email]>
Subject: Re: Mirror operator

On 2017-03-17 00:19, jim_klessig wrote:
> I would disagree that it "solidifies confusion".
>
> I think the confusion is inherent in the name "mirror".
> Scale, rotate, and translate do not carry the same basic connotation
> (that "mirror" does) of "creating a copy".
> To me "reflect" would have been less confusing. Far more confusing to
> this new user, was the combination of the words and the illustrations
> used in the example.

The words translate, rotate, scale and mirror are universal terms in the
context of 3d transformations expressed as 4x4 homogeneous
transformation matrices, just look up any book on transformations in
computer graphics, CAD systems, or finite elements. OpenSCAD has simply
adopted the established nomenclature and interpretation. Applying a new
meaning to these terms would indeed cause more confusion.

Carsten Arnholm

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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/Mirror-operator-tp20900p20943.html
To unsubscribe from Mirror operator, click here.
NAML
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Mirror operator

Ronaldo
In reply to this post by Parkinbot
Parkinbot wrote
besides the fact that it has really some funny implementation.
Comming back to the utility of mirror. As a reflection, two subsequent mirrors are equivalent to a rotation:
// rotate children about x axis
module rotX(a)
    mirror([0,cos(a/2),sin(a/2)]) mirror([0,1,0]) children();
Although this usually have little interest, there are cases where the rotation angle computation may be avoided by using mirror. For instance when we need the minimum angle rotation that brings a direction d0 to a direction d1:

module rotFromTo(d0,d1)
    mirror(unit(d1)+unit(d0)) mirror(d0) children();
function unit(v) = v/norm(v);
This minimum angle rotation is part of the line definition in Drawing "lines" in OpenSCAD that could be rephrased as:
module line(p0, p1, diameter=1) {
    v = p1-p0;
    translate(p0)
        // rotate the cylinder so its z axis is brought to direction v
        rotFromTo([0,0,1],v))
            cylinder(d=diameter, h=norm(v), $fn=4);
}
However, thanks to the cylinder symmetries a simpler and more general polyline may use just one mirror:
module polyline(p,t=1) {
    for(i=[0:len(p)-2])
        translate(p[i+1])
        mirror([0,0,1]+unit(p[i+1]-p[i]))
        cylinder(r=t,h=norm(p[i+1]-p[i]));
}
n=500;
k=50;
spiral = [for(i=[0:n])
        [cos(-90+180*i/n)*cos(360*i/k), cos(-90+180*i/n)*sin(360*i/k),sin(-90+180*i/n)]];
polyline(20*spiral,t=1);

Don't try to render it!

Loading...