VECTOR_FIELD3 Procedure
Plots a 3D vector field from three arrays.
Usage
VECTOR_FIELD3, vx, vy, vz, n_points
Input Parameters
vx—A 3D array containing the x-component of the vector field, or an n-element vector containing the x-component of the vector field.
vy—A 3D array containing the y-component of the vector field, or an n-element vector containing the y-component of the vector field.
vz—A 3D array containing the z-component of the vector field, or an n-element vector containing the z-component of the vector field.
note | The arrays vx, vy, and vz must be the same size. |
n_points—If vx, vy, and vz are all 3D arrays and n_points is a (3, n) array, then n_points is used to specify where the vectors are plotted.
If vx, vy, and vz have the dimensions (i, j, k), then:
n_points(0,*)
should range between 0 and
i – 1
n_points(1,*) should range between 0 and
j – 1
n_points(2,*) should range between 0 and
k – 1
If vx, vy, and vz are all 3D arrays and n_points is a single positive value n, then n vectors are plotted with random starting locations.
If vx, vy, and vz are all 3D arrays and n_points is zero or negative, then one vector is plotted for each element in vx.
If vx, vy, and vz are n-element vectors and n_points is a (3, n) array, then the starting locations for each vector are taken from n_points.
Keywords
Axis_Color—The color to use when plotting the axis. To suppress the axis, set Axis_Color to –1.
Mark_Color—The color index to use when plotting the markers.
Mark_Size—The marker size.
Mark_Symbol—A number ranging from 1 to 7 defining the marker symbol to use. The default is 3 (a period). Markers are plotted at the tail of each vector. For a list of symbols, see the description of !Psym in
System Variables.
Max_Color—The highest color index to use when plotting.
Min_Color—The lowest color index to use when plotting. The color of each vector ranges from Min_Color to Max_Color.
Max_Length—A scalar value for the maximum plotted length of each vector. Each vector ranges from zero to Max_Length.
Thick—The line thickness (in pixels) to use when plotting vectors.
Vec_Color—A 3D array (with the same dimensions as vx) containing the data for the vector colors.
A vector plotted where Vec_Color is at its maximum has the color Max_Color, while a vector plotted at a location where Vec_Color is minimum has the color Min_Color.
If Vec_Color is not supplied, then the color of each vector is determined by its length.
Discussion
VECTOR_FIELD3 plots a 3D velocity vector field from volumetric or 3D data.
Examples
This program displays a 3D vector field using x, y, z data.
.RUN
PRO vec_demo1
; Specify the window size.
winx = 800
winy = 600
; Specify the number of vectors.
v_num = 1000
xvec = FLTARR(v_num)
yvec = FLTARR(v_num)
zvec = FLTARR(v_num)
; Create the arrays for the vectors and their starting points.
points = FLTARR(3, v_num)
; Create the data for the vectors and their starting points.
FOR k=0L, 9 DO BEGIN
FOR j=0L, 9 DO BEGIN
FOR i=0L, 9 DO BEGIN
ind = i + (j * 10) + (k * 10 * 10)
xvec(ind) = COS(!PI * FLOAT(i)/10.0)
yvec(ind) = SIN(!PI * FLOAT(j)/10.0)
zvec(ind) = SIN(!PI * FLOAT(k)/10.0)$
+ COS(!PI * FLOAT(i)/10.0)
points(*, ind) = [i, j, k]
ENDFOR
ENDFOR
ENDFOR
; Set up the transformation matrix for the view.
T3D, /Reset
T3D, Translate=[-0.5, -0.5, -0.5]
T3D, Scale=[0.5, 0.5, 0.5]
T3D, Rotate=[0.0, 0.0, -30.0]
T3D, Rotate=[-60.0, 0.0, 0.0]
T3D, Translate=[0.5, 0.5, 0.5]
; Set up the viewing window and load the color table.
WINDOW, 0, XSize=winx, YSize=winy, XPos=256, YPos=128, $
Colors=128, Title='3-D Velocity Vector Field'
LOADCT, 4
; Plot vector field with vector directions defined by xvec,
; yvec, and zvec, and the vector starting points defined by
; points.
VECTOR_FIELD3, xvec, yvec, zvec, points, Max_Length=0.5, $
Min_Color=32, Max_Color=127, Axis_Color=100, $
Mark_Symbol=3, Mark_Color=127, Mark_Size=0.5, Thick=2
END
VEC_DEMO1
For other examples, see the vec_demo2 and vol_demo1 demonstration programs in:
(UNIX) <wavedir>/demo/arl
(WIN) <wavedir>\demo\arl
Where <wavedir> is the main PV‑WAVE directory.
See Also
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.