52 PLFLT def_arrow_x[6] = { -0.5, 0.5, 0.3, 0.5, 0.3, 0.5 };
53 PLFLT def_arrow_y[6] = { 0.0, 0.0, 0.2, 0.0, -0.2, 0.0 };
61 if ( arrowx == NULL && arrowy == NULL )
69 if ( ( ( plsc->arrow_x = (
PLFLT *) malloc( (
size_t) npts *
sizeof (
PLFLT ) ) ) == NULL ) ||
70 ( ( plsc->arrow_y = (
PLFLT *) malloc( (
size_t) npts *
sizeof (
PLFLT ) ) ) == NULL ) )
72 plexit(
"c_plsvect: Insufficient memory" );
75 plsc->arrow_npts = npts;
76 plsc->arrow_fill =
fill;
77 for ( i = 0; i < npts; i++ )
79 plsc->arrow_x[i] = arrowx[i];
80 plsc->arrow_y[i] = arrowy[i];
90 PLFLT uu, vv, px0, py0, dpx, dpy;
95 PLINT *a_x, *a_y = NULL;
101 if ( uu == 0.0 && vv == 0.0 )
104 if ( ( ( a_x = (
PLINT *) malloc(
sizeof (
PLINT ) * (
size_t) ( plsc->arrow_npts ) ) ) == NULL ) ||
105 ( ( a_y = (
PLINT *) malloc(
sizeof (
PLINT ) * (
size_t) ( plsc->arrow_npts ) ) ) == NULL ) )
107 plexit(
"plP_plotvect: Insufficient memory" );
114 pldebug(
"plP_plotvect",
"%f %f %d %d\n", x, y, px0, py0 );
116 TRANSFORM( x + 0.5 * uu, y + 0.5 * vv, &xt, &yt );
123 for ( j = 0; j < plsc->arrow_npts; j++ )
125 a_x[j] = (
PLINT) ( plsc->arrow_x[j] * dpx - plsc->arrow_y[j] * dpy + px0 );
126 a_y[j] = (
PLINT) ( plsc->arrow_x[j] * dpy + plsc->arrow_y[j] * dpx + py0 );
131 if ( plsc->arrow_fill )
133 plP_plfclp( a_x, a_y, plsc->arrow_npts, plsc->clpxmi, plsc->clpxma,
134 plsc->clpymi, plsc->clpyma,
plP_fill );
137 free( (
void *) a_x );
138 free( (
void *) a_y );
152 PLFLT **u, **v, **x, **y;
153 PLFLT lscale, dx, dy, dxmin, dymin, umax, vmax;
158 plabort(
"plfvect: The pltr callback must be defined" );
167 for ( j = 0; j < ny; j++ )
169 for ( i = 0; i < nx; i++ )
171 u[i][j] = getuv( i, j, up );
172 v[i][j] = getuv( i, j, vp );
173 pltr( (
PLFLT) i, (
PLFLT) j, &x[i][j], &y[i][j], pltr_data );
180 if ( nx <= 1 && ny <= 1 )
182 fprintf( stderr,
"plfvect: not enough points for autoscaling\n" );
187 for ( j = 0; j < ny; j++ )
189 for ( i = 0; i < nx; i++ )
191 for ( j1 = j; j1 < ny; j1++ )
193 for ( i1 = 0; i1 < nx; i1++ )
195 dx = fabs( x[i1][j1] - x[i][j] );
196 dy = fabs( y[i1][j1] - y[i][j] );
199 dxmin = ( dx < dxmin ) ? dx : dxmin;
203 dymin = ( dy < dymin ) ? dy : dymin;
211 for ( j = 0; j < ny; j++ )
213 for ( i = 0; i < nx; i++ )
215 umax = ( u[i][j] > umax ) ? u[i][j] : umax;
216 vmax = ( v[i][j] > vmax ) ? v[i][j] : vmax;
221 dxmin = dxmin / umax;
229 dymin = dymin / vmax;
235 lscale = 1.5 *
MIN( dxmin, dymin );
238 scale = -scale * lscale;
246 for ( j = 0; j < ny; j++ )
248 for ( i = 0; i < nx; i++ )
250 plP_plotvect( x[i][j], y[i][j], u[i][j], v[i][j], scale );
265 nx, ny, scale, pltr, pltr_data );
void plexit(PLCHAR_VECTOR errormsg)
void c_plsvect(PLFLT_VECTOR arrowx, PLFLT_VECTOR arrowy, PLINT npts, PLBOOL fill)
const PLFLT *const * PLFLT_MATRIX
PLDLLIMPEXP void plsvect_null(void)
void plabort(PLCHAR_VECTOR errormsg)
PLFLT(* PLF2EVAL_callback)(PLINT ix, PLINT iy, PLPointer data)
void plFree2dGrid(PLFLT **f, PLINT nx, PLINT PL_UNUSED(ny))
PLFLT plf2eval1(PLINT ix, PLINT iy, PLPointer plf2eval_data)
#define TRANSFORM(x, y, xnew, ynew)
void(* PLTRANSFORM_callback)(PLFLT x, PLFLT y, PLFLT_NC_SCALAR xp, PLFLT_NC_SCALAR yp, PLPointer data)
static void plP_plotvect(PLFLT x, PLFLT y, PLFLT u, PLFLT v, PLFLT scale)
void plP_fill(short *x, short *y, PLINT npts)
void plP_draphy_poly(PLINT *x, PLINT *y, PLINT n)
void plAlloc2dGrid(PLFLT ***f, PLINT nx, PLINT ny)
void plP_plfclp(PLINT *x, PLINT *y, PLINT npts, PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax, void(*draw)(short *, short *, PLINT))
void c_plvect(PLFLT_MATRIX u, PLFLT_MATRIX v, PLINT nx, PLINT ny, PLFLT scale, PLTRANSFORM_callback pltr, PLPointer pltr_data)
void plfvect(PLF2EVAL_callback getuv, PLPointer up, PLPointer vp, PLINT nx, PLINT ny, PLFLT scale, PLTRANSFORM_callback pltr, PLPointer pltr_data)
const PLFLT * PLFLT_VECTOR
PLDLLIMPEXP_CXX void fill(PLINT n, const PLFLT *x, const PLFLT *y)