Documentation Center

  • Trial Software
  • Product Updates


Rotation angle

Value Summary

OptionalMuPAD® expression

Graphics Primitives

ObjectsAngle Default Values
plot::Arc2d, plot::Arc3d, plot::Prism, plot::Pyramid, plot::Rotate2d, plot::Rotate3d0


Angle determines the rotation angle in transformation objects of type plot::Rotate2d and plot::Rotate3d, respectively, and other graphical objects. The angle has to be specified in radians.

In 2D, the direction of the rotation is counter clock wise. Use negative angles to rotate clock wise.

In 3D, the rotation is implemented following the "right hand rule": Stretch the thumb of your right hand and bend the fingers. When the thumb points into the direction of the rotation axis, your finger tips indicate the direction of the rotation. Use negative angles to rotate in the opposite direction.


Example 1

Rectangles of type plot::Rectangle are always parallel to the coordinate axes. To have one with a different orientation, we must rotate it:

r0 := plot::Rectangle(0..2, 1..3):
r1 := plot::Rotate2d(r0, Center = [1, 2], Angle = PI/6)

As you can see in the output above, the rotate object contains the rotated object and acts as a grouping construct. This means that we only need to plot r1 to see the rotated object:


Plotting both r0 and r1 yields a plot showing the rotated rectangle together with the unrotated one:

plot(r0, r1)

delete r0, r1:

Example 2

Using plot::Rotate2d, we plot several copies of a function plot, rotated at different angles:

f := plot::Function2d(sin(x^3)/(x^2+1), x = -5..5, Mesh = 300):
plot(plot::Rotate2d(f, Angle = PI/11*a) $ a = 0..10):

delete f:

Example 3

The rotation angle can be animated. We use an animated plot::Rotate2d object to rotate a square around a center that moves along a circle around the origin:

p := plot::Point2d([cos(a), sin(a)], a = 0..2*PI,
                   Frames = 100):
r := plot::Rotate2d(plot::Rectangle(0..2, -1..1), Angle = a,
                    Center = [0, 0], a = 0..2*PI):
q := plot::Rotate2d(r, Angle = 4*a, Center = [cos(a), sin(a)],
                    a = 0..2*PI, Frames = 200):
plot(p, q)

delete p, r, q:

Example 4

This is the 3D analogue of Example 1. Boxes of type plot::Box are always parallel to the coordinate axes. To have one with a different orientation, we must rotate it:

b0 := plot::Box(0..2, 1..3, 2..3):
b1 := plot::Rotate3d(b0, Center = [1, 2, 2.5],
                     Axis = [1, 1, 1], Angle = PI/5)

plot(b0, b1)

delete b0, b1:

Example 5

Some graphic objects, e.g. plot::Arc2d and plot::Pyramid, also accept a rotation angle:

arc:= [3, 1], [0, 0], -PI/4..PI/4, Filled:
  plot::Arc2d(arc, Angle=0,      FillColor=RGB::Red),
  plot::Arc2d(arc, Angle=1/2*PI, FillColor=RGB::Green),
  plot::Arc2d(arc, Angle=PI,     FillColor=RGB::Yellow),
  plot::Arc2d(arc, Angle=3/2*PI, FillColor=RGB::Blue)

plot(plot::Pyramid(1/2, Angle=0),
     plot::Pyramid(1/2, Angle=PI/4, FillColor2=RGB::Yellow))

delete arc:

See Also

MuPAD Functions

Was this topic helpful?