MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
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.
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:
a plot showing the rotated rectangle together with the unrotated one:
delete r0, r1:
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):
The rotation angle can be animated. We use an animated
to rotate a square around a center that moves along a circle around
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:
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)
delete b0, b1:
arc:= [3, 1], [0, 0], -PI/4..PI/4, Filled: plot( 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))