Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: How can I graph 3D vectors in Mathematica?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67462] RE: [mg67447] How can I graph 3D vectors in Mathematica?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 26 Jun 2006 00:13:12 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I would not call this so much a 3D vector, as a curve in 3D space
parametrized by t.

First, you will save yourself some time if you can go through much of Part I
of The Mathematica Book and learn the basic syntax.

Specifically, lists of component positions, or vector components, or lists
of anything are always enclosed in curly brackets, {}. Arguments of
functions like Sin and Cos are always enclosed in square brackets, []. Each
type of bracket in Mathematica has a specific use and they cannot be
interchanged.

Next, although it is not absolutely necessary, it is usually better to
define your parametrized curve as a function of t. In the following
statement t_ is a pattern variable and it means that anything put in the t
slot will be used on the right hand side. I used p to define the
parametrized curve. ':=' is a SetDelayed. (You can copy the Mathematica
statements directly from the posting to a Mathematica notebook.)

p[t_] := {Sin[t], t, Cos[t]}

We can then plot the curve with the following statement.

ParametricPlot3D[p[t], {t, 0, 2Pi}]

If you want to make a more fancy plot, and better control its appearance you
can give it a colored background and add labels with a series of options.
Mathematica usually adjust the ratios of the bounding box of 3D plots so
that each axis has the same scale. In the following plot I am using a larger
t domain and this would lead to a long narrow plot. So I used a plot Option,
BoxRatios, to give more convenient plot dimensions. I used the PlotPoints
option to specify that Mathematica was to take more sample points. This gave
a smoother curve. In general, you can use plot Options to improve your plots
although it take a while to learn what options there are and how to use
them.

Needs["Graphics`Colors`"]

ParametricPlot3D[p[t], {t, 0, 8Pi},
    PlotPoints -> 150,
    BoxRatios -> {1, 2, 1},
    AxesLabel -> {x, t, z},
    PlotLabel -> "A Helix",
    Background -> Linen,
    ImageSize -> 450];


If you actually want to plot 3D arrows, with little arrow cones on the tip,
then Mathematica does not have such a routine. (There is a 2D Arrow
routine.) The DrawGraphics package at my web site has an Arrow3D routine
that will plot 3D arrows and also put arrow cones on curves, and also allow
you to put 2D or 3D arrowheads anywhere along the length of a line and not
just at the tip.

The following uses DrawGraphics to draw a series of arrow cones along the
curve. The DrawGraphics construction also makes it easy to give a color to
the curve. (The regular method is to include the color as a 4th argument in
the parametrization.)

Needs["DrawGraphics`DrawingMaster`"]

Draw3DItems[
    {Blue,
      curve = ParametricDraw3D[p[t], {t, 0, 8Pi}, PlotPoints -> 150],
      ArrowCurve3D[curve, #, HeadLength3D -> 0.01] & /@ Range[0.2, 1, 0.2]},
    BoxRatios -> {1, 2, 1},
    AxesLabel -> {x, t, z},
    PlotLabel -> "A Helix",
    Background -> Linen,
    ImageSize -> 450];


David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: Michael [mailto:sirhankins at gmail.com]
To: mathgroup at smc.vnet.net


Hi, I am trying to figure out hout to make Mathematica graph 3D vectors. For
example, I would like to graph

v = <sin(t), t, cos(t)>

However, I have not been able to figure out what lines to type in to output
the graph.

I'm relatively new to the software, so any info would be great.

If anyone can help me figure out what to input in order to output the graph
of this type of vector, I'd be very thankful!



  • Prev by Date: Re: Integrate the Multivariate normal distribution
  • Next by Date: Re: Integrate the Multivariate normal distribution
  • Previous by thread: Re: How can I graph 3D vectors in Mathematica?
  • Next by thread: NIntegrate's Method ->Oscillatory option