/** *@brief * Draw a vector between points "from" and "to", with the option of * having an arrowhead on either or both ends. * * The fromheadfract and toheadfract values indicate the length of the * arrowheads relative to the length of the vector to-from. A typical * value is 0.1, making the head 10% of the size of the vector. The * sign of the "fract" values indicates the pointing direction. * Positive points towards the "to" point, negative points towards * "from". Upon return, the virtual pen is left at the "to" position. */ void tp_3vector(FILE *plotfp, fastf_t *from, fastf_t *to, double fromheadfract, double toheadfract) { register fastf_t len; register fastf_t hooklen; vect_t diff; vect_t c1, c2; vect_t h1, h2; vect_t backup; point_t tip; pdv_3line(plotfp, from, to); /* "pen" is left at "to" position */ VSUB2(diff, to, from); if ((len = MAGNITUDE(diff)) < SMALL) return; VSCALE(diff, diff, 1/len); bn_vec_ortho(c1, diff); VCROSS(c2, c1, diff); if (!ZERO(fromheadfract)) { hooklen = fromheadfract*len; VSCALE(backup, diff, -hooklen); VSCALE(h1, c1, hooklen); VADD3(tip, from, h1, backup); pdv_3move(plotfp, from); pdv_3cont(plotfp, tip); VSCALE(h2, c2, hooklen); VADD3(tip, from, h2, backup); pdv_3move(plotfp, tip); } if (!ZERO(toheadfract)) { hooklen = toheadfract*len; VSCALE(backup, diff, -hooklen); VSCALE(h1, c1, hooklen); VADD3(tip, to, h1, backup); pdv_3move(plotfp, to); pdv_3cont(plotfp, tip); VSCALE(h2, c2, hooklen); VADD3(tip, to, h2, backup); pdv_3move(plotfp, tip); } /* Be certain "pen" is left at "to" position */ if (!ZERO(fromheadfract) || !ZERO(toheadfract)) pdv_3cont(plotfp, to); }
void rt_vlist_to_uplot(FILE *fp, const struct bu_list *vhead) { register struct bn_vlist *vp; for (BU_LIST_FOR(vp, bn_vlist, vhead)) { register int i; register int nused = vp->nused; register const int *cmd = vp->cmd; register point_t *pt = vp->pt; for (i = 0; i < nused; i++, cmd++, pt++) { switch (*cmd) { case BN_VLIST_POLY_START: case BN_VLIST_TRI_START: break; case BN_VLIST_POLY_MOVE: case BN_VLIST_LINE_MOVE: case BN_VLIST_TRI_MOVE: pdv_3move(fp, *pt); break; case BN_VLIST_POLY_DRAW: case BN_VLIST_POLY_END: case BN_VLIST_LINE_DRAW: case BN_VLIST_TRI_DRAW: case BN_VLIST_TRI_END: pdv_3cont(fp, *pt); break; default: bu_log("rt_vlist_to_uplot: unknown vlist cmd x%x\n", *cmd); } } } }
int main(int argc, char *argv) { double xyz[3]; int i; int first = 1; for (;;) { xyz[0] = xyz[1] = xyz[2] = 0.0; buf[0] = '\0'; bu_fgets( buf, sizeof(buf), stdin ); if ( feof(stdin) ) break; i = sscanf( buf, "%lf %lf %lf", &xyz[0], &xyz[1], &xyz[2] ); if (debug) { fprintf(stderr, "buf=%s", buf); fprintf(stderr, "%d: %f\t%f\t%f\n", i, xyz[0], xyz[1], xyz[2] ); } if ( i <= 0 ) break; if ( first ) { first = 0; pdv_3move( stdout, xyz ); } else { pdv_3cont( stdout, xyz ); } } return 0; }
void plot_face(ON_3dPoint *pt1, ON_3dPoint *pt2, ON_3dPoint *pt3, int r, int g, int b, FILE *c_plot) { point_t p1, p2, p3; VSET(p1, pt1->x, pt1->y, pt1->z); VSET(p2, pt2->x, pt2->y, pt2->z); VSET(p3, pt3->x, pt3->y, pt3->z); pl_color(c_plot, r, g, b); pdv_3move(c_plot, p1); pdv_3cont(c_plot, p2); pdv_3move(c_plot, p1); pdv_3cont(c_plot, p3); pdv_3move(c_plot, p2); pdv_3cont(c_plot, p3); }
/** * Draw a ray */ void pdv_3ray(FILE *fp, const fastf_t *pt, const fastf_t *dir, double t) { point_t tip; VJOIN1( tip, pt, t, dir ); pdv_3move( fp, pt ); pdv_3cont( fp, tip ); }
HIDDEN void plot_obr(int test_num, const point_t *pnt_array, int pnt_cnt) { int i = 0; struct bu_vls name; FILE *plot_file = NULL; bu_vls_init(&name); bu_vls_printf(&name, "obr_test_%.3d.pl", test_num); plot_file = fopen(bu_vls_addr(&name), "w"); pl_color(plot_file, 0, 255, 0); for (i = 0; i < pnt_cnt; i++) { pdv_3move(plot_file, pnt_array[i]); if (i < pnt_cnt - 1) { pdv_3cont(plot_file, pnt_array[i+1]); } else { pdv_3cont(plot_file, pnt_array[0]); } } fclose(plot_file); bu_vls_free(&name); }
void view_eol(struct application *UNUSED(ap)) { struct cell *posp; size_t i; int cont; /* continue flag */ posp = &(cellp[0]); cont = 0; /* Plot the starting point and set cont to 0. Then * march along the entire array and continue to plot the * hit points based on their distance from the emanation * plane. When consecutive hit-points with identical distances * are found, cont is set to one so that the entire sequence * of like-distanced hit-points can be plotted together. */ pdv_3move( outfp, posp->c_hit ); for ( i = 0; i < width-1; i++, posp++ ) { if (EQUAL(posp->c_dist, (posp+1)->c_dist)) { cont = 1; continue; } else { if (cont) { pdv_3cont(outfp, posp->c_hit); cont = 0; } pdv_3cont(outfp, (posp+1)->c_hit); } } /* Catch the boundary condition if the last couple of cells * heve the same distance. */ pdv_3cont(outfp, posp->c_hit); }
/* * T P _ 3 S Y M B O L */ void tp_3symbol(FILE *fp, char *string, fastf_t *origin, fastf_t *rot, double scale) /* string of chars to be plotted */ /* lower left corner of 1st char */ /* Transform matrix (WARNING: may xlate) */ /* scale factor to change 1x1 char sz */ { register unsigned char *cp; double offset; /* offset of char from given x, y */ int ysign; /* sign of y motion, either +1 or -1 */ vect_t temp; vect_t loc; mat_t xlate_to_origin; mat_t mat; if ( string == NULL || *string == '\0' ) return; /* done before begun! */ /* * The point "origin" will be the center of the axis rotation. * The text is located in a local coordinate system with the * lower left corner of the first character at (0, 0, 0), with * the text proceeding onward towards +X. * We need to rotate the text around its local (0, 0, 0), * and then translate to the user's designated "origin". * If the user provided translation or * scaling in his matrix, it will *also* be applied. */ MAT_IDN( xlate_to_origin ); MAT_DELTAS_VEC( xlate_to_origin, origin ); bn_mat_mul( mat, xlate_to_origin, rot ); /* Check to see if initialization is needed */ if ( tp_cindex[040] == 0 ) tp_setup(); /* Draw each character in the input string */ offset = 0; for ( cp = (unsigned char *)string; *cp; cp++, offset += scale ) { register int *p; /* pointer to stroke table */ register int stroke; VSET( temp, offset, 0, 0 ); MAT4X3PNT( loc, mat, temp ); pdv_3move( fp, loc ); for ( p = tp_cindex[*cp]; (stroke= *p) != LAST; p++ ) { int draw; if ( stroke==NEGY ) { ysign = (-1); stroke = *++p; } else ysign = 1; /* Detect & process pen control */ if ( stroke < 0 ) { stroke = -stroke; draw = 0; } else draw = 1; /* stroke co-ordinates in string coord system */ VSET( temp, (stroke/11) * 0.1 * scale + offset, (ysign * (stroke%11)) * 0.1 * scale, 0 ); MAT4X3PNT( loc, mat, temp ); if ( draw ) pdv_3cont( fp, loc ); else pdv_3move( fp, loc ); } } }