Skip to Main Content Skip to Search
Product Documentation

plot::Curve2dparameterized 2D curves

plot::Curve3dparameterized 3D curves

plot::Curve2d([x(t), y(t)], t = `t_{min}`..`t_{max}`) creates the planar curve

ImageSet((x(t), y(t)), (`t_{min}` <= t) <= `t_{max}`)`.`

plot::Curve3d([x(t), y(t), z(t)], t = `t_{min}`..`t_{max}`) creates the space curve

ImageSet((x(t), y(t), z(t)), (`t_{min}` <= t) <= `t_{max}`)`.`

→ Examples

Calls:

plot::Curve2d([x, y], t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

plot::Curve2d(`A_{2d}`, t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

plot::Curve2d(piecewiseF(t), t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

plot::Curve3d([x, y, z], t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

plot::Curve3d(`A_{3d}`, t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

plot::Curve3d(piecewiseF(t), t = `t_{min}` .. `t_{max}`, <a = amin .. amax>, Options)

Parameters:

x, y, z

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

`A_{2d}`

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

`A_{3d}`

a matrix of category Cat::Matrix with three entries that provide the parametrization x, y, z of a 3D curve

piecewiseF(t)

a piecewise object

t

an identifier or an indexed identifier

`t_{min}`, `t_{max}`

real-valued expressions (possibly in the animation parameter)

Related Domains:

plot::Function2d, plot::Function3d, plot::Polygon2d, plot::Polygon3d, plot::Surface

Related Functions:

plot, plot::copy

Details:

Example 1

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

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

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

plot(curve)

MuPAD graphics

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)

MuPAD graphicsimage

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)

MuPAD graphicsimage

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

MuPAD graphicsimage

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)

MuPAD graphicsimage

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

MuPAD graphics

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)

MuPAD graphics

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

MuPAD graphics

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

MuPAD graphics

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

MuPAD graphics

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

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

Now, plot this function:

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

MuPAD graphics

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS