discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] geometrically confused

B
Bananapeel
Sun, Dec 7, 2014 11:21 PM

Rotation is a really difficult issue. The part is rotated around the axis,
not around its own center. So you get different results depending on whether
you translate it before or after rotating. To rotate a part around its own
center, it needs to be placed with its center at 0 on the axes that you want
to rotate around.

rotate([0,20,0])  {
color("red")
translate([-3,0,0])
cube([3,3,3]);

translate([0, 6, 0])
cube([3,3,3]);

}

One cube appears to be rotated "up" (red) and the other "down" even though
both were rotated 20*. The difference lies in their initial positions. Be
very observant about where your parts are created, even before you start
translating/rotating.

Rotation is like tying a string from each of the vertices and to the axis
that you are rotating about, then moving the vertices by x degrees.

The direction of rotation is also difficult to predict. I don't use the
right hand rule. Instead I imagine a protractor centered at [0,0,0]. Rotate
the view so that you are "standing" on the POSITIVE side of the axis you are
rotating around and looking towards zero. Imagine (you don't have to imagine
it, as I drew it for us in the code below - I'm definetely saving this for
future use!) the full circle of 360 degrees. If you have an object placed at
120 and rotate it 30 degrees around the x axis it should end up at 150.

module protractor(c) {
color(c)
for (i=[0:30:359]) {
rotate([i, 0, 0])
translate([0, 100, 0])
rotate([0,90,0])
linear_extrude(height=1)
text(str(i));

    rotate([i,0,0])
    translate([0, 0, 10])
    cylinder(h=90, r=0.5);
}

}

// rotate around the x axis
protractor("red");

// rotate around the y axis
//rotate([0,0,90])
//protractor("chartreuse");

// rotate around the z axis
//rotate([0, 90, 0])
//protractor("blue");

I hope this helps!

Regards,
Bananapeel :)

--
View this message in context: http://forum.openscad.org/geometrically-confused-tp10421p10424.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Rotation is a really difficult issue. The part is rotated around the axis, not around its own center. So you get different results depending on whether you translate it before or after rotating. To rotate a part around its own center, it needs to be placed with its center at 0 on the axes that you want to rotate around. rotate([0,20,0]) { color("red") translate([-3,0,0]) cube([3,3,3]); translate([0, 6, 0]) cube([3,3,3]); } One cube appears to be rotated "up" (red) and the other "down" even though both were rotated 20*. The difference lies in their initial positions. Be very observant about where your parts are created, even before you start translating/rotating. Rotation is like tying a string from each of the vertices and to the axis that you are rotating about, then moving the vertices by x degrees. The direction of rotation is also difficult to predict. I don't use the right hand rule. Instead I imagine a protractor centered at [0,0,0]. Rotate the view so that you are "standing" on the POSITIVE side of the axis you are rotating around and looking towards zero. Imagine (you don't have to imagine it, as I drew it for us in the code below - I'm definetely saving this for future use!) the full circle of 360 degrees. If you have an object placed at 120 and rotate it 30 degrees around the x axis it should end up at 150. module protractor(c) { color(c) for (i=[0:30:359]) { rotate([i, 0, 0]) translate([0, 100, 0]) rotate([0,90,0]) linear_extrude(height=1) text(str(i)); rotate([i,0,0]) translate([0, 0, 10]) cylinder(h=90, r=0.5); } } // rotate around the x axis protractor("red"); // rotate around the y axis //rotate([0,0,90]) //protractor("chartreuse"); // rotate around the z axis //rotate([0, 90, 0]) //protractor("blue"); I hope this helps! Regards, Bananapeel :) -- View this message in context: http://forum.openscad.org/geometrically-confused-tp10421p10424.html Sent from the OpenSCAD mailing list archive at Nabble.com.