discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Problem with order of multiple translate and rotation

B
billbob123
Fri, Nov 13, 2015 3:46 PM

The code below produces cubes in three different positions. To the best of my
understanding, it shouldn't.  All rotations and translations apply to the
object in it's original position at 0,0,0, so the order of these operations
shouldn't matter. Can anyone please point out what  I missed/misunderstood?

rotate ([0,0,90]) translate([800,0,0]) translate([500,0,0])
cube(400,30,100, center=true);

translate([800,0,0]) rotate ([0,0,90]) translate([500,0,0])
cube(400,30,100, center=true);

translate([800,0,0]) translate([500,0,0]) rotate ([0,0,90])
cube(400,30,100, center=true);

--
View this message in context: http://forum.openscad.org/Problem-with-order-of-multiple-translate-and-rotation-tp14447.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The code below produces cubes in three different positions. To the best of my understanding, it shouldn't. All rotations and translations apply to the object in it's original position at 0,0,0, so the order of these operations shouldn't matter. Can anyone please point out what I missed/misunderstood? rotate ([0,0,90]) translate([800,0,0]) translate([500,0,0]) cube(400,30,100, center=true); translate([800,0,0]) rotate ([0,0,90]) translate([500,0,0]) cube(400,30,100, center=true); translate([800,0,0]) translate([500,0,0]) rotate ([0,0,90]) cube(400,30,100, center=true); -- View this message in context: http://forum.openscad.org/Problem-with-order-of-multiple-translate-and-rotation-tp14447.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
clothbot
Fri, Nov 13, 2015 4:46 PM

billbob123 wrote

The code below produces cubes in three different positions. To the best of
my understanding, it shouldn't.  All rotations and translations apply to
the object in it's original position at 0,0,0, so the order of these
operations shouldn't matter. Can anyone please point out what  I
missed/misunderstood?

rotate ([0,0,90]) translate([800,0,0]) translate([500,0,0])
cube(400,30,100, center=true);

translate([800,0,0]) rotate ([0,0,90]) translate([500,0,0])
cube(400,30,100, center=true);

translate([800,0,0]) translate([500,0,0]) rotate ([0,0,90])
cube(400,30,100, center=true);

Take a step back and think of each one of these operations as linear
algebra, matrix multiplications.

R1 * T1 * T2

...is different from...

T1 * R1 * T2

...which is also different from...

T1 * T2 * R1

They are only equivalent in trivial cases, e.g. when one is an identity
matrix and the other two are their inverse.

Andrew.

--
View this message in context: http://forum.openscad.org/Problem-with-order-of-multiple-translate-and-rotation-tp14447p14451.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

billbob123 wrote > The code below produces cubes in three different positions. To the best of > my understanding, it shouldn't. All rotations and translations apply to > the object in it's original position at 0,0,0, so the order of these > operations shouldn't matter. Can anyone please point out what I > missed/misunderstood? > > rotate ([0,0,90]) translate([800,0,0]) translate([500,0,0]) > cube(400,30,100, center=true); > > translate([800,0,0]) rotate ([0,0,90]) translate([500,0,0]) > cube(400,30,100, center=true); > > translate([800,0,0]) translate([500,0,0]) rotate ([0,0,90]) > cube(400,30,100, center=true); Take a step back and think of each one of these operations as linear algebra, matrix multiplications. R1 * T1 * T2 ...is different from... T1 * R1 * T2 ...which is also different from... T1 * T2 * R1 They are only equivalent in trivial cases, e.g. when one is an identity matrix and the other two are their inverse. Andrew. -- View this message in context: http://forum.openscad.org/Problem-with-order-of-multiple-translate-and-rotation-tp14447p14451.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DM
doug moen
Fri, Nov 13, 2015 4:48 PM

If there was no rotate, then the order of the translates would not matter.

If the effect of rotate was to rotate the cube around its centre,
regardless of its position, then your intuition would be correct. But
that's not what rotate does.

"Rotate()" rotates the entire arena of objects around the origin at
(0,0,0). So the effect of rotate on each object in the arena depends on the
objects position within the arena.

On Friday, 13 November 2015, billbob123 robert.heath16@gmail.com wrote:

The code below produces cubes in three different positions. To the best of
my
understanding, it shouldn't.  All rotations and translations apply to the
object in it's original position at 0,0,0, so the order of these operations
shouldn't matter. Can anyone please point out what  I missed/misunderstood?

rotate ([0,0,90]) translate([800,0,0]) translate([500,0,0])
cube(400,30,100, center=true);

translate([800,0,0]) rotate ([0,0,90]) translate([500,0,0])
cube(400,30,100, center=true);

translate([800,0,0]) translate([500,0,0]) rotate ([0,0,90])
cube(400,30,100, center=true);

--
View this message in context:
http://forum.openscad.org/Problem-with-order-of-multiple-translate-and-rotation-tp14447.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

If there was no rotate, then the order of the translates would not matter. If the effect of rotate was to rotate the cube around its centre, regardless of its position, then your intuition would be correct. But that's not what rotate does. "Rotate()" rotates the entire arena of objects around the origin at (0,0,0). So the effect of rotate on each object in the arena depends on the objects position within the arena. On Friday, 13 November 2015, billbob123 <robert.heath16@gmail.com> wrote: > The code below produces cubes in three different positions. To the best of > my > understanding, it shouldn't. All rotations and translations apply to the > object in it's original position at 0,0,0, so the order of these operations > shouldn't matter. Can anyone please point out what I missed/misunderstood? > > rotate ([0,0,90]) translate([800,0,0]) translate([500,0,0]) > cube(400,30,100, center=true); > > translate([800,0,0]) rotate ([0,0,90]) translate([500,0,0]) > cube(400,30,100, center=true); > > translate([800,0,0]) translate([500,0,0]) rotate ([0,0,90]) > cube(400,30,100, center=true); > > > > -- > View this message in context: > http://forum.openscad.org/Problem-with-order-of-multiple-translate-and-rotation-tp14447.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <javascript:;> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > >