rotateX()

Rotates in 3D around the x-axis

Example

Syntax

rotateX(angle)
InputDescription

angle

angle of rotation

Full Example

Example Full Code
def setup():
  createCanvas(300,300, WEBGL)

def draw():
  background(255, 79, 132)
  fill(112, 88, 255)
  stroke(176, 235, 51)
  strokeWeight(2)
  orbitControl()
  # draw3DAxes(100, (100, 50, 20))
  rotateX(frameCount)
  torus(100, 25)
  rotateX(-2*frameCount)
  cone(50, 50)

Description

Rotates a shape around x-axis by the amount specified in angle parameter. The angles can be entered in either RADIANS or DEGREES, depending on the specified angleMode().

Positive angles rotates the space from +z to +y regardless of handedness.

Why is this the direction of rotation?

The reason is hidden in the mathematical convention of setting up axes such that:

  • if one extends his fingers of your Right Hand in the +x direction

  • then curls his fingers into +y direction

  • his thumb points into the +z direction

This is called the Right Hand Convention (as if you did it with your left hand, it would fail! it would give the opposite direction). We can write this convention as +x => +y => +z.

Extending the sequence with the same order +x => +y => +z => +x => +y gives us the convention for rotations about the x-axis and the y-axis as well:

  • about x-axis: +y => +z => +x

  • about y-axis: +z => +x => +y

Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!

We'd love to hear your Feedback/Comments here.

Last updated