25 #define INSIDE( ix, iy ) ( BETW( ix, xmin, xmax ) && BETW( iy, ymin, ymax ) )
77 if ( plsc->level < 3 )
79 plabort(
"plline: Please set up window first" );
98 if ( plsc->coordinate_transform == NULL )
109 if ( xs == NULL || ys == NULL )
111 plexit(
"c_plpath: Insufficient memory" );
134 PLFLT vmin[3], vmax[3], zscale;
136 if ( plsc->level < 3 )
138 plabort(
"plline3: Please set up window first" );
143 plP_gdom( &vmin[0], &vmax[0], &vmin[1], &vmax[1] );
147 for ( i = 0; i < n - 1; i++ )
153 p0[0] = x[i]; p0[1] = y[i]; p0[2] = z[i];
154 p1[0] = x[i + 1]; p1[1] = y[i + 1]; p1[2] = z[i + 1];
157 for ( axis = 0; axis < 3; axis++ )
159 if ( p0[axis] < vmin[axis] )
161 if ( p1[axis] < vmin[axis] )
169 PLFLT t = ( vmin[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
170 p0[axis] = vmin[axis];
171 for ( j = 1; j < 3; j++ )
173 int k = ( axis + j ) % 3;
174 p0[k] = ( 1 - t ) * p0[k] + t * p1[k];
178 else if ( p1[axis] < vmin[axis] )
182 PLFLT t = ( vmin[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
183 p1[axis] = vmin[axis];
184 for ( j = 1; j < 3; j++ )
186 int k = ( axis + j ) % 3;
187 p1[k] = ( 1 - t ) * p0[k] + t * p1[k];
190 if ( p0[axis] > vmax[axis] )
192 if ( p1[axis] > vmax[axis] )
200 PLFLT t = ( vmax[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
201 p0[axis] = vmax[axis];
202 for ( j = 1; j < 3; j++ )
204 int k = ( axis + j ) % 3;
205 p0[k] = ( 1 - t ) * p0[k] + t * p1[k];
209 else if ( p1[axis] > vmax[axis] )
213 PLFLT t = ( vmax[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
214 p1[axis] = vmax[axis];
215 for ( j = 1; j < 3; j++ )
217 int k = ( axis + j ) % 3;
218 p1[k] = ( 1 - t ) * p0[k] + t * p1[k];
226 PLFLT u0, v0, u1, v1;
269 PLFLT vmin[3], vmax[3], zscale;
270 PLFLT u1, v1, u2, v2, u3, v3;
273 if ( plsc->level < 3 )
275 plabort(
"plpoly3: Please set up window first" );
281 plabort(
"plpoly3: Must specify at least 3 points" );
296 c = ( u1 - u2 ) * ( v3 - v2 ) - ( v1 - v2 ) * ( u3 - u2 );
298 if ( c * ( 1 - 2 *
ABS( ifcc ) ) < 0. )
302 plP_gdom( &vmin[0], &vmax[0], &vmin[1], &vmax[1] );
306 for ( i = 0; i < n - 1; i++ )
312 p0[0] = x[i]; p0[1] = y[i]; p0[2] = z[i];
313 p1[0] = x[i + 1]; p1[1] = y[i + 1]; p1[2] = z[i + 1];
316 for ( axis = 0; axis < 3; axis++ )
318 if ( p0[axis] < vmin[axis] )
320 if ( p1[axis] < vmin[axis] )
328 PLFLT t = ( vmin[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
329 p0[axis] = vmin[axis];
330 for ( j = 1; j < 3; j++ )
332 int k = ( axis + j ) % 3;
333 p0[k] = ( 1 - t ) * p0[k] + t * p1[k];
337 else if ( p1[axis] < vmin[axis] )
341 PLFLT t = ( vmin[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
342 p1[axis] = vmin[axis];
343 for ( j = 1; j < 3; j++ )
345 int k = ( axis + j ) % 3;
346 p1[k] = ( 1 - t ) * p0[k] + t * p1[k];
349 if ( p0[axis] > vmax[axis] )
351 if ( p1[axis] > vmax[axis] )
359 PLFLT t = ( vmax[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
360 p0[axis] = vmax[axis];
361 for ( j = 1; j < 3; j++ )
363 int k = ( axis + j ) % 3;
364 p0[k] = ( 1 - t ) * p0[k] + t * p1[k];
368 else if ( p1[axis] > vmax[axis] )
372 PLFLT t = ( vmax[axis] - p0[axis] ) / ( p1[axis] - p0[axis] );
373 p1[axis] = vmax[axis];
374 for ( j = 1; j < 3; j++ )
376 int k = ( axis + j ) % 3;
377 p1[k] = ( 1 - t ) * p0[k] + t * p1[k];
383 if ( axis == 3 && draw[i] )
409 if ( plsc->level < 1 )
411 plabort(
"plstyl: Please call plinit first" );
414 if ( ( nms < 0 ) || ( nms > 10 ) )
416 plabort(
"plstyl: Broken lines cannot have <0 or >10 elements" );
420 for ( i = 0; i < nms; i++ )
422 if ( ( mark[i] < 0 ) || ( space[i] < 0 ) )
424 plabort(
"plstyl: Mark and space lengths must be > 0" );
427 if ( ( mark[i] != 0 ) || ( space[i] != 0 ) )
433 if ( ( nms > 0 ) && ( flag == 1 ) )
435 plabort(
"plstyl: At least one mark or space must be > 0" );
440 for ( i = 0; i < nms; i++ )
442 plsc->mark[i] = mark[i];
443 plsc->space[i] = space[i];
449 plsc->alarm = nms > 0 ? mark[0] : 0;
474 xline[0] = plsc->currx;
476 yline[0] = plsc->curry;
510 xline[0] = plsc->currx;
512 yline[0] = plsc->curry;
529 PLINT i, j, ib, ilim;
535 for ( i = 0; i < ilim; i++ )
556 PLINT i, j, ib, ilim;
563 for ( i = 0; i < ilim; i++ )
584 plP_pllclp( x, y, npts, plsc->clpxmi, plsc->clpxma,
585 plsc->clpymi, plsc->clpyma,
genlin );
601 void ( *draw )(
short *,
short *,
PLINT ) )
603 PLINT x1, x2, y1, y2;
607 short *xclp = NULL, *yclp = NULL;
617 if ( ( ( xclp = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) ||
618 ( ( yclp = (
short *) malloc( (
size_t) npts *
sizeof (
short ) ) ) == NULL ) )
620 plexit(
"plP_pllclp: Insufficient memory" );
624 for ( i = 0; i < npts - 1; i++ )
634 xmin, xmax, ymin, ymax );
642 xclp[iclp] = (short) x1;
643 yclp[iclp] = (short) y1;
645 xclp[iclp] = (short) x2;
646 yclp[iclp] = (short) y2;
652 else if ( x1 == xclp[iclp] && y1 == yclp[iclp] )
655 xclp[iclp] = (short) x2;
656 yclp[iclp] = (short) y2;
664 ( *draw )( xclp, yclp, iclp + 1 );
666 xclp[iclp] = (short) x1;
667 yclp[iclp] = (short) y1;
669 xclp[iclp] = (short) x2;
670 yclp[iclp] = (short) y2;
678 ( *draw )( xclp, yclp, iclp + 1 );
680 plsc->currx = x[npts - 1];
681 plsc->curry = y[npts - 1];
700 PLINT t, dx, dy, flipx, flipy;
701 double dydx = 0, dxdy = 0;
706 if ( ( *p_x1 <= xmin && *p_x2 <= xmin ) ||
707 ( *p_x1 >= xmax && *p_x2 >= xmax ) ||
708 ( *p_y1 <= ymin && *p_y2 <= ymin ) ||
709 ( *p_y1 >= ymax && *p_y2 >= ymax ) )
722 *p_x1 = 2 * xmin - *p_x1;
723 *p_x2 = 2 * xmin - *p_x2;
724 xmax = 2 * xmin - xmax;
733 *p_y1 = 2 * ymin - *p_y1;
734 *p_y2 = 2 * ymin - *p_y2;
735 ymax = 2 * ymin - ymax;
745 if ( dx != 0 && dy != 0 )
747 dydx = (double) dy / (
double) dx;
753 if ( dx != 0 && dy != 0 )
754 *p_y1 = *p_y1 +
ROUND( ( xmin - *p_x1 ) * dydx );
760 if ( dx != 0 && dy != 0 )
761 *p_x1 = *p_x1 +
ROUND( ( ymin - *p_y1 ) * dxdy );
765 if ( *p_x1 >= xmax || *p_y1 >= ymax )
770 if ( dx != 0 && dy != 0 )
771 *p_x2 = *p_x2 -
ROUND( ( *p_y2 - ymax ) * dxdy );
777 if ( dx != 0 && dy != 0 )
778 *p_y2 = *p_y2 -
ROUND( ( *p_x2 - xmax ) * dydx );
784 *p_x1 = 2 * xmax - *p_x1;
785 *p_x2 = 2 * xmax - *p_x2;
790 *p_y1 = 2 * ymax - *p_y1;
791 *p_y2 = 2 * ymax - *p_y2;
810 if ( plsc->nms == 0 )
827 if ( plsc->dev_dash )
829 plsc->dev_npts = npts;
836 for ( i = 0; i < npts - 1; i++ )
852 PLINT nx, ny, nxp, nyp, incr, temp;
853 PLINT modulo, dx, dy, i, xtmp, ytmp;
854 PLINT tstep, pix_distance, j;
857 double nxstep, nystep;
866 plsc->alarm = plsc->mark[0];
872 if ( x[0] == x[1] && y[0] == y[1] )
876 dx = ( nx > 0 ) ? 1 : -1;
880 dy = ( ny > 0 ) ? 1 : -1;
900 nxstep = nxp * plsc->umx;
901 nystep = nyp * plsc->umy;
902 tstep = (
PLINT) ( sqrt( nxstep * nxstep + nystep * nystep ) / modulo );
911 pix_distance = ( plsc->alarm - plsc->timecnt + tstep - 1 ) / tstep;
914 pix_distance -= ( i - modulo );
915 plsc->timecnt += pix_distance * tstep;
917 temp += pix_distance * incr;
919 temp = temp % modulo;
923 xtmp += pix_distance * dx;
929 ytmp += pix_distance * dy;
931 if ( plsc->pendn != 0 )
933 xl[0] = (short)
lastx;
934 yl[0] = (short)
lasty;
935 xl[1] = (short) xtmp;
936 yl[1] = (short) ytmp;
942 while ( plsc->timecnt >= plsc->alarm )
944 if ( plsc->pendn != 0 )
947 plsc->timecnt -= plsc->alarm;
948 plsc->alarm = plsc->space[plsc->curel];
953 plsc->timecnt -= plsc->alarm;
955 if ( plsc->curel >= plsc->nms )
957 plsc->alarm = plsc->mark[plsc->curel];
983 if ( ( values = (
PLFLT *) malloc( (
size_t) n *
sizeof (
PLFLT ) ) ) == NULL )
988 step_size = ( b - a ) / (
PLFLT) ( n - 1 );
989 for ( i = 0; i < n; i++ )
991 values[i] = a + step_size * (
PLFLT) i;
void c_plline3(PLINT n, PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_VECTOR z)
void plexit(PLCHAR_VECTOR errormsg)
void plP_esc(PLINT op, void *ptr)
const PLBOOL * PLBOOL_VECTOR
void plP_pllclp(PLINT *x, PLINT *y, PLINT npts, PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax, void(*draw)(short *, short *, PLINT))
void plP_movwor(PLFLT x, PLFLT y)
void plP_grange(PLFLT *p_zscl, PLFLT *p_zmin, PLFLT *p_zmax)
int plP_clipline(PLINT *p_x1, PLINT *p_y1, PLINT *p_x2, PLINT *p_y2, PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax)
void plabort(PLCHAR_VECTOR errormsg)
static PLFLT * interpolate_between(int n, PLFLT a, PLFLT b)
static void grdashline(short *x, short *y)
void plP_polyline(short *x, short *y, PLINT npts)
static void genlin(short *x, short *y, PLINT npts)
#define TRANSFORM(x, y, xnew, ynew)
static void pllclp(PLINT *x, PLINT *y, PLINT npts)
const PLINT * PLINT_VECTOR
void c_plline(PLINT n, PLFLT_VECTOR x, PLFLT_VECTOR y)
void plP_drawor_poly(PLFLT_VECTOR x, PLFLT_VECTOR y, PLINT n)
PLFLT plP_w3wcy(PLFLT x, PLFLT y, PLFLT z)
void c_pljoin(PLFLT x1, PLFLT y1, PLFLT x2, PLFLT y2)
void c_plpoly3(PLINT n, PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_VECTOR z, PLBOOL_VECTOR draw, PLBOOL ifcc)
void plP_draphy(PLINT x, PLINT y)
PLFLT plP_w3wcx(PLFLT x, PLFLT y, PLFLT PL_UNUSED(z))
void plP_draphy_poly(PLINT *x, PLINT *y, PLINT n)
void plP_movphy(PLINT x, PLINT y)
void plP_drawor(PLFLT x, PLFLT y)
static PLINT xline[PL_MAXPOLY]
void plP_line(short *x, short *y)
void c_plstyl(PLINT nms, PLINT_VECTOR mark, PLINT_VECTOR space)
const PLFLT * PLFLT_VECTOR
void c_plpath(PLINT n, PLFLT x1, PLFLT y1, PLFLT x2, PLFLT y2)
void plP_gdom(PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax)
static PLINT yline[PL_MAXPOLY]