Quantcast

Documentation Center

  • Trial Software
  • Product Updates

plot::Rotate3d

Rotations of 3D objects

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::Rotate3d(angle, <[cx, cy, cz], [dx, dy, dz]>, obj1, <obj2, …>, <a = amin .. amax>, options)

Description

plot::Rotate3d(angle, [cx, cy, cz], [dx, dy, dz], object) rotates a 3D object by the given angle around the rotation axis defined by the point [cx, cy, cz] and the direction [dx, dy, dz].

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.

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. Cf. the help page of ViewingBox. In such a case, you should 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.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Anglerotation angle0
Axisrotation axis[0, 0, 1]
AxisXx-component of rotation axis0
AxisYy-component of rotation axis0
AxisZz-component of rotation axis1
Centercenter of objects, rotation center[0, 0, 0]
CenterXcenter of objects, rotation center, x-component0
CenterYcenter of objects, rotation center, y-component0
CenterZcenter of objects, rotation center, z-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

Examples

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):

Similarly, 3D boxes with arbitrary orientation can be generated via plot::Rotate3d. We use several animated rotation objects:

b0 := plot::Box(-3..3, -2..2, -1..1):
b1 :=  plot::Rotate3d(a, [0, 0, 0], [0, 0, 1], b0, 
                      a = 0..PI/2, TimeRange = 0..3):
b2 :=  plot::Rotate3d(a, [0, 0, 0], [0, 1, 0], b1, 
                      a = 0..PI/2, TimeRange = 3..6):
b3 :=  plot::Rotate3d(a, [0, 0, 0], [1, 0, 0], b2, 
                      a = 0..PI/2, TimeRange = 6..9):
plot(b0, b3):

delete e0, e1, e2, b0, b1, b2, b3:

Example 2

We 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

We 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

We 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:

Parameters

angle

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, cz

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, 0] is used.

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

dx, dy, dz

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

dx, dy, dz are equivalent to the attributes Axis, AxisX, AxisY, AxisZ.

obj1, obj2, …

Arbitrary plot objects of the appropriate dimension

a

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

See Also

MuPAD Functions

MuPAD Graphical Primitives

Was this topic helpful?