This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Rotations of 2D objects

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.


plot::Rotate2d(angle, <[cx, cy]>, obj1, <obj2, …>, <a = amin .. amax>, options)


plot::Rotate2d(angle, [cx, cy], object) rotates a 2D object counterclockwise by the given angle around the rotation center [cx, cy]. To rotate clock wise, use negative angles.

Rotate objects can rotate several graphical objects simultaneously. Plotting the rotate object renders all graphical objects inside.

Rotated objects have a tendency to overestimate their ViewingBox. See the help page of ViewingBox. In such cases, specify a suitable ViewingBox explicitly.

Transformation objects can be used inside rotate objects. If they are animated, the animations run simultaneously.

Animated rotate objects are rather "cheap" concerning computing and storing costs. For more complex graphical objects, it is more efficient to use an animated rotate object than to redefine the object for each frame.

The function op allows to extract the graphical objects inside a rotate object.


AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Anglerotation angle0
Centercenter of objects, rotation center[0, 0]
CenterXcenter of objects, rotation center, x-component0
CenterYcenter of objects, rotation center, y-component0
Framesthe number of frames in an animation50
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0


Example 1

Ellipses of type plot::Ellipse2d have symmetry axes parallel to the coordinate axes. You can use plot::Rotate2d to obtain ellipses with other orientations:

e0 := plot::Ellipse2d(3, 1, [0, 0]):
e1 :=  plot::Rotate2d(PI/4, [0, 0], e0):
e2 :=  plot::Rotate2d(-PI/4, [0, 0], e0):
plot(e0, e1, e2):

delete e0, e1, e2

Example 2

Plot several copies of a function plot, rotated by 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

Plot turning cogs. Each animated rotate object rotates a curve and a line simultaneously:

r1 := 2: x1 := -r1: y1:= 0:
r2 := 1: x2 :=  r2: y2:= 0:
dr := 0.2:
cog1 := plot::Curve2d([x1 + (r1 + dr*cos(36*u))*cos(u), 
                       y1 + (r1 + dr*cos(36*u))*sin(u)],
                      u = 0..2*PI, Mesh = 360):
cog2 := plot::Curve2d([x2 + (r2 - dr*cos(18*u))*cos(u), 
                       y2 + (r2 - dr*cos(18*u))*sin(u)],
                       u = 0..2*PI, Mesh = 360):
line1 :=  plot::Line2d([x1, y1], [x1 + r1 + dr, y1],
                       Color = RGB::Red):
line2 :=  plot::Line2d([x2, y2], [x2 - r2 + dr, y2],
                       Color = RGB::Red):
Cog1 := plot::Rotate2d(-a, [x1,  y1], cog1, line1, 
                       a = 0..2*PI, Frames = 180):
Cog2 := plot::Rotate2d(2*a, [x2, y2], cog2, line2,
                       a = 0..2*PI, Frames = 180):
plot(Cog1, Cog2, Scaling = Constrained):

delete r1, x1, y1, r2, x2, y2, dr, cog1, cog2, 
       line1, line2, Cog1, Cog2:

Example 4

Use an animated rotation inside another animated rotation:

L1 := plot::Line2d([0, 0], [0, 1]):
L2 := plot::Rotate2d(a, [0, 1], a = 0..2*PI,
                     plot::Line2d([0, 1], [1, 1])):
plot(plot::Rotate2d(a, [0, 0], L1, L2, a = 0..PI/2)):

delete L1, L2:



The rotation angle in radians: a numerical real value or an arithmetical expression of the animation parameter a.

angle is equivalent to the attribute Angle.

cx, cy

The components of the rotation center: numerical real values or arithmetical expressions of the animation parameter a. If no rotation center is specified, the center [0, 0] is used.

cx, cy are equivalent to the attributes Center, CenterX, CenterY.

obj1, obj2, …

Arbitrary plot objects of the appropriate dimension


Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

Was this topic helpful?