5.15 Vector fields

These functions perform plotting of 2D and 3D vector fields. There are 5 generally different types of vector fields representations: simple vector field (Vect), vectors along the curve (Traj), vector field by dew-drops (Dew), flow threads (Flow, FlowP), flow pipes (Pipe). By default (if absent) values of x, y, z are equidistantly distributed in axis range. The minor dimensions of arrays x, y, z, ax should be equal. The size of ax, ay and az must be equal. Arrays x, y, z can be vectors (not matrices as ax). String sch sets the color scheme (see Color scheme) for plot. String opt contain command options (see Command options).

MGL command: lines y1dat y2dat ['sch'='']
MGL command: lines x1dat y1dat x2dat y2dat ['sch'='']
MGL command: lines x1dat y1dat z1dat x2dat y2dat z2dat ['sch'='']
Method on mglGraph: void Lines (const mglDataA &y1, const mglDataA &y2, const char *sch="", const char *opt="")
Method on mglGraph: void Lines (const mglDataA &x1, const mglDataA &y1, const mglDataA &x2, const mglDataA &y2, const char *sch="", const char *opt="")
Method on mglGraph: void Lines (const mglDataA &x1, const mglDataA &y1, const mglDataA &z1, const mglDataA &x2, const mglDataA &y2, const mglDataA &z2, const char *sch="", const char *opt="")
C function: void mgl_lines_xyz (HMGL gr, HCDTx1, HCDTy1, HCDTz1, HCDTx2, HCDTy2, HCDTz2, const char *sch, const char *opt)
C function: void mgl_lines_xy (HMGL gr, HCDTx1, HCDTy1, HCDTx2, HCDTy2, const char *sch, const char *opt)
C function: void mgl_lines (HMGL gr, HCDTy1, HCDTy2, const char *sch, const char *opt)

The function draws lines between points {x1, y1, z1} and {x2, y2, z2}. String pen specifies the color (see Line styles). By default (pen="") color from palette is used (see Palette and colors). The minor sizes of all arrays must be the same. The plots are drawn for each row if one of the data is the matrix. See also plot, traj. See Sample ‘lines, for sample code and picture.

MGL command: traj xdat ydat udat vdat ['sch'='']
MGL command: traj xdat ydat zdat udat vdat wdat ['sch'='']
Method on mglGraph: void Traj (const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
Method on mglGraph: void Traj (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
C function: void mgl_traj_xyz (HMGL gr, HCDTx, HCDTy, HCDTz, HCDTax, HCDTay, HCDTaz, const char *sch, const char *opt)
C function: void mgl_traj_xy (HMGL gr, HCDTx, HCDTy, HCDTax, HCDTay, const char *sch, const char *opt)

The function draws vectors {ax, ay, az} along a curve {x, y, z}. The length of arrows are proportional to \sqrt{ax^2+ay^2+az^2}. String pen specifies the color (see Line styles). By default (pen="") color from palette is used (see Palette and colors). Option value set the vector length factor (if non-zero) or vector length to be proportional the distance between curve points (if value=0). The minor sizes of all arrays must be equal and large 2. The plots are drawn for each row if one of the data is the matrix. See also vect. See Sample ‘traj, for sample code and picture.

MGL command: vect udat vdat ['sch'='']
MGL command: vect xdat ydat udat vdat ['sch'='']
Method on mglGraph: void Vect (const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
Method on mglGraph: void Vect (const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
C function: void mgl_vect_2d (HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt)
C function: void mgl_vect_xy (HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt)

The function draws plane vector field plot for the field {ax, ay} depending parametrically on coordinates x, y at level z equal to minimal z-axis value. The length and color of arrows are proportional to \sqrt{ax^2+ay^2}. The number of arrows depend on meshnum. The appearance of the hachures (arrows) can be changed by symbols:

  • f’ for drawing arrows with fixed lengths,
  • >’, ‘<’ for drawing arrows to or from the cell point (default is centering),
  • .’ for drawing hachures with dots instead of arrows,
  • =’ for enabling color gradient along arrows.

See also flow, dew. See Sample ‘vect, for sample code and picture.

MGL command: vect udat vdat wdat ['sch'='']
MGL command: vect xdat ydat zdat udat vdat wdat ['sch'='']
Method on mglGraph: void Vect (const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
Method on mglGraph: void Vect (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
C function: void mgl_vect_3d (HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt)
C function: void mgl_vect_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the length and color of arrows is proportional to \sqrt{ax^2+ay^2+az^2}.

MGL command: vect3 udat vdat wdat ['sch'='' sval]
MGL command: vect3 xdat ydat zdat udat vdat wdat ['sch'='' sval]
Method on mglGraph: void Vect3 (const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", mreal sVal=-1, const char *opt="")
Method on mglGraph: void Vect3 (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", mreal sVal=-1, const char *opt="")
C function: void mgl_vect3 (HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, mreal sVal, const char *opt)
C function: void mgl_vect3_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, mreal sVal, const char *opt)

The function draws 3D vector field plot for the field {ax, ay, az} depending parametrically on coordinates x, y, z. Vector field is drawn at slice sVal in direction {‘x’, ‘y’, ‘z’} if sch contain corresponding symbol (by default, ‘y’ direction is used). The length and color of arrows are proportional to \sqrt{ax^2+ay^2+az^2}. The number of arrows depend on meshnum. The appearance of the hachures (arrows) can be changed by symbols:

  • f’ for drawing arrows with fixed lengths,
  • >’, ‘<’ for drawing arrows to or from the cell point (default is centering),
  • .’ for drawing hachures with dots instead of arrows,
  • =’ for enabling color gradient along arrows.

See also vect, flow, dew. See Sample ‘vect3, for sample code and picture.

MGL command: dew udat vdat ['sch'='']
MGL command: dew xdat ydat udat vdat ['sch'='']
Method on mglGraph: void Dew (const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
Method on mglGraph: void Dew (const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
C function: void mgl_dew (HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt)
C function: void mgl_dew_xy (HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt)

The function draws dew-drops for plane vector field {ax, ay} depending parametrically on coordinates x, y at level z equal to minimal z-axis value. Note that this is very expensive plot in memory usage and creation time! The color of drops is proportional to \sqrt{ax^2+ay^2}. The number of drops depend on meshnum. See also vect. See Sample ‘dew, for sample code and picture.

MGL command: flow udat vdat ['sch'='']
MGL command: flow xdat ydat udat vdat ['sch'='']
Method on mglGraph: void Flow (const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
Method on mglGraph: void Flow (const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
C function: void mgl_flow_2d (HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt)
C function: void mgl_flow_xy (HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt)

The function draws flow threads for the plane vector field {ax, ay} parametrically depending on coordinates x, y at level z equal to minimal z-axis value. Option value set the approximate number of threads (default is 5), or accuracy for stationary points (if style ‘.’ is used) . String sch may contain:

  • color scheme – up-half (warm) corresponds to normal flow (like attractor), bottom-half (cold) corresponds to inverse flow (like source);
  • #’ for starting threads from edges only;
  • .’ for drawing separatrices only (flow threads to/from stationary points).
  • *’ for starting threads from a 2D array of points inside the data;
  • v’ for drawing arrows on the threads;
  • x’, ‘z’ for drawing tapes of normals in x-y and y-z planes correspondingly.

See also pipe, vect, tape, flow3, barwidth. See Sample ‘flow, for sample code and picture.

MGL command: flow udat vdat wdat ['sch'='']
MGL command: flow xdat ydat zdat udat vdat wdat ['sch'='']
Method on mglGraph: void Flow (const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
Method on mglGraph: void Flow (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
C function: void mgl_flow_3d (HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt)
C function: void mgl_flow_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the color of line is proportional to \sqrt{ax^2+ay^2+az^2}.

MGL command: flow x0 y0 udat vdat ['sch'='']
MGL command: flow x0 y0 xdat ydat udat vdat ['sch'='']
Method on mglGraph: void FlowP (mglPoint p0, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
Method on mglGraph: void FlowP (mglPoint p0, const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="")
C function: void mgl_flowp_2d (HMGL gr, mreal x0, mreal y0, mreal z0, HCDT ax, HCDT ay, const char *sch, const char *opt)
C function: void mgl_flowp_xy (HMGL gr, mreal x0, mreal y0, mreal z0, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt)

The same as first one (flow) but draws single flow thread starting from point p0={x0,y0,z0}. String sch may also contain: ‘>’ or ‘<’ for drawing in forward or backward direction only (default is both).

MGL command: flow x0 y0 z0 udat vdat wdat ['sch'='']
MGL command: flow x0 y0 z0 xdat ydat zdat udat vdat wdat ['sch'='']
Method on mglGraph: void FlowP (mglPoint p0, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
Method on mglGraph: void FlowP (mglPoint p0, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="")
C function: void mgl_flowp_3d (HMGL gr, mreal x0, mreal y0, mreal z0, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt)
C function: void mgl_flowp_xyz (HMGL gr, mreal x0, mreal y0, mreal z0, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt)

This is 3D version of the previous functions.

MGL command: flow3 udat vdat wdat ['sch'='']
MGL command: flow3 xdat ydat zdat udat vdat ['sch'='']
Method on mglGraph: void Flow3 (const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", double sVal=-1, const char *opt="")
Method on mglGraph: void Flow3 (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", double sVal=-1, const char *opt="")
C function: void mgl_flow3 (HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, double sVal, const char *opt)
C function: void mgl_flow3_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, double sVal, const char *opt)

The function draws flow threads for the 3D vector field {ax, ay, az} parametrically depending on coordinates x, y, z. Flow threads starts from given plane. Option value set the approximate number of threads (default is 5). String sch may contain:

  • color scheme – up-half (warm) corresponds to normal flow (like attractor), bottom-half (cold) corresponds to inverse flow (like source);
  • x’, ‘z’ for normal of starting plane (default is y-direction);
  • v’ for drawing arrows on the threads;
  • t’ for drawing tapes of normals in x-y and y-z planes.

See also flow, pipe, vect. See Sample ‘flow3, for sample code and picture.

MGL command: grad pdat ['sch'='']
MGL command: grad xdat ydat pdat ['sch'='']
MGL command: grad xdat ydat zdat pdat ['sch'='']
Method on mglGraph: void Grad (const mglDataA &phi, const char *sch="", const char *opt="")
Method on mglGraph: void Grad (const mglDataA &x, const mglDataA &y, const mglDataA &phi, const char *sch="", const char *opt="")
Method on mglGraph: void Grad (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &phi, const char *sch="", const char *opt="")
C function: void mgl_grad (HMGL gr, HCDT phi, const char *sch, const char *opt)
C function: void mgl_grad_xy (HMGL gr, HCDT x, HCDT y, HCDT phi, const char *sch, const char *opt)
C function: void mgl_grad_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT phi, const char *sch, const char *opt)

The function draws gradient lines for scalar field phi[i,j] (or phi[i,j,k] in 3d case) specified parametrically {x[i,j,k], y[i,j,k], z[i,j,k]}. Number of lines is proportional to value option (default is 5). See also dens, cont, flow.

MGL command: pipe udat vdat ['sch'='' r0=0.05]
MGL command: pipe xdat ydat udat vdat ['sch'='' r0=0.05]
Method on mglGraph: void Pipe (const mglDataA &ax, const mglDataA &ay, const char *sch="", mreal r0=0.05, const char *opt="")
Method on mglGraph: void Pipe (const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", mreal r0=0.05, const char *opt="")
C function: void mgl_pipe_2d (HMGL gr, HCDT ax, HCDT ay, const char *sch, mreal r0, const char *opt)
C function: void mgl_pipe_xy (HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, mreal r0, const char *opt)

The function draws flow pipes for the plane vector field {ax, ay} parametrically depending on coordinates x, y at level z equal to minimal z-axis value. Number of pipes is proportional to value option (default is 5). If ‘#’ symbol is specified then pipes start only from edges of axis range. The color of lines is proportional to \sqrt{ax^2+ay^2}. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). Parameter r0 set the base pipe radius. If r0<0 or symbol ‘i’ is specified then pipe radius is inverse proportional to amplitude. The vector field is plotted for each z slice of ax, ay. See also flow, vect. See Sample ‘pipe, for sample code and picture.

MGL command: pipe udat vdat wdat ['sch'='' r0=0.05]
MGL command: pipe xdat ydat zdat udat vdat wdat ['sch'='' r0=0.05]
Method on mglGraph: void Pipe (const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", mreal r0=0.05, const char *opt="")
Method on mglGraph: void Pipe (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", mreal r0=0.05, const char *opt="")
C function: void mgl_pipe_3d (HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, mreal r0, const char *opt)
C function: void mgl_pipe_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, mreal r0, const char *opt)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the color of line is proportional to \sqrt{ax^2+ay^2+az^2}.