Documentation Center

  • Trial Software
  • Product Updates

plot::Curve2d

Parameterized 2D curves

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::Curve2d([x, y], t = tmin .. tmax, <a = amin .. amax>, options)
plot::Curve2d(A2d, t = tmin .. tmax, <a = amin .. amax>, options)
plot::Curve2d(piecewiseF(t), t = tmin .. tmax, <a = amin .. amax>, options)

Description

plot::Curve2d([x(t), y(t)], t = tmin.. tmax) creates the planar curve

.

plot::Curve2d and plot::Curve3d construct curves in one parameter (see Example 1), possibly animated (see Example 2). The curves may contain poles, in which case automatic clipping is used by default (see Example 4).

By default, curves are sampled at equidistant values of the parameter t. The attribute AdaptiveMesh can be used to change this behavior, such that a denser sampling rate is used in areas of higher curvature. Cf. Example 5.

Curves are graphical objects that can be manipulated, see the examples and the documentation of the parameters listed below for details.

Attributes

AttributePurposeDefault Value
AdaptiveMeshadaptive sampling0
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
AntiAliasedantialiased lines and points?TRUE
Colorthe main colorRGB::Blue
DiscontinuitySearchsemi-symbolic search for discontinuitiesTRUE
Framesthe number of frames in an animation50
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?TRUE
LineColorcolor of linesRGB::Blue
LineWidthwidth of lines0.35
LineColor2color of linesRGB::DeepPink
LineStylesolid, dashed or dotted lines?Solid
LinesVisiblevisibility of linesTRUE
LineColorTypeline coloring typesFlat
LineColorFunctionfunctional line coloring 
LineColorDirectionthe direction of color transitions on lines[0, 1]
LineColorDirectionXx-component of the direction of color transitions on lines0
LineColorDirectionYy-component of the direction of color transitions on lines1
Meshnumber of sample points121
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 
PointSizethe size of points1.5
PointStylethe presentation style of pointsFilledCircles
PointsVisiblevisibility of mesh pointsFALSE
Submeshdensity of submesh (additional sample points)0
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
UMaxfinal value of parameter "u"5
UMeshnumber of sample points for parameter "u"121
UMininitial value of parameter "u"-5
UNamename of parameter "u" 
URangerange of parameter "u"-5 .. 5
USubmeshdensity of additional sample points for parameter "u"0
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE
XFunctionfunction for x values 
YFunctionfunction for y values 

Examples

Example 1

Archimedes' Spiral is defined by f(r) = (rsin(r), rcos(r)). The corresponding call to plot::Curve2d reads:

curve := plot::Curve2d([r*sin(r), r*cos(r)], r = 0..35)

plot(curve)

Note that this particular example is even more straightforward to plot using plot::Polar.

Example 2

Continuing the example from above, we define an easy animation by making the angular part time-dependent:

curve := plot::Curve2d([r*sin(r-t), r*cos(r-t)],
                       r = 0..35, t = 0..2*PI,
                       TimeEnd = 5,
                       ViewingBox = [-25..25, -25..25]):
plot(curve)

Note that to start the animation, you have to double-click the image in the notebook and choose "Start" from the "Animation" menu.

Example 3

Another useful and easy type of animation is achieved by animating the parameter range. This creates the illusion of the curve being drawn in real time:

curve := plot::Curve2d([sin(thet), cos(thet)],
                       thet = 0..a,
                       a = 0..2*PI):
plot(curve)

curve := plot::Curve3d([sin(thet)*cos(20*thet),
                        sin(thet)*sin(20*thet),
                        cos(thet)],
                       thet = 0..a,
                       a = 0..PI):
plot(curve)

Combining this with an animated LineColorFunction, you can even simulate motion:

colorfunc := (thet, x, y, a) -> [a-thet, a-thet, 1.0]:
curve := plot::Curve2d([sin(3*thet), sin(4*thet)],
                       thet = a-1..a,
                       LineColorFunction = colorfunc,
                       LineWidth = 1,
                       a = 0..2*PI):
plot(curve)

Example 4

Curves with poles are automatically clipped:

curve := plot::Curve2d([(1+tan(3*t)^2)*sin(t),
                        (1+tan(3*t)^2)*cos(t)],
                       t = 0..2*PI):
plot(curve);

If the automatically chosen viewing box is not to your liking, you can explicitly set other values:

curve::ViewingBox := [-2..2, -2..2]:
plot(curve)

Example 5

By default, curves are drawn by evaluating at equidistant values of the curve parameter. For curves that have few regions of high curvature, this may be inappropriate:

plot(plot::Curve2d([arctan(t), t^2-10*exp(-50*t^2)],
                   t = -PI..PI))

Note the hard "kink" at the bottom of the picture. On the other hand, the remainder of the curve is sufficiently smooth, so globally increasing the number of evaluation points is not desirable. AdaptiveMesh makes plot::Curve2d look for these kinks and adaptively increase the mesh density in problematic areas:

plot(plot::Curve2d([arctan(t), t^2-10*exp(-50*t^2)],
                   t = -PI..PI, AdaptiveMesh = 2))

Example 6

To display a curve in the complex plane, map the list-valued function [Re, Im] to the curve:

plot(plot::Curve2d([Re, Im](zeta(I*y+1/2)), y=0..42,
                   AdaptiveMesh=3),
     XAxisTitle = "Re(z)", YAxisTitle = "Im(z)")

Example 7

Create the following piecewise function:

f := piecewise([t < 0, [t, sin(10*t)^2, t^3]], [t >= 0, [t, 5*t/exp(t), -t^2]])

Now, plot this function:

plot(plot::Curve3d(f, t = -10..10))

Parameters

x, y

Real-valued expressions in t (and possibly the animation parameter)

A2d

A matrix of category Cat::Matrix with two entries that provide the parametrization x, y of a 2D curve

piecewiseF(t)

A piecewise object

t

An identifier or an indexed identifier

tmin, tmax

Real-valued expressions (possibly in the animation parameter)

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?