Function Repository Resource:

PlotVector3D

Source Notebook

Plot a list of vectors in space

Contributed by: Dennis M Schneider

ResourceFunction["PlotVector3D"][{{x1,y1,z1},{x2,y2,z2},}]

plots the vectors {xi,yi,zi}, each located at the origin.

ResourceFunction["PlotVector3D"][{{x1,y1,z1},{x2,y2,z2},},{p,q,r}]

plots the vectors {xi,yi,zi}, each located at the point {p,q,r}.

ResourceFunction["PlotVector3D"][{{{x1,y1,z1},{p1,q1,r1}},{{x2,y2,z2},{p2,q2,r2}},}]

plots the vectors {xi,yi,zi} located at the corresponding points {pi,qi,ri}.

ResourceFunction["PlotVector3D"][{{x1,y1,z1},{x2,y2,z2},},{{p1,q1,r1},{p2,q2,r2},}]

plots the vectors {xi,yi,zi} located at the corresponding points (pi,qi,r1}.

Details and Options

The following options are supported:
"ArrowSize"Largespecifies the size of the arrowhead
"LocatedVector"Falsewhether to draw vectors from the initial point (the first point of the list)
VectorStyleRGBColor[.3,.4,.7]specifes the style of the vector
A located vector is one whose initial point is the first point in the list, and whose terminal point is the second point in the list. ResourceFunction["PlotVector3D"][{{{x,y,z},{p,q,r}}}] uses {p,q,r} as the initial point and moves off in the direction given by {x,y,z}. Thus the terminal point is {p+x,q+y,r+z}.

Examples

Basic Examples (2) 

Plot the vector (1,1,1) located at the origin:

In[1]:=
ResourceFunction["PlotVector3D"][{{1, 1, 1}}]
Out[1]=

Plot a list of vectors located at the origin:

In[2]:=
ResourceFunction["PlotVector3D"][{{1, 1, 1}, {2, 2, -1}}]
Out[2]=

Scope (4) 

Plot the vector (2,2,2) located at the point {-1,1,1}:

In[3]:=
ResourceFunction["PlotVector3D"][{{2, 2, 2}}, {-1, 1, 1}]
Out[3]=

Plot a list of vectors located at the point {1,2,2}:

In[4]:=
ResourceFunction["PlotVector3D"][{{1, 1, 2}, {2, -1, 2}}, {1, 2, 2}]
Out[4]=

Plot a list of vectors located at different points. The first list is a list of vectors and the second is a list of initial points:

In[5]:=
ResourceFunction[
 "PlotVector3D"][{{1, 1, 1}, {2, -1, 1}, {1, .5, 1}}, {{0, 0, 0}, {3, 5, 2}, {2, 2, 1}}]
Out[5]=

The length of the list of vectors must be the same as the length of the list of initial points:

In[6]:=
ResourceFunction[
 "PlotVector3D"][{{1, 1, 1}, {2, -1, 1}, {1, .5, 1}}, {{0, 0, 0}, {3, 5, 2}}]

Options (5) 

ArrowSize (1) 

Change the arrow size of each vector:

In[7]:=
ResourceFunction["PlotVector3D"][{{1/2, 1, 1}, {1, 1, 1}}, "ArrowSize" -> {Medium, Large}]
Out[7]=

LocatedVector (2) 

A located vector from the first point to the second point:

In[8]:=
ResourceFunction["PlotVector3D"][{{1, 1, 1}, {-1, 1, 2}}, "LocatedVector" -> True]
Out[8]=

Setting "LocatedVector" to False draws the vector located at the origin:

In[9]:=
ResourceFunction["PlotVector3D"][{{1, 1, 1}, {-1, 1, 2}}, "LocatedVector" -> False]
Out[9]=

A list of lists of pairs of vectors with the option "LocatedVector"True draws located vectors from the first point in each sublist to the second point in each sublist:

In[10]:=
ResourceFunction[
 "PlotVector3D"][{{{1, 1, 1}, {-1, 1, 2}}, {{1, 0, 1}, {2, 1, 1}}}, "LocatedVector" -> True]
Out[10]=

Without the option being set, the second tuple in each list gives the located point, and the first tuple gives the direction:

In[11]:=
ResourceFunction[
 "PlotVector3D"][{{{1, 1, 1}, {-1, 1, 2}}, {{1, 0, 1}, {2, 1, 1}}}, "LocatedVector" -> False]
Out[11]=

VectorStyle (2) 

Change the style of the vectors:

In[12]:=
ResourceFunction[
 "PlotVector3D"][{{{3, 1, 1}, {1, 1, 1}}, {{2, -1, 1}, {1/2, 0, -1}}},
  VectorStyle -> {Dashed, {Red, Thick}}]
Out[12]=

Set both the arrow size and style for each vector:

In[13]:=
ResourceFunction[
 "PlotVector3D"][{{{3, 1, 1}, {1, 1, 1}}, {{2, -1, 1}, {1/2, 0, -1}}},
  VectorStyle -> {Dashed, {Red, Thick}}, "ArrowSize" -> {Medium, Large}]
Out[13]=

Properties and Relations (2) 

You can specify a vector located at a point using the second, third and fourth templates:

In[14]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/0e99c7ee-e74f-4bdc-b59b-cddcc6f51eda"]
Out[14]=

Use Arrow to produce any of these plots:

In[15]:=
Graphics3D[{RGBColor[.3, .4, .7], Arrowheads[Large], Arrow[{{1, 1, 1}, {1, 1, 1} + {2, 1, 1}}]}, Axes -> Automatic, TicksStyle -> Tiny]
Out[15]=

Publisher

Dennis M Schneider

Version History

  • 1.0.0 – 24 September 2019

Related Resources

License Information