FYI: rotation, and teaching others about it

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

FYI: rotation, and teaching others about it

jdawgaz
I have been teaching openscad to a mix of people (my amateur radio buddies), and some have had a little experience in programming (like basic), others have had fairly extensive programming experience, and others have absolutely none.

I started talking about rotation, and got them thoroughly confused. It is not an easy concept, even when you are a programmer.

So, I came up with the following script which I hope will help alleviate the visualization of what rotate does.

Just wanted to share this.

Jerry

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([-0.5,-0.5,0.75]) text(t, size=1);
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("N", "Blue");
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("U", "Magenta");
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("S", "MediumSpringGreen");
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("E", "PeachPuff");
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("W", "Olive");
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("D", "LightSteelBlue");
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();


=========== end of script ============

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson


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

Re: FYI: rotation, and teaching others about it

Hypher
Jerry,

I think this is really useful for beginners, but one thing concerns me, which is the use of cardinal directions to represent the axes which already have names. Additionally, the axes already have colors in OpenSCAD as well (X=Red, Y=Green, Z=Blue). By changing both the names and colors of the axes, I think it actually may make it more confusing when trying to relate what's going on with the very-helpful axes visualizer in the preview pane, as well as with the rotation vector. Which number rotates around the NS axis, for instance?

Here is a version which names the directions using +X, -X, etc, and uses the already-defined colors, with a brighter color for positive and darker color for negative. I think this has a similar useful effect, but uses visual "terms" already established in OpenScad (and many other 3d programs).

As an aside, the text() module takes the very handle halign and valign parameters, which are an easier way of centering text than using manual offsets.

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([0,-0,0.75]) text(t, size=1, halign="center", valign="center");
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
 
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("+X", [1,0,0]);
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("-X", [.5,0,0]);
 
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("+Y", [0,1,0]);
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("-Y", [0,.5,0]);
   
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("+Z", [0,0,1]);
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("-Z", [0,0,.5]);
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();

=========== end of script ============


Best,

~ Yona
November 20, 2015 at 07:19
I have been teaching openscad to a mix of people (my amateur radio buddies), and some have had a little experience in programming (like basic), others have had fairly extensive programming experience, and others have absolutely none.

I started talking about rotation, and got them thoroughly confused. It is not an easy concept, even when you are a programmer.

So, I came up with the following script which I hope will help alleviate the visualization of what rotate does.

Just wanted to share this.

Jerry

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([-0.5,-0.5,0.75]) text(t, size=1);
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("N", "Blue");
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("U", "Magenta");
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("S", "MediumSpringGreen");
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("E", "PeachPuff");
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("W", "Olive");
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("D", "LightSteelBlue");
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();


=========== end of script ============

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson

_______________________________________________
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
|

Re: FYI: rotation, and teaching others about it

jdawgaz
thanks, let me put it in and see what I get.
Forgot about the halign, and valign. Should've thought of that.



--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson


On Fri, Nov 20, 2015 at 1:08 PM, Yona Appletree <[hidden email]> wrote:
Jerry,

I think this is really useful for beginners, but one thing concerns me, which is the use of cardinal directions to represent the axes which already have names. Additionally, the axes already have colors in OpenSCAD as well (X=Red, Y=Green, Z=Blue). By changing both the names and colors of the axes, I think it actually may make it more confusing when trying to relate what's going on with the very-helpful axes visualizer in the preview pane, as well as with the rotation vector. Which number rotates around the NS axis, for instance?

Here is a version which names the directions using +X, -X, etc, and uses the already-defined colors, with a brighter color for positive and darker color for negative. I think this has a similar useful effect, but uses visual "terms" already established in OpenScad (and many other 3d programs).

As an aside, the text() module takes the very handle halign and valign parameters, which are an easier way of centering text than using manual offsets.

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([0,-0,0.75]) text(t, size=1, halign="center", valign="center");
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
 
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("+X", [1,0,0]);
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("-X", [.5,0,0]);
 
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("+Y", [0,1,0]);
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("-Y", [0,.5,0]);
   
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("+Z", [0,0,1]);
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("-Z", [0,0,.5]);
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();

=========== end of script ============


Best,

~ Yona
November 20, 2015 at 07:19
I have been teaching openscad to a mix of people (my amateur radio buddies), and some have had a little experience in programming (like basic), others have had fairly extensive programming experience, and others have absolutely none.

I started talking about rotation, and got them thoroughly confused. It is not an easy concept, even when you are a programmer.

So, I came up with the following script which I hope will help alleviate the visualization of what rotate does.

Just wanted to share this.

Jerry

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([-0.5,-0.5,0.75]) text(t, size=1);
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("N", "Blue");
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("U", "Magenta");
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("S", "MediumSpringGreen");
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("E", "PeachPuff");
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("W", "Olive");
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("D", "LightSteelBlue");
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();


=========== end of script ============

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson

_______________________________________________
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
|

Re: FYI: rotation, and teaching others about it

jdawgaz
looks really good.
except: the -X line came out X-
so I changed it to:
translate([-3,0,0]) rotate([90,0,0]) rotate([0,-90,0]) textcube("-X", [.5,0,0]);


--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson


On Fri, Nov 20, 2015 at 1:19 PM, Jerry Davis <[hidden email]> wrote:
thanks, let me put it in and see what I get.
Forgot about the halign, and valign. Should've thought of that.



--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson


On Fri, Nov 20, 2015 at 1:08 PM, Yona Appletree <[hidden email]> wrote:
Jerry,

I think this is really useful for beginners, but one thing concerns me, which is the use of cardinal directions to represent the axes which already have names. Additionally, the axes already have colors in OpenSCAD as well (X=Red, Y=Green, Z=Blue). By changing both the names and colors of the axes, I think it actually may make it more confusing when trying to relate what's going on with the very-helpful axes visualizer in the preview pane, as well as with the rotation vector. Which number rotates around the NS axis, for instance?

Here is a version which names the directions using +X, -X, etc, and uses the already-defined colors, with a brighter color for positive and darker color for negative. I think this has a similar useful effect, but uses visual "terms" already established in OpenScad (and many other 3d programs).

As an aside, the text() module takes the very handle halign and valign parameters, which are an easier way of centering text than using manual offsets.

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([0,-0,0.75]) text(t, size=1, halign="center", valign="center");
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
 
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("+X", [1,0,0]);
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("-X", [.5,0,0]);
 
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("+Y", [0,1,0]);
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("-Y", [0,.5,0]);
   
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("+Z", [0,0,1]);
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("-Z", [0,0,.5]);
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();

=========== end of script ============


Best,

~ Yona
November 20, 2015 at 07:19
I have been teaching openscad to a mix of people (my amateur radio buddies), and some have had a little experience in programming (like basic), others have had fairly extensive programming experience, and others have absolutely none.

I started talking about rotation, and got them thoroughly confused. It is not an easy concept, even when you are a programmer.

So, I came up with the following script which I hope will help alleviate the visualization of what rotate does.

Just wanted to share this.

Jerry

============== script ==============

$fn = 300;

module textcube(t, c) {
  // t = text, c = color
  color(c) cube(2, center=true);
  translate([-0.5,-0.5,0.75]) text(t, size=1);
}

// make a part, that has n,s,e,w, up, down obvious orientations.
module part() {
  cylinder(h=5,r=3, center=true);
  translate([3,0,0]) rotate([90,0,0]) rotate([0,90,0]) textcube("N", "Blue");
  translate([0,0,3]) rotate([0,0,0]) rotate([0,0,0]) textcube("U", "Magenta");
  translate([-3,0,0]) rotate([-90,0,0]) rotate([0,-90,0]) textcube("S", "MediumSpringGreen");
  translate([0,-3,0]) rotate([0,0,0]) rotate([90,0,0]) textcube("E", "PeachPuff");
  translate([0,3,0]) rotate([0,180,0]) rotate([-90,0,0]) textcube("W", "Olive");
  translate([0,0,-3]) rotate([180,0,0]) rotate([0,0,0]) textcube("D", "LightSteelBlue");
}

// alternately change the values for the rotate transformation
// to see what happens to our part. I suggest values of 90, and -90
// for the various values.
// for instance, see what rotate([0,0,0]) does (which doesn't rotate at all, obviously)
// then change it to 90 in the x direction (rotate([90,0,0]).
// what happens to our part then?
// change it back to 0, then back to 90 several times until you can visualize what is happening
// then try 90 in the y direction, etc.
// later try doing in the 90 degrees in both the x and y directions?
// what happens?

rotate([0,0,0]) part();


=========== end of script ============

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime. 
- Anonymous

If writing good code requires very little comments, then writing really excellent code requires no comments at all!
- Ken Thompson

_______________________________________________
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
|

Re: FYI: rotation, and teaching others about it

minuti
In reply to this post by jdawgaz
Another nice trick for explaining rotation: the right-hand rule!

Curious about which way "rotation about the X axis" will make it go? Point your right thumb along the X axis, towards the +X direction, with your hand loosely open. Now look at which way your fingers are curling, they're pointing in the direction of the rotation. Ta-dah!

For rotation about multiple axes, it's the rotation about X, then about Y, then about Z.

And applying the right-hand rule to this might just make some of your radio buddies happy :)