Contents



Learning Objectives

  • Understand the concept of rotation in 3D space and how it’s implemented in OpenSCAD.
  • Learn how to use the rotate command to rotate shapes around different axes.
  • Understand the significance of the right-hand rule in rotation and how rotation angles are determined.

Rotation in 3D Space

Rotation in OpenSCAD is controlled using the rotate command. This command rotates a shape around the origin (0,0,0) unless a translate command is used to move the shape away from the origin. The rotate command uses degrees for the rotation angles and follows the right-hand rule.

The syntax of the rotate command is as follows:

rotate([rotation_angle_x, rotation_angle_y, rotation_angle_z])

Here’s a simple example of how to rotate a cube around the x, y, and z-axes:

rotate([45, 30, 60]) cube(10);

In this case, the cube is rotated 45 degrees around the x-axis, 30 degrees around the y-axis, and 60 degrees around the z-axis.



Practice: Rotating Objects

Now let’s practice using the rotate command.

  1. Rotate a cylinder around the z-axis:

rotate([0, 0, 90]) cylinder(h=10, d=10);

In this case, the cylinder is rotated 90 degrees around the z-axis.

  1. Rotate a sphere around the y-axis:

rotate([0, 180, 0]) sphere(r=10);

Here, the sphere is rotated 180 degrees around the y-axis.

Remember, rotations are performed around the origin, so you may need to use translate to position your shape correctly after rotation.




Learning About the Right Hand Rule

You might be wondering, “How do I know which way something will rotate in OpenSCAD?” Well, we have a handy (pun intended) trick called the Right Hand Rule.

Let’s break it down:

  1. What’s the Right Hand Rule? It’s like a secret code to figure out which way something will spin when we rotate it in 3D space. The cool thing is you only need your right hand to figure it out!

  2. How does it work?
    • Pretend you’re holding an invisible pencil in your right hand. This pencil is like an invisible spinning stick (we call it an “axis”) around which our shape spins.
    • Point your thumb in the direction of the axis (for example, if the axis is ‘X’, point your thumb to your right).
    • When you make a fist, the way your fingers curl is the way your shape will rotate.
  3. Let’s apply this to OpenSCAD:
    • X-axis: Point your thumb to the right (that’s the positive X direction). Your fingers curl from towards you (Y-axis) to upwards (Z-axis). This means when we rotate something around the X-axis, it goes from Y to Z.
    • Y-axis: Point your thumb towards you (that’s the positive Y direction). Your fingers curl from upwards (Z-axis) to the right (X-axis). So when we rotate around the Y-axis, it goes from Z to X.
    • Z-axis: Point your thumb upwards (that’s the positive Z direction). Your fingers curl from the right (X-axis) to towards you (Y-axis). So when we rotate around the Z-axis, it goes from X to Y.

That’s it! Now when you use a command like rotate([45,0,0]) in OpenSCAD, you know it means to spin your shape 45 degrees around the X-axis, just like your fingers showed you.
It might seem tricky at first, but with a little practice, you’ll be a pro at the Right Hand Rule in no time. This will make creating 3D models even more fun!


Review

In addition to what you learned previously, this lesson also taught you:

  • How to rotate objects in OpenSCAD using the rotate command.
  • How rotation angles work and the significance of the right-hand rule.
  • How to use the rotate command in conjunction with other commands like translate.


Resources