Previous Page Next Page Contents

plot3d -- 3D plots

Introduction

plot3d(object1, object2, ...) generates a 3D plot of graphical objects such as curves, surfaces, points, and polygons.

Call(s)

plot3d( <SceneOptions,> object1, object2, ...)

Parameters

object1, object2, ... - graphical objects as described below

Options

SceneOptions - a sequence of scene options. These determine the general appearance of the graphical scene. See ?plotOptions3d for details.

Returns

MuPAD's graphics tool is called to render the graphical scene, and the null() object is returned to the MuPAD session.

Related Functions

plot, plotfunc2d, plot2d, plotfunc3d

Details

Option: Color =

value

Option: Grid = [n]

(for curves)

Option: Grid = [nu, nv]

(for surfaces)

Option: LineStyle =

value

Option: LineWidth = n

Option: PointStyle =

value

Option: PointWidth = n

Option: Smoothness = [n]

(for curves)

Option: Smoothness = [nu, nv]

(for surfaces)

Option: Style =

value (for curves)

Option: Style =

value (for surfaces)

Option: Title =

TitleString

Option: TitlePosition = [x, y]

Example 1

We demonstrate plotting of graphical primtives. First, three point primitives, a line primitive and a filled polygon is defined:

>> p1 := point(0, 0, 0, Color = RGB::Red):
   p2 := point(0, 1, 1/2, Color = RGB::Green):
   p3 := point(-1, 1, 1, Color = RGB::Blue):
   line := polygon(point(0, 0, 0), point(0, 1, 1/2), 
                   point(-1, 1, 1), Closed = TRUE,
                   Color = RGB::Black):
   triangle := polygon(point(0, 0, 0), point(-1, 0.2, 0.4),
                       point(-1, 1, 0), Closed = TRUE,
                       Filled = TRUE, Color = RGB::Antique): 

These are combined to a graphical object:

>> object := [Mode = List, [p1, p2, p3, line, triangle]]:

Finally, this object is plotted:

>> plot3d(BackGround = RGB::White, ForeGround = RGB::Black,
          PointWidth = 70, PointStyle = FilledCircles,
          Axes = Box, object)
>> delete p1, p2, p3, line, triangle, object:

Example 2

We plot curves. The following picture demonstrates various styles:

>> plot3d(Axes = Box, Ticks = 0,
          BackGround = RGB::White, ForeGround = RGB::Black,
          [Mode = Curve, [u, -PI, cos(u)], u = [-PI, PI],
           Grid = [40], Style = [Points], PointWidth = 40
          ],
          [Mode = Curve, [u, -PI/3, cos(u)], u = [-PI, PI],
           Grid = [40], Style = [Lines]
          ],
          [Mode = Curve, [u, PI/3, cos(u)], u = [-PI, PI],
           Grid = [40], Style = [LinesPoints], PointWidth = 30
          ],
          [Mode = Curve, [u, PI, cos(u)], u = [-PI, PI],
           Grid = [40], Style = [Impulses]
          ]):

The following command plots a ``histogram style'' graph of the cosine function defined over the unit circle in the x-y-plane:

>> plot3d(Axes = Box, Ticks = 5, CameraPoint = [20, -10, 30],
          BackGround = RGB::White, ForeGround = RGB::Black,
          Labeling = TRUE, Labels = ["x", "y", "z"],
          Title = "A curve in space",
          [Mode = Curve, [cos(u), sin(u), sin(3*u)], u = [0, 2*PI],
           Grid = [200], Style = [Impulses]
          ])

The following command plots a spiral on the unit sphere:

>> plot3d(Axes = Box, Ticks = 0, Scaling = Constrained,
          Title = "spiral", TitlePosition = Below,
          [Mode = Curve,
           [cos(12*u*PI)*sin(u*PI),
            sin(12*u*PI)*sin(u*PI),
            cos(u*PI)],
           u = [0, 1], Grid = [50], Smoothness = [5]
          ])

Example 3

We demonstrate surface plots. The next command generates spheres of radius 1 parametrized by polar coordinates. It illustrates various surface styles:

>> plot3d(Axes = Box, Ticks = 0, Scaling = Constrained,
          BackGround = RGB::White, ForeGround = RGB::Black,
          CameraPoint = [6, -21, 8],
          [Mode = Surface,
           [-2.5 + sin(u)*cos(v), sin(u)*sin(v), cos(u)],
           u = [0, PI], v = [0, 2*PI],
           Grid = [20, 20], Smoothness = [0, 0],
           Style = [HiddenLine, Mesh]
          ],
          [Mode = Surface,
           [sin(u)*cos(v), sin(u)*sin(v), cos(u)],
           u = [0, PI], v = [0, 2*PI],
           Grid = [15, 30], Smoothness = [0, 0],
           Style = [ColorPatches, AndULine]
          ],
          [Mode = Surface,
           [2.5 + sin(u)*cos(v), sin(u)*sin(v), cos(u)],
           u = [0, PI], v = [0, 2*PI],
           Grid = [10, 10], Smoothness = [0, 0],
           Style = [Transparent, AndVLine]
          ])

The effect of the options Grid and Smoothness is demonstrated by discs in the x-y-plane:

>> plot3d(Axes = None, Scaling = Constrained, 
          BackGround = RGB::White, ForeGround = RGB::Black,
          CameraPoint = [0, -1, 20],
          [Mode = Surface, [-2.5 + v*sin(u), v*cos(u), 0],
           u = [-PI, PI], v = [0, 1], Style = [WireFrame, Mesh],
           Grid = [ 6,  6], Smoothness = [0, 0]
          ],
          [Mode = Surface, [v*sin(u), v*cos(u), 0],
           u = [-PI, PI], v = [0, 1], Style = [WireFrame, Mesh],
           Grid = [ 6,  6], Smoothness = [3, 2]
          ],
          [Mode = Surface, [2.5 + v*sin(u), v*cos(u), 0],
           u = [-PI, PI], v = [0, 1], Style = [WireFrame, Mesh],
           Grid = [20, 10], Smoothness = [0, 0]
          ])

The graph of a function is plotted as a parametrized surface:

>> plot3d(Axes = Box, Ticks = 8,
          BackGround = RGB::White, ForeGround = RGB::Black,
          Title = "Plot of sin(u^2 + v^2)", TitlePosition = Below,
          [Mode = Surface, [u, v, sin(u^2 + v^2)],
           u = [0, PI], v = [0, PI],
           Grid = [30, 30], Style = [HiddenLine, Mesh]
          ])

Various objects of different type are combined to a graphical scene:

>> plot3d(Axes = None, Scaling = Constrained,
          BackGround = RGB::White, ForeGround = RGB::Black,
          Title = "Three surfaces and a curve",
          TitlePosition = Below,
          CameraPoint = [13, -24, 20],
          [Mode = Surface,
           [(4 + cos(v))*cos(u), (4 + cos(v))*sin(u), sin(v)],
           u = [0, 2*PI], v = [0, 2*PI],
           Grid = [20, 20], Smoothness = [2, 0],
           Style = [HiddenLine, Mesh]
          ],
          [Mode = Surface,
           [2*cos(u)*sin(v), 2*sin(u)*sin(v), 2*cos(v)],
           u = [0, 2*PI], v = [0, PI],
           Grid = [10, 10], Smoothness = [2, 2],
           Style = [ColorPatches, AndMesh]
          ],
          [Mode = Surface, [u, v, -3], u = [-5, 5], v = [-5, 5],
           Grid = [5, 5], Smoothness = [0, 0],
           Style = [ColorPatches, Only]
          ],
          [Mode = Curve,
           [6*cos(12*u)*sin(u), 6*sin(12*u)*sin(u), 6*cos(u)],
           u = [0, PI], Grid = [50], Smoothness = [5],
           Title = "spiral"
          ])

Example 4

We demonstrate user-defined color functions. The following function produces admissible RGB-values between 0 and 1 for objects with coordinates x,y,z in [-1,1]:

>> myColor := (x, y, z, u, v) -> 
              [(abs(x) + 1)/2, abs(x - y)/(3 + z), abs(y)]:

A hyperboloid over the unit square is to be colored by the function above. We plot the graph of the function (x, y) -> x^2 - y^2 as a parametrized surface:

>> plot3d(Axes = Box,
          BackGround = RGB::White, ForeGround = RGB::Black,
          [Mode = Surface, [x, y, x^2 - y^2],
           x = [-1, 1], y = [-1, 1],
           Grid = [15, 15], Smoothness = [3, 3],
           Style = [ColorPatches, AndMesh], 
           Color = [Function, myColor]
          ])
>> delete myColor:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000