home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume24
/
gnuplot3
/
part21
< prev
next >
Wrap
Text File
|
1991-10-28
|
49KB
|
1,735 lines
Newsgroups: comp.sources.misc
From: gershon%gr@cs.utah.edu (Elber Gershon)
Subject: v24i043: gnuplot3 - interactive function plotting utility, Part21/26
Message-ID: <1991Oct29.030950.4051@sparky.imd.sterling.com>
X-Md4-Signature: fc51f63e22070950a7dde62c0c005b02
Date: Tue, 29 Oct 1991 03:09:50 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: gershon%gr@cs.utah.edu (Elber Gershon)
Posting-number: Volume 24, Issue 43
Archive-name: gnuplot3/part21
Environment: UNIX, MS-DOS, VMS
Supersedes: gnuplot2: Volume 11, Issue 65-79
#!/bin/sh
# this is Part.21 (part 21 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file gnuplot/graph3d.c continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 21; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping gnuplot/graph3d.c'
else
echo 'x - continuing file gnuplot/graph3d.c'
sed 's/^X//' << 'SHAR_EOF' >> 'gnuplot/graph3d.c' &&
static double make_3dtics(tmin,tmax,axis,logscale)
double tmin,tmax;
int axis;
BOOLEAN logscale;
{
int len,x1,y1,x2,y2;
register double xr,xnorm,tics,tic,l10;
X
X xr = fabs(tmin-tmax);
X
X /* Compute length of axis in screen space coords. */
X switch (axis) {
X case 'x':
X map3d_xy(tmin,0.0,0.0,&x1,&y1);
X map3d_xy(tmax,0.0,0.0,&x2,&y2);
X break;
X case 'y':
X map3d_xy(0.0,tmin,0.0,&x1,&y1);
X map3d_xy(0.0,tmax,0.0,&x2,&y2);
X break;
X case 'z':
X map3d_xy(0.0,0.0,tmin,&x1,&y1);
X map3d_xy(0.0,0.0,tmax,&x2,&y2);
X break;
X }
X
X if (((long) (x1-x2))*(x1-x2) + ((long) (y1-y2))*(y1-y2) <
X sqr(3L * term_tbl[term].h_char))
X return -1.0; /* No tics! */
X
X l10 = log10(xr);
X if (logscale) {
X tic = dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
X if (tic < 1.0)
X tic = 1.0;
X } else {
X xnorm = pow(10.0,l10-(double)((l10 >= 0.0 ) ? (int)l10 : ((int)l10-1)));
X if (xnorm <= 5)
X tics = 0.5;
X else tics = 1.0;
X tic = tics * dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
X }
X return(tic);
}
X
do_3dplot(plots, pcount, min_x, max_x, min_y, max_y, min_z, max_z)
struct surface_points *plots;
int pcount; /* count of plots in linked list */
double min_x, max_x;
double min_y, max_y;
double min_z, max_z;
{
register struct termentry *t = &term_tbl[term];
register int surface, xaxis_y, yaxis_x;
register struct surface_points *this_plot;
int xl, yl;
X /* only a Pyramid would have this many registers! */
double xtemp, ytemp, ztemp, temp;
struct text_label *this_label;
struct arrow_def *this_arrow;
BOOLEAN scaling;
transform_matrix mat;
X
/* Initiate transformation matrix using the global view variables. */
X mat_rot_z(surface_rot_z, trans_mat);
X mat_rot_x(surface_rot_x, mat);
X mat_mult(trans_mat, trans_mat, mat);
X mat_scale(surface_scale / 2.0, surface_scale / 2.0, surface_scale / 2.0, mat);
X mat_mult(trans_mat, trans_mat, mat);
X
/* modify min_z/max_z so it will zscale properly. */
X ztemp = (max_z - min_z) / (2.0 * surface_zscale);
X temp = (max_z + min_z) / 2.0;
X min_z = temp - ztemp;
X max_z = temp + ztemp;
X
/* store these in variables global to this file */
/* otherwise, we have to pass them around a lot */
X x_min3d = min_x;
X x_max3d = max_x;
X y_min3d = min_y;
X y_max3d = max_y;
X z_min3d = min_z;
X z_max3d = max_z;
X
X if (polar)
X int_error("Can not splot in polar coordinate system.", NO_CARET);
X
X if (z_min3d == VERYLARGE || z_max3d == -VERYLARGE ||
X x_min3d == VERYLARGE || x_max3d == -VERYLARGE ||
X y_min3d == VERYLARGE || y_max3d == -VERYLARGE)
X int_error("all points undefined!", NO_CARET);
X
X /* If we are to draw the bottom grid make sure zmin is updated properly. */
X if (xtics || ytics || grid)
X z_min3d -= (max_z - min_z) * ticslevel;
X
/* This used be x_max3d == x_min3d, but that caused an infinite loop once. */
X if (fabs(x_max3d - x_min3d) < zero)
X int_error("x_min3d should not equal x_max3d!",NO_CARET);
X if (fabs(y_max3d - y_min3d) < zero)
X int_error("y_min3d should not equal y_max3d!",NO_CARET);
X if (fabs(z_max3d - z_min3d) < zero)
X int_error("z_min3d should not equal z_max3d!",NO_CARET);
X
/* INITIALIZE TERMINAL */
X if (!term_init) {
X (*t->init)();
X term_init = TRUE;
X }
X screen_ok = FALSE;
X scaling = (*t->scale)(xsize, ysize);
X (*t->graphics)();
X
X /* now compute boundary for plot (xleft, xright, ytop, ybot) */
X boundary3d(scaling);
X
/* SCALE FACTORS */
X zscale3d = 2.0/(z_max3d - z_min3d);
X yscale3d = 2.0/(y_max3d - y_min3d);
X xscale3d = 2.0/(x_max3d - x_min3d);
X
X (*t->linetype)(-2); /* border linetype */
/* PLACE TITLE */
X if (*title != 0) {
X int x, y;
X
X x = title_xoffset * t->h_char;
X y = title_yoffset * t->v_char;
X
X if ((*t->justify_text)(CENTRE))
X (*t->put_text)(x+(xleft+xright)/2,
X y+ytop+(t->v_char), title);
X else
X (*t->put_text)(x+(xleft+xright)/2 - strlen(title)*(t->h_char)/2,
X y+ytop+(t->v_char), title);
X }
X
/* PLACE TIMEDATE */
X if (timedate) {
X int x, y;
X
X x = time_xoffset * t->h_char;
X y = time_yoffset * t->v_char;
X dated = time( (long *) 0);
X tdate = ctime( &dated);
X tdate[24]='\0';
X if ((*t->text_angle)(1)) {
X if ((*t->justify_text)(CENTRE)) {
X (*t->put_text)(x+(t->v_char),
X y+ybot+4*(t->v_char), tdate);
X }
X else {
X (*t->put_text)(x+(t->v_char),
X y+ybot+4*(t->v_char)-(t->h_char)*strlen(ylabel)/2,
X tdate);
X }
X }
X else {
X (void)(*t->justify_text)(LEFT);
X (*t->put_text)(x,
X y+ybot-3*(t->v_char), tdate);
X }
X (void)(*t->text_angle)(0);
X }
X
/* PLACE LABELS */
X for (this_label = first_label; this_label!=NULL;
X this_label=this_label->next ) {
X int x,y;
X
X xtemp = LogScale(this_label->x, log_x, "label", "x");
X ytemp = LogScale(this_label->y, log_y, "label", "y");
X ztemp = LogScale(this_label->z, log_z, "label", "z");
X map3d_xy(xtemp,ytemp,ztemp, &x, &y);
X
X if ((*t->justify_text)(this_label->pos)) {
X (*t->put_text)(x,y,this_label->text);
X }
X else {
X switch(this_label->pos) {
X case LEFT:
X (*t->put_text)(x,y,this_label->text);
X break;
X case CENTRE:
X (*t->put_text)(x -
X (t->h_char)*strlen(this_label->text)/2,
X y, this_label->text);
X break;
X case RIGHT:
X (*t->put_text)(x -
X (t->h_char)*strlen(this_label->text),
X y, this_label->text);
X break;
X }
X }
X }
X
/* PLACE ARROWS */
X (*t->linetype)(0); /* arrow line type */
X for (this_arrow = first_arrow; this_arrow!=NULL;
X this_arrow = this_arrow->next ) {
X int sx,sy,ex,ey;
X
X xtemp = LogScale(this_arrow->sx, log_x, "arrow", "x");
X ytemp = LogScale(this_arrow->sy, log_y, "arrow", "y");
X ztemp = LogScale(this_arrow->sz, log_y, "arrow", "z");
X map3d_xy(xtemp,ytemp,ztemp, &sx, &sy);
X
X xtemp = LogScale(this_arrow->ex, log_x, "arrow", "x");
X ytemp = LogScale(this_arrow->ey, log_y, "arrow", "y");
X ztemp = LogScale(this_arrow->ez, log_y, "arrow", "z");
X map3d_xy(xtemp,ytemp,ztemp, &ex, &ey);
X
X (*t->arrow)(sx, sy, ex, ey, this_arrow->head);
X }
X
X
/* DRAW SURFACES AND CONTOURS */
X real_z_min3d = min_z;
X real_z_max3d = max_z;
X if (key == -1) {
X xl = xright - (t->h_tic) - (t->h_char)*5;
X yl = ytop - (t->v_tic) - (t->v_char);
X }
X if (key == 1) {
X xtemp = LogScale(key_x, log_x, "key", "x");
X ytemp = LogScale(key_y, log_y, "key", "y");
X ztemp = LogScale(key_z, log_z, "key", "z");
X map3d_xy(xtemp,ytemp,ztemp, &xl, &yl);
X }
X
X this_plot = plots;
X for (surface = 0;
X surface < pcount;
X this_plot = this_plot->next_sp, surface++) {
X (*t->linetype)(this_plot->line_type+1);
X
X if (draw_contour && this_plot->contours != NULL) {
X struct gnuplot_contours *cntrs = this_plot->contours;
X
X if (key != 0) {
X if ((*t->justify_text)(RIGHT)) {
X clip_put_text(xl,
X yl,this_plot->title);
X }
X else {
X if (inrange(xl-(t->h_char)*strlen(this_plot->title),
X xleft, xright))
X clip_put_text(xl-(t->h_char)*strlen(this_plot->title),
X yl,this_plot->title);
X }
X switch(this_plot->plot_style) {
X case IMPULSES:
X clip_move(xl+(t->h_char),yl);
X clip_vector(xl+4*(t->h_char),yl);
X break;
X case LINES:
X clip_move(xl+(int)(t->h_char),yl);
X clip_vector(xl+(int)(4*(t->h_char)),yl);
X break;
X case ERRORBARS: /* ignored; treat like points */
X case POINTS:
X if (!clip_point(xl+2*(t->h_char),yl)) {
X (*t->point)(xl+2*(t->h_char),yl,
X this_plot->point_type);
X }
X break;
X case LINESPOINTS:
X clip_move(xl+(int)(t->h_char),yl);
X clip_vector(xl+(int)(4*(t->h_char)),yl);
X break;
X case DOTS:
X if (!clip_point(xl+2*(t->h_char),yl)) {
X (*t->point)(xl+2*(t->h_char),yl, -1);
X }
X break;
X }
X }
X
X while (cntrs) {
X switch(this_plot->plot_style) {
X case IMPULSES:
X cntr3d_impulses(cntrs, this_plot);
X break;
X case LINES:
X cntr3d_lines(cntrs);
X break;
X case ERRORBARS: /* ignored; treat like points */
X case POINTS:
X cntr3d_points(cntrs, this_plot);
X break;
X case LINESPOINTS:
X cntr3d_lines(cntrs);
X cntr3d_points(cntrs, this_plot);
X break;
X case DOTS:
X cntr3d_dots(cntrs);
X break;
X }
X cntrs = cntrs->next;
X }
X if (key != 0) yl = yl - (t->v_char);
X }
X
X if ( surface == 0 )
X draw_bottom_grid(this_plot,real_z_min3d,real_z_max3d);
X
X if (!draw_surface) continue;
X (*t->linetype)(this_plot->line_type);
X
X if (key != 0) {
X if ((*t->justify_text)(RIGHT)) {
X clip_put_text(xl,
X yl,this_plot->title);
X }
X else {
X if (inrange(xl-(t->h_char)*strlen(this_plot->title),
X xleft, xright))
X clip_put_text(xl-(t->h_char)*strlen(this_plot->title),
X yl,this_plot->title);
X }
X }
X
X switch(this_plot->plot_style) {
X case IMPULSES: {
X if (key != 0) {
X clip_move(xl+(t->h_char),yl);
X clip_vector(xl+4*(t->h_char),yl);
X }
X plot3d_impulses(this_plot);
X break;
X }
X case LINES: {
X if (key != 0) {
X clip_move(xl+(int)(t->h_char),yl);
X clip_vector(xl+(int)(4*(t->h_char)),yl);
X }
X plot3d_lines(this_plot);
X break;
X }
X case ERRORBARS: /* ignored; treat like points */
X case POINTS: {
X if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
X (*t->point)(xl+2*(t->h_char),yl,
X this_plot->point_type);
X }
X plot3d_points(this_plot);
X break;
X }
X case LINESPOINTS: {
X /* put lines */
X if (key != 0) {
X clip_move(xl+(t->h_char),yl);
X clip_vector(xl+4*(t->h_char),yl);
X }
X plot3d_lines(this_plot);
X
X /* put points */
X if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
X (*t->point)(xl+2*(t->h_char),yl,
X this_plot->point_type);
X }
X plot3d_points(this_plot);
X break;
X }
X case DOTS: {
X if (key != 0 && !clip_point(xl+2*(t->h_char),yl)) {
X (*t->point)(xl+2*(t->h_char),yl, -1);
X }
X plot3d_dots(this_plot);
X break;
X }
X }
X yl = yl - (t->v_char);
X }
X (*t->text)();
X (void) fflush(outfile);
}
X
/* plot3d_impulses:
X * Plot the surfaces in IMPULSES style
X */
static plot3d_impulses(plot)
X struct surface_points *plot;
{
X int i; /* point index */
X int x,y,x0,y0; /* point in terminal coordinates */
X struct termentry *t = &term_tbl[term];
X struct iso_curve *icrvs = plot->iso_crvs;
X
X while ( icrvs ) {
X struct coordinate *points = icrvs->points;
X
X for (i = 0; i < icrvs->p_count; i++) {
X if (real_z_max3d<points[i].z)
X real_z_max3d=points[i].z;
X if (real_z_min3d>points[i].z)
X real_z_min3d=points[i].z;
X
X map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
X map3d_xy(points[i].x, points[i].y, z_min3d, &x0, &y0);
X
X clip_move(x0,y0);
X clip_vector(x,y);
X }
X
X icrvs = icrvs->next;
X }
}
X
/* plot3d_lines:
X * Plot the surfaces in LINES style
X */
static plot3d_lines(plot)
X struct surface_points *plot;
{
X int i;
X int x,y; /* point in terminal coordinates */
X struct termentry *t = &term_tbl[term];
X struct iso_curve *icrvs = plot->iso_crvs;
X
X while ( icrvs ) {
X struct coordinate *points = icrvs->points;
X
X for (i = 0; i < icrvs->p_count; i++) {
X if (real_z_max3d<points[i].z)
X real_z_max3d=points[i].z;
X if (real_z_min3d>points[i].z)
X real_z_min3d=points[i].z;
X
X map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
X
X if (i > 0)
X clip_vector(x,y);
X else
X clip_move(x,y);
X }
X
X icrvs = icrvs->next;
X }
}
X
/* plot3d_points:
X * Plot the surfaces in POINTS style
X */
static plot3d_points(plot)
X struct surface_points *plot;
{
X int i,x,y;
X struct termentry *t = &term_tbl[term];
X struct iso_curve *icrvs = plot->iso_crvs;
X
X while ( icrvs ) {
X struct coordinate *points = icrvs->points;
X
X for (i = 0; i < icrvs->p_count; i++) {
X if (real_z_max3d<points[i].z)
X real_z_max3d=points[i].z;
X if (real_z_min3d>points[i].z)
X real_z_min3d=points[i].z;
X
X map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
X
X if (!clip_point(x,y))
X (*t->point)(x,y, plot->point_type);
X }
X
X icrvs = icrvs->next;
X }
}
X
/* plot3d_dots:
X * Plot the surfaces in DOTS style
X */
static plot3d_dots(plot)
X struct surface_points *plot;
{
X int i,x,y;
X struct termentry *t = &term_tbl[term];
X struct iso_curve *icrvs = plot->iso_crvs;
X
X while ( icrvs ) {
X struct coordinate *points = icrvs->points;
X
X for (i = 0; i < icrvs->p_count; i++) {
X if (real_z_max3d<points[i].z)
X real_z_max3d=points[i].z;
X if (real_z_min3d>points[i].z)
X real_z_min3d=points[i].z;
X
X map3d_xy(points[i].x, points[i].y, points[i].z, &x, &y);
X
X if (!clip_point(x,y))
X (*t->point)(x,y, -1);
X }
X
X icrvs = icrvs->next;
X }
}
X
/* cntr3d_impulses:
X * Plot a surface contour in IMPULSES style
X */
static cntr3d_impulses(cntr, plot)
X struct gnuplot_contours *cntr;
X struct surface_points *plot;
{
X int i,j,k; /* point index */
X int x,y,x0,y0; /* point in terminal coordinates */
X struct termentry *t = &term_tbl[term];
X
X if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
X &x, &y);
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
X &x0, &y0);
X
X clip_move(x0,y0);
X clip_vector(x,y);
X }
X }
X else
X cntr3d_points(cntr, plot); /* Must be on base grid, so do points. */
}
X
/* cntr3d_lines:
X * Plot a surface contour in LINES style
X */
static cntr3d_lines(cntr)
X struct gnuplot_contours *cntr;
{
X int i,j,k; /* point index */
X int x,y; /* point in terminal coordinates */
X struct termentry *t = &term_tbl[term];
X
X if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
X &x, &y);
X
X if (i > 0)
X clip_vector(x,y);
X else
X clip_move(x,y);
X }
X }
X
X if (draw_contour == CONTOUR_BASE || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
X &x, &y);
X
X if (i > 0)
X clip_vector(x,y);
X else
X clip_move(x,y);
X }
X }
}
X
/* cntr3d_points:
X * Plot a surface contour in POINTS style
X */
static cntr3d_points(cntr, plot)
X struct gnuplot_contours *cntr;
X struct surface_points *plot;
{
X int i,j,k;
X int x,y;
X struct termentry *t = &term_tbl[term];
X
X if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
X &x, &y);
X
X if (!clip_point(x,y))
X (*t->point)(x,y, plot->point_type);
X }
X }
X
X if (draw_contour == CONTOUR_BASE || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
X &x, &y);
X
X if (!clip_point(x,y))
X (*t->point)(x,y, plot->point_type);
X }
X }
}
X
/* cntr3d_dots:
X * Plot a surface contour in DOTS style
X */
static cntr3d_dots(cntr)
X struct gnuplot_contours *cntr;
{
X int i,j,k;
X int x,y;
X struct termentry *t = &term_tbl[term];
X
X if (draw_contour == CONTOUR_SRF || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, cntr->coords[i].z,
X &x, &y);
X
X if (!clip_point(x,y))
X (*t->point)(x,y, -1);
X }
X }
X
X if (draw_contour == CONTOUR_BASE || draw_contour == CONTOUR_BOTH) {
X for (i = 0; i < cntr->num_pts; i++) {
X if (real_z_max3d<cntr->coords[i].z)
X real_z_max3d=cntr->coords[i].z;
X if (real_z_min3d>cntr->coords[i].z)
X real_z_min3d=cntr->coords[i].z;
X
X map3d_xy(cntr->coords[i].x, cntr->coords[i].y, z_min3d,
X &x, &y);
X
X if (!clip_point(x,y))
X (*t->point)(x,y, -1);
X }
X }
}
X
static update_extrema_pts(ix, iy, min_sx_x, min_sx_y, min_sy_x, min_sy_y,
X x, y)
X int ix, iy, *min_sx_x, *min_sx_y, *min_sy_x, *min_sy_y;
X double x, y;
{
X
X if (*min_sx_x > ix + 2 || /* find (bottom) left corner of grid */
X (abs(*min_sx_x - ix) <= 2 && *min_sx_y > iy)) {
X *min_sx_x = ix;
X *min_sx_y = iy;
X min_sx_ox = x;
X min_sx_oy = y;
X }
X if (*min_sy_y > iy + 2 || /* find bottom (right) corner of grid */
X (abs(*min_sy_y - iy) <= 2 && *min_sy_x < ix)) {
X *min_sy_x = ix;
X *min_sy_y = iy;
X min_sy_ox = x;
X min_sy_oy = y;
X }
}
X
/* Draw the bottom grid for the parametric case. */
static draw_parametric_grid(plot)
X struct surface_points *plot;
{
X int i,ix,iy, /* point in terminal coordinates */
X min_sx_x = 10000,min_sx_y = 10000,min_sy_x = 10000,min_sy_y = 10000,
X grid_iso = plot->plot_type == DATA3D && plot->has_grid_topology ?
X plot->num_iso_read : iso_samples;
X double x,y,dx,dy;
X struct termentry *t = &term_tbl[term];
X
X if (grid && plot->has_grid_topology) {
X x = x_min3d;
X y = y_min3d;
X
X dx = (x_max3d-x_min3d) / (grid_iso-1);
X dy = (y_max3d-y_min3d) / (grid_iso-1);
X
X for (i = 0; i < grid_iso; i++) {
X if (i == 0 || i == grid_iso-1)
X (*t->linetype)(-2);
X else
X (*t->linetype)(-1);
X map3d_xy(x_min3d, y, z_min3d, &ix, &iy);
X clip_move(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x_min3d,y);
X
X map3d_xy(x_max3d, y, z_min3d, &ix, &iy);
X clip_vector(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x_max3d,y);
X
X y += dy;
X }
X
X for (i = 0; i < grid_iso; i++) {
X if (i == 0 || i == grid_iso-1)
X (*t->linetype)(-2);
X else
X (*t->linetype)(-1);
X map3d_xy(x, y_min3d, z_min3d, &ix, &iy);
X clip_move(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x,y_min3d);
X
X map3d_xy(x, y_max3d, z_min3d, &ix, &iy);
X clip_vector(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x,y_max3d);
X
X x += dx;
X }
X }
X else {
X (*t->linetype)(-2);
X
X map3d_xy(x_min3d, y_min3d, z_min3d, &ix, &iy);
X clip_move(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x_min3d,y_min3d);
X
X map3d_xy(x_max3d, y_min3d, z_min3d, &ix, &iy);
X clip_vector(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x_max3d,y_min3d);
X
X map3d_xy(x_max3d, y_max3d, z_min3d, &ix, &iy);
X clip_vector(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x_max3d,y_max3d);
X
X map3d_xy(x_min3d, y_max3d, z_min3d, &ix, &iy);
X clip_vector(ix,iy);
X update_extrema_pts(ix,iy,&min_sx_x,&min_sx_y,
X &min_sy_x,&min_sy_y,x_min3d,y_max3d);
X
X
X map3d_xy(x_min3d, y_min3d, z_min3d, &ix, &iy);
X clip_vector(ix,iy);
X }
}
X
/* Draw the bottom grid for non parametric case. */
static draw_non_param_grid(plot)
X struct surface_points *plot;
{
X int i,is_boundary=TRUE,crv_count=0,
X x,y, /* point in terminal coordinates */
X min_sx_x = 10000,min_sx_y = 10000,min_sy_x = 10000,min_sy_y = 10000,
X grid_samples = plot->plot_type == DATA3D && plot->has_grid_topology ?
X plot->iso_crvs->p_count : samples,
X grid_iso = plot->plot_type == DATA3D && plot->has_grid_topology ?
X plot->num_iso_read : iso_samples;
X struct termentry *t = &term_tbl[term];
X struct iso_curve *icrvs = plot->iso_crvs;
X
X while ( icrvs ) {
X struct coordinate *points = icrvs->points;
X
X for (i = 0; i < icrvs->p_count; i += icrvs->p_count-1) {
X map3d_xy(points[i].x, points[i].y, z_min3d, &x, &y);
X if (is_boundary) {
X (*t->linetype)(-2);
X }
X else {
X (*t->linetype)(-1);
X }
X
X if (i > 0) {
X clip_vector(x,y);
X }
X else {
X clip_move(x,y);
X }
X
X if (draw_surface &&
X is_boundary &&
X (i == 0 || i == icrvs->p_count-1)) {
X int x1,y1; /* point in terminal coordinates */
X
X /* Draw a vertical line to surface corner from grid corner. */
X map3d_xy(points[i].x, points[i].y, points[i].z, &x1, &y1);
X clip_vector(x1,y1);
X clip_move(x,y);
X update_extrema_pts(x,y,&min_sx_x,&min_sx_y, &min_sy_x,&min_sy_y,
X points[i].x,points[i].y);
X }
X }
X
X if (grid) {
X crv_count++;
X icrvs = icrvs->next;
X is_boundary = crv_count == grid_iso - 1 ||
X crv_count == grid_iso ||
X (icrvs && icrvs->next == NULL);
X }
X else {
X switch (crv_count++) {
X case 0:
X for (i = 0; i < grid_iso - 1; i++)
X icrvs = icrvs->next;
X break;
X case 1:
X icrvs = icrvs->next;
X break;
X case 2:
X while (icrvs->next)
X icrvs = icrvs->next;
X break;
X case 3:
X icrvs = NULL;
X break;
X }
X }
X }
}
X
/* Draw the bottom grid that hold the tic marks for 3d surface. */
static draw_bottom_grid(plot, min_z, max_z)
X struct surface_points *plot;
X double min_z, max_z;
{
X int i,j,k; /* point index */
X int x,y,min_x = 10000,min_y = 10000;/* point in terminal coordinates */
X double xtic,ytic,ztic;
X struct termentry *t = &term_tbl[term];
X
X xtic = make_3dtics(x_min3d,x_max3d,'x',log_x);
X ytic = make_3dtics(y_min3d,y_max3d,'y',log_y);
X ztic = make_3dtics(min_z,max_z,'z',log_z);
X
X if (draw_border)
X if (parametric || !plot->has_grid_topology)
X draw_parametric_grid(plot);
X else
X draw_non_param_grid(plot);
X
X (*t->linetype)(-2); /* border linetype */
X
/* label x axis tics */
X if (xtics && xtic > 0.0) {
X switch (xticdef.type) {
X case TIC_COMPUTED:
X if (x_min3d < x_max3d)
X draw_3dxtics(xtic * floor(x_min3d/xtic),
X xtic,
X xtic * ceil(x_max3d/xtic),
X min_sy_oy);
X else
X draw_3dxtics(xtic * floor(x_max3d/xtic),
X xtic,
X xtic * ceil(x_min3d/xtic),
X min_sy_oy);
X break;
X case TIC_SERIES:
X draw_series_3dxtics(xticdef.def.series.start,
X xticdef.def.series.incr,
X xticdef.def.series.end,
X min_sy_oy);
X break;
X case TIC_USER:
X draw_set_3dxtics(xticdef.def.user,
X min_sy_oy);
X break;
X default:
X (*t->text)();
X (void) fflush(outfile);
X int_error("unknown tic type in xticdef in do_3dplot", NO_CARET);
X break; /* NOTREACHED */
X }
X }
/* label y axis tics */
X if (ytics && ytic > 0.0) {
X switch (yticdef.type) {
X case TIC_COMPUTED:
X if (y_min3d < y_max3d)
X draw_3dytics(ytic * floor(y_min3d/ytic),
X ytic,
X ytic * ceil(y_max3d/ytic),
X min_sy_ox);
X else
X draw_3dytics(ytic * floor(y_max3d/ytic),
X ytic,
X ytic * ceil(y_min3d/ytic),
X min_sy_ox);
X break;
X case TIC_SERIES:
X draw_series_3dytics(yticdef.def.series.start,
X yticdef.def.series.incr,
X yticdef.def.series.end,
X min_sy_ox);
X break;
X case TIC_USER:
X draw_set_3dytics(yticdef.def.user,
X min_sy_ox);
X break;
X default:
X (*t->text)();
X (void) fflush(outfile);
X int_error("unknown tic type in yticdef in do_3dplot", NO_CARET);
X break; /* NOTREACHED */
X }
X }
/* label z axis tics */
X if (ztics && ztic > 0.0 && (draw_surface ||
X draw_contour == CONTOUR_SRF ||
X draw_contour == CONTOUR_BOTH)) {
X switch (zticdef.type) {
X case TIC_COMPUTED:
X if (min_z < max_z)
X draw_3dztics(ztic * floor(min_z/ztic),
X ztic,
X ztic * ceil(max_z/ztic),
X min_sx_ox,
X min_sx_oy,
X min_z,
X max_z);
X else
X draw_3dztics(ztic * floor(max_z/ztic),
X ztic,
X ztic * ceil(min_z/ztic),
X min_sx_ox,
X min_sx_oy,
X max_z,
X min_z);
X break;
X case TIC_SERIES:
X draw_series_3dztics(zticdef.def.series.start,
X zticdef.def.series.incr,
X zticdef.def.series.end,
X min_sx_ox,
X min_sx_oy,
X min_z,
X max_z);
X
X break;
X case TIC_USER:
X draw_set_3dztics(zticdef.def.user,
X min_sx_ox,
X min_sx_oy,
X min_z,
X max_z);
X break;
X default:
X (*t->text)();
X (void) fflush(outfile);
X int_error("unknown tic type in zticdef in do_3dplot", NO_CARET);
X break; /* NOTREACHED */
X }
X }
X
/* PLACE XLABEL - along the middle grid X axis */
X if (strlen(xlabel) > 0) {
X int x1,y1;
X double step = apx_eq( min_sy_oy, y_min3d ) ? (y_max3d-y_min3d)/4
X : (y_min3d-y_max3d)/4;
X map3d_xy((x_min3d+x_max3d)/2,min_sy_oy-step, z_min3d,&x1,&y1);
X x1 += xlabel_xoffset * t->h_char;
X y1 += xlabel_yoffset * t->v_char;
X if ((*t->justify_text)(CENTRE))
X clip_put_text(x1,y1,xlabel);
X else
X clip_put_text(x1 - strlen(xlabel)*(t->h_char)/2,y1,xlabel);
X }
X
/* PLACE YLABEL - along the middle grid Y axis */
X if (strlen(ylabel) > 0) {
X int x1,y1;
X double step = apx_eq( min_sy_ox, x_min3d ) ? (x_max3d-x_min3d)/4
X : (x_min3d-x_max3d)/4;
X map3d_xy(min_sy_ox-step,(y_min3d+y_max3d)/2,z_min3d,&x1,&y1);
X x1 += ylabel_xoffset * t->h_char;
X y1 += ylabel_yoffset * t->v_char;
X if ((*t->justify_text)(CENTRE))
X clip_put_text(x1,y1,ylabel);
X else
X clip_put_text(x1 - strlen(ylabel)*(t->h_char)/2,y1,ylabel);
X }
X
/* PLACE ZLABEL - along the middle grid Z axis */
X if (strlen(zlabel) > 0 &&
X (draw_surface ||
X draw_contour == CONTOUR_SRF ||
X draw_contour == CONTOUR_BOTH)) {
X map3d_xy(min_sx_ox,min_sx_oy,max_z + (max_z-min_z)/4, &x, &y);
X
X x += zlabel_xoffset * t->h_char;
X y += zlabel_yoffset * t->v_char;
X if ((*t->justify_text)(CENTRE))
X clip_put_text(x,y,zlabel);
X else
X clip_put_text(x - strlen(zlabel)*(t->h_char)/2,y,zlabel);
X }
}
X
/* DRAW_3DXTICS: draw a regular tic series, x axis */
static draw_3dxtics(start, incr, end, ypos)
X double start, incr, end, ypos; /* tic series definition */
X /* assume start < end, incr > 0 */
{
X double ticplace;
X int ltic; /* for mini log tics */
X double lticplace; /* for mini log tics */
X
X end = end + SIGNIF*incr;
X
X for (ticplace = start; ticplace <= end; ticplace +=incr) {
X if (ticplace < x_min3d || ticplace > x_max3d) continue;
X xtick(ticplace, xformat, incr, 1.0, ypos);
X if (log_x && incr == 1.0) {
X /* add mini-ticks to log scale ticmarks */
X for (ltic = 2; ltic <= 9; ltic++) {
X lticplace = ticplace+log10((double)ltic);
X xtick(lticplace, "\0", incr, 0.5, ypos);
X }
X }
X }
}
X
/* DRAW_3DYTICS: draw a regular tic series, y axis */
static draw_3dytics(start, incr, end, xpos)
X double start, incr, end, xpos; /* tic series definition */
X /* assume start < end, incr > 0 */
{
X double ticplace;
X int ltic; /* for mini log tics */
X double lticplace; /* for mini log tics */
X
X end = end + SIGNIF*incr;
X
X for (ticplace = start; ticplace <= end; ticplace +=incr) {
X if (ticplace < y_min3d || ticplace > y_max3d) continue;
X ytick(ticplace, yformat, incr, 1.0, xpos);
X if (log_y && incr == 1.0) {
X /* add mini-ticks to log scale ticmarks */
X for (ltic = 2; ltic <= 9; ltic++) {
X lticplace = ticplace+log10((double)ltic);
X ytick(lticplace, "\0", incr, 0.5, xpos);
X }
X }
X }
}
X
/* DRAW_3DZTICS: draw a regular tic series, z axis */
static draw_3dztics(start, incr, end, xpos, ypos, z_min, z_max)
X double start, incr, end, xpos, ypos, z_min, z_max;
X /* assume start < end, incr > 0 */
{
X int x, y;
X double ticplace;
X int ltic; /* for mini log tics */
X double lticplace; /* for mini log tics */
X register struct termentry *t = &term_tbl[term];
X
X end = end + SIGNIF*incr;
X
X for (ticplace = start; ticplace <= end; ticplace +=incr) {
X if (ticplace < z_min || ticplace > z_max) continue;
X
X ztick(ticplace, zformat, incr, 1.0, xpos, ypos);
X if (log_z && incr == 1.0) {
X /* add mini-ticks to log scale ticmarks */
X for (ltic = 2; ltic <= 9; ltic++) {
X lticplace = ticplace+log10((double)ltic);
X ztick(lticplace, "\0", incr, 0.5, xpos, ypos);
X }
X }
X }
X
X /* Make sure the vertical line is fully drawn. */
X (*t->linetype)(-2); /* axis line type */
X
X map3d_xy(xpos, ypos, z_min3d, &x, &y);
X clip_move(x,y);
X map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
X clip_vector(x,y);
X
X (*t->linetype)(-1); /* border linetype */
}
X
/* DRAW_SERIES_3DXTICS: draw a user tic series, x axis */
static draw_series_3dxtics(start, incr, end, ypos)
X double start, incr, end, ypos; /* tic series definition */
X /* assume start < end, incr > 0 */
{
X double ticplace, place;
X double ticmin, ticmax; /* for checking if tic is almost inrange */
X double spacing = log_x ? log10(incr) : incr;
X
X if (end == VERYLARGE)
X end = max(CheckLog(log_x, x_min3d), CheckLog(log_x, x_max3d));
X else
X /* limit to right side of plot */
X end = min(end, max(CheckLog(log_x, x_min3d), CheckLog(log_x, x_max3d)));
X
X /* to allow for rounding errors */
X ticmin = min(x_min3d,x_max3d) - SIGNIF*incr;
X ticmax = max(x_min3d,x_max3d) + SIGNIF*incr;
X end = end + SIGNIF*incr;
X
X for (ticplace = start; ticplace <= end; ticplace +=incr) {
X place = (log_x ? log10(ticplace) : ticplace);
X if ( inrange(place,ticmin,ticmax) )
X xtick(place, xformat, spacing, 1.0, ypos);
X }
}
X
/* DRAW_SERIES_3DYTICS: draw a user tic series, y axis */
static draw_series_3dytics(start, incr, end, xpos)
X double start, incr, end, xpos; /* tic series definition */
X /* assume start < end, incr > 0 */
{
X double ticplace, place;
X double ticmin, ticmax; /* for checking if tic is almost inrange */
X double spacing = log_y ? log10(incr) : incr;
X
X if (end == VERYLARGE)
X end = max(CheckLog(log_y, y_min3d), CheckLog(log_y, y_max3d));
X else
X /* limit to right side of plot */
X end = min(end, max(CheckLog(log_y, y_min3d), CheckLog(log_y, y_max3d)));
X
X /* to allow for rounding errors */
X ticmin = min(y_min3d,y_max3d) - SIGNIF*incr;
X ticmax = max(y_min3d,y_max3d) + SIGNIF*incr;
X end = end + SIGNIF*incr;
X
X for (ticplace = start; ticplace <= end; ticplace +=incr) {
X place = (log_y ? log10(ticplace) : ticplace);
X if ( inrange(place,ticmin,ticmax) )
X ytick(place, xformat, spacing, 1.0, xpos);
X }
}
X
/* DRAW_SERIES_3DZTICS: draw a user tic series, z axis */
static draw_series_3dztics(start, incr, end, xpos, ypos, z_min, z_max)
X double start, incr, end; /* tic series definition */
X double xpos, ypos, z_min, z_max;
X /* assume start < end, incr > 0 */
{
X int x, y;
X double ticplace, place;
X double ticmin, ticmax; /* for checking if tic is almost inrange */
X double spacing = log_x ? log10(incr) : incr;
X register struct termentry *t = &term_tbl[term];
X
X if (end == VERYLARGE)
X end = max(CheckLog(log_z, z_min), CheckLog(log_z, z_max));
X else
X /* limit to right side of plot */
X end = min(end, max(CheckLog(log_z, z_min), CheckLog(log_z, z_max)));
X
X /* to allow for rounding errors */
X ticmin = min(z_min,z_max) - SIGNIF*incr;
X ticmax = max(z_min,z_max) + SIGNIF*incr;
X end = end + SIGNIF*incr;
X
X for (ticplace = start; ticplace <= end; ticplace +=incr) {
X place = (log_z ? log10(ticplace) : ticplace);
X if ( inrange(place,ticmin,ticmax) )
X ztick(place, zformat, spacing, 1.0, xpos, ypos);
X }
X
X /* Make sure the vertical line is fully drawn. */
X (*t->linetype)(-2); /* axis line type */
X
X map3d_xy(xpos, ypos, z_min3d, &x, &y);
X clip_move(x,y);
X map3d_xy(xpos, ypos, min(end,z_max)+(log_z ? incr : 0.0), &x, &y);
X clip_vector(x,y);
X
X (*t->linetype)(-1); /* border linetype */
}
X
/* DRAW_SET_3DXTICS: draw a user tic set, x axis */
static draw_set_3dxtics(list, ypos)
X struct ticmark *list; /* list of tic marks */
X double ypos;
{
X double ticplace;
X double incr = (x_max3d - x_min3d) / 10;
X /* global x_min3d, x_max3d, xscale, y_min3d, y_max3d, yscale */
X
X while (list != NULL) {
X ticplace = (log_x ? log10(list->position) : list->position);
X if ( inrange(ticplace, x_min3d, x_max3d) /* in range */
X || NearlyEqual(ticplace, x_min3d, incr) /* == x_min */
X || NearlyEqual(ticplace, x_max3d, incr)) /* == x_max */
X xtick(ticplace, list->label, incr, 1.0, ypos);
X
X list = list->next;
X }
}
X
/* DRAW_SET_3DYTICS: draw a user tic set, y axis */
static draw_set_3dytics(list, xpos)
X struct ticmark *list; /* list of tic marks */
X double xpos;
{
X double ticplace;
X double incr = (y_max3d - y_min3d) / 10;
X /* global x_min3d, x_max3d, xscale, y_min3d, y_max3d, yscale */
X
X while (list != NULL) {
X ticplace = (log_y ? log10(list->position) : list->position);
X if ( inrange(ticplace, y_min3d, y_max3d) /* in range */
X || NearlyEqual(ticplace, y_min3d, incr) /* == y_min3d */
X || NearlyEqual(ticplace, y_max3d, incr)) /* == y_max3d */
X ytick(ticplace, list->label, incr, 1.0, xpos);
X
X list = list->next;
X }
}
X
/* DRAW_SET_3DZTICS: draw a user tic set, z axis */
static draw_set_3dztics(list, xpos, ypos, z_min, z_max)
X struct ticmark *list; /* list of tic marks */
X double xpos, ypos, z_min, z_max;
{
X int x, y;
X double ticplace;
X double incr = (z_max - z_min) / 10;
X register struct termentry *t = &term_tbl[term];
X
X while (list != NULL) {
X ticplace = (log_z ? log10(list->position) : list->position);
X if ( inrange(ticplace, z_min, z_max) /* in range */
X || NearlyEqual(ticplace, z_min, incr) /* == z_min */
X || NearlyEqual(ticplace, z_max, incr)) /* == z_max */
X ztick(ticplace, list->label, incr, 1.0, xpos, ypos);
X
X list = list->next;
X }
X
X /* Make sure the vertical line is fully drawn. */
X (*t->linetype)(-2); /* axis line type */
X
X map3d_xy(xpos, ypos, z_min, &x, &y);
X clip_move(x,y);
X map3d_xy(xpos, ypos, z_max+(log_z ? incr : 0.0), &x, &y);
X clip_vector(x,y);
X
X (*t->linetype)(-1); /* border linetype */
}
X
/* draw and label a x-axis ticmark */
static xtick(place, text, spacing, ticscale, ypos)
X double place; /* where on axis to put it */
X char *text; /* optional text label */
X double spacing; /* something to use with checkzero */
X double ticscale; /* scale factor for tic mark (0..1] */
X double ypos;
{
X register struct termentry *t = &term_tbl[term];
X char ticlabel[101];
X int x0,y0,x1,y1,x2,y2,x3,y3;
X int ticsize = (int)((t->h_tic) * ticscale);
X double v[2], len;
X
X place = CheckZero(place,spacing); /* to fix rounding error near zero */
X
X if (place > x_max3d || place < x_min3d) return;
X
X map3d_xy(place, ypos, z_min3d, &x0, &y0);
X /* need to figure out which is in. pick the middle point along the */
X /* axis as in. */
X map3d_xy(place, (y_max3d + y_min3d) / 2, z_min3d, &x1, &y1);
X
X /* compute a vector of length 1 into the grid: */
X v[0] = x1 - x0;
X v[1] = y1 - y0;
X len = sqrt(v[0] * v[0] + v[1] * v[1]);
X v[0] /= len;
X v[1] /= len;
X
X if (tic_in) {
X x1 = x0;
X y1 = y0;
X x2 = x1 + ((int) (v[0] * ticsize));
X y2 = y1 + ((int) (v[1] * ticsize));
X x3 = x0 - ((int) (v[0] * ticsize * 3)); /* compute text position */
X y3 = y0 - ((int) (v[1] * ticsize * 3));
X } else {
X x1 = x0;
X y1 = y0;
X x2 = x0 - ((int) (v[0] * ticsize));
X y2 = y0 - ((int) (v[1] * ticsize));
X x3 = x0 - ((int) (v[0] * ticsize * 4)); /* compute text position */
X y3 = y0 - ((int) (v[1] * ticsize * 4));
X }
X clip_move(x1,y1);
X clip_vector(x2,y2);
X
X /* label the ticmark */
X if (text == NULL)
X text = xformat;
X
X (void) sprintf(ticlabel, text, CheckLog(log_x, place));
X if (apx_eq(v[0], 0.0)) {
X if ((*t->justify_text)(CENTRE)) {
X clip_put_text(x3,y3,ticlabel);
X } else {
X clip_put_text(x3-(t->h_char)*strlen(ticlabel)/2,y3,ticlabel);
X }
X }
X else if (v[0] > 0) {
X if ((*t->justify_text)(RIGHT)) {
X clip_put_text(x3,y3,ticlabel);
X } else {
X clip_put_text(x3-(t->h_char)*strlen(ticlabel),y3,ticlabel);
X }
X } else {
X (*t->justify_text)(LEFT);
X clip_put_text(x3,y3,ticlabel);
X }
}
X
/* draw and label a y-axis ticmark */
static ytick(place, text, spacing, ticscale, xpos)
X double place; /* where on axis to put it */
X char *text; /* optional text label */
X double spacing; /* something to use with checkzero */
X double ticscale; /* scale factor for tic mark (0..1] */
X double xpos;
{
X register struct termentry *t = &term_tbl[term];
X char ticlabel[101];
X int x0,y0,x1,y1,x2,y2,x3,y3;
X int ticsize = (int)((t->h_tic) * ticscale);
X double v[2], len;
X
X place = CheckZero(place,spacing); /* to fix rounding error near zero */
X
X if (place > y_max3d || place < y_min3d) return;
X
X map3d_xy(xpos, place, z_min3d, &x0, &y0);
X /* need to figure out which is in. pick the middle point along the */
X /* axis as in. */
X map3d_xy((x_max3d + x_min3d) / 2, place, z_min3d, &x1, &y1);
X
X /* compute a vector of length 1 into the grid: */
X v[0] = x1 - x0;
X v[1] = y1 - y0;
X len = sqrt(v[0] * v[0] + v[1] * v[1]);
X v[0] /= len;
X v[1] /= len;
X
X if (tic_in) {
X x1 = x0;
X y1 = y0;
X x2 = x1 + ((int) (v[0] * ticsize));
X y2 = y1 + ((int) (v[1] * ticsize));
X x3 = x0 - ((int) (v[0] * ticsize * 3)); /* compute text position */
X y3 = y0 - ((int) (v[1] * ticsize * 3));
X } else {
X x1 = x0;
X y1 = y0;
X x2 = x0 - ((int) (v[0] * ticsize));
X y2 = y0 - ((int) (v[1] * ticsize));
X x3 = x0 - ((int) (v[0] * ticsize * 4)); /* compute text position */
X y3 = y0 - ((int) (v[1] * ticsize * 4));
X }
X clip_move(x1,y1);
X clip_vector(x2,y2);
X
X /* label the ticmark */
X if (text == NULL)
X text = yformat;
X
X (void) sprintf(ticlabel, text, CheckLog(log_y, place));
X if (apx_eq(v[0], 0.0)) {
X if ((*t->justify_text)(CENTRE)) {
X clip_put_text(x3,y3,ticlabel);
X } else {
X clip_put_text(x3-(t->h_char)*strlen(ticlabel)/2,y3,ticlabel);
X }
X }
X else if (v[0] > 0) {
X if ((*t->justify_text)(RIGHT)) {
X clip_put_text(x3,y3,ticlabel);
X } else {
X clip_put_text(x3-(t->h_char)*strlen(ticlabel),y3,ticlabel);
X }
X } else {
X (*t->justify_text)(LEFT);
X clip_put_text(x3,y3,ticlabel);
X }
}
X
/* draw and label a z-axis ticmark */
static ztick(place, text, spacing, ticscale, xpos, ypos)
X double place; /* where on axis to put it */
X char *text; /* optional text label */
X double spacing; /* something to use with checkzero */
X double ticscale; /* scale factor for tic mark (0..1] */
X double xpos, ypos;
{
X register struct termentry *t = &term_tbl[term];
X char ticlabel[101];
X int x0,y0,x1,y1,x2,y2,x3,y3;
X int ticsize = (int)((t->h_tic) * ticscale);
X
X place = CheckZero(place,spacing); /* to fix rounding error near zero */
X
X map3d_xy(xpos, ypos, place, &x0, &y0);
X
X if (tic_in) {
X x1 = x0;
X y1 = y0;
X x2 = x0 + ticsize;
X y2 = y0;
X x3 = x0 - ticsize;
X y3 = y0;
X } else {
X x1 = x0;
X y1 = y0;
X x2 = x0 - ticsize;
X y2 = y0;
X x3 = x0 - ticsize * 2; /* compute text position */
X y3 = y0;
X }
X clip_move(x1,y1);
X clip_vector(x2,y2);
X
X /* label the ticmark */
X if (text == NULL)
X text = zformat;
X
X (void) sprintf(ticlabel, text, CheckLog(log_z, place));
X if ((*t->justify_text)(RIGHT)) {
X clip_put_text(x3,y3,ticlabel);
X } else {
X clip_put_text(x3-(t->h_char)*(strlen(ticlabel)+1),y3,ticlabel);
X }
}
SHAR_EOF
echo 'File gnuplot/graph3d.c is complete' &&
chmod 0644 gnuplot/graph3d.c ||
echo 'restore of gnuplot/graph3d.c failed'
Wc_c="`wc -c < 'gnuplot/graph3d.c'`"
test 52166 -eq "$Wc_c" ||
echo 'gnuplot/graph3d.c: original size 52166, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/makefile.vms ==============
if test -f 'gnuplot/makefile.vms' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/makefile.vms (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/makefile.vms (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/makefile.vms' &&
#
# GNUPLOT Makefile
# for VMS
#
# use with the MAKE that was posted by Tony Ivanov (tony@gvgpvd.GVG.TEK.COM)
# in comp.os.vms on 5 December 1988
#
X
# NOOP NO Optimiser
CFLAGS = /NOOP/define=(NOGAMMA,MEMSET)
X
# /define=(<terminal>) in TERMFLAGS iff you wish to support <terminal>
# see other terminal defines in term.h
X
TERMFLAGS =
X
OBJS = bitmap.obj,command.obj,contour.obj,eval.obj,graphics.obj,graph3d.obj, \
X internal.obj,misc.obj,parse.obj,plot.obj,scanner.obj,setshow.obj, \
X standard.obj,term.obj,util.obj,version.obj
X
CSOURCE1 = command.c setshow.c
CSOURCE2 = help.c graphics.c graph3d.c internal.c
CSOURCE3 = misc.c eval.c parse.c plot.c scanner.c standard.c
CSOURCE4 = bitmap.c term.c util.c version.c
CSOURCE5 = [.term]aed.trm [.term]cgi.trm [.term]dumb.trm [.term]dxf.trm [.term]dxy.trm \
X [.term]eepic.trm [.term]epson.trm [.term]fig.trm [.term]hp26.trm \
X [.term]hp2648.trm [.term]hpgl.trm [.term]hpljii.trm
CSOURCE6 = [.term]impcodes.h [.term]imagen.trm [.term]object.h \
X [.term]iris4d.trm [.term]kyo.trm [.term]latex.trm [.term]pc.trm
CSOURCE7 = [.term]post.trm [.term]qms.trm [.term]regis.trm [.term]sun.trm \
X [.term]t410x.trm [.term]tek.trm [.term]unixpc.trm [.term]unixplot.trm \
X [.term]v384.trm [.term]x11.trm gnuplot_x11.c
CSOURCE8 = contour.c
X
all : gnuplot.exe gnuplot.hlp gnuplot.hlb
X
X
gnuplot.exe : $(OBJS)
X link /exe=gnuplot $(OBJS) ,linkopt.vms/opt
X
gnuplot.hlp : doc2hlp.exe [.docs]gnuplot.doc [.docs]doc2hlp.com
X $$@[.docs]doc2hlp.com
X
gnuplot.hlb : gnuplot.hlp
X library/create/help gnuplot.hlb gnuplot.hlp
X
doc2hlp.exe: [.docs]doc2hlp.c
X cc [.docs]doc2hlp.c
X link doc2hlp,linkopt.vms/opt
X
term.obj: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
X $(CC) $(CFLAGS) $(TERMFLAGS) term.c
X
$(OBJS): plot.h
X
command.obj help.obj misc.obj: help.h
X
command.obj graphics.obj graph3d.obj misc.obj plot.obj setshow.obj term.obj: setshow.h
X
bitmap.obj term.obj: bitmap.h
X
clean :
X purge/log
X del/log *.obj;*
SHAR_EOF
chmod 0644 gnuplot/makefile.vms ||
echo 'restore of gnuplot/makefile.vms failed'
Wc_c="`wc -c < 'gnuplot/makefile.vms'`"
test 1998 -eq "$Wc_c" ||
echo 'gnuplot/makefile.vms: original size 1998, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= gnuplot/util.c ==============
if test -f 'gnuplot/util.c' -a X"$1" != X"-c"; then
echo 'x - skipping gnuplot/util.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting gnuplot/util.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'gnuplot/util.c' &&
/* GNUPLOT - util.c */
/*
X * Copyright (C) 1986, 1987, 1990, 1991 Thomas Williams, Colin Kelley
X *
X * Permission to use, copy, and distribute this software and its
X * documentation for any purpose with or without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and
X * that both that copyright notice and this permission notice appear
X * in supporting documentation.
X *
X * Permission to modify the software is granted, but not the right to
X * distribute the modified code. Modifications are to be distributed
X * as patches to released version.
X *
X * This software is provided "as is" without express or implied warranty.
X *
X *
X * AUTHORS
X *
X * Original Software:
X * Thomas Williams, Colin Kelley.
X *
X * Gnuplot 2.0 additions:
X * Russell Lang, Dave Kotz, John Campbell.
X *
X * Gnuplot 3.0 additions:
X * Gershon Elber and many others.
X *
X * Send your comments or suggestions to
X * pixar!info-gnuplot@sun.com.
X * This is a mailing list; to join it send a note to
X * pixar!info-gnuplot-request@sun.com.
X * Send bug reports to
X * pixar!bug-gnuplot@sun.com.
X */
X
#include <ctype.h>
#include <setjmp.h>
#include <stdio.h>
#include <errno.h>
#include "plot.h"
X
BOOLEAN screen_ok;
X /* TRUE if command just typed; becomes FALSE whenever we
X send some other output to screen. If FALSE, the command line
X will be echoed to the screen before the ^ error message. */
X
#ifndef vms
#ifndef __ZTC__
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
#endif
#endif /* vms */
X
extern char input_line[];
extern struct lexical_unit token[];
extern jmp_buf env; /* from plot.c */
extern int inline_num; /* from command.c */
extern BOOLEAN interactive; /* from plot.c */
extern char *infile_name; /* from plot.c */
X
extern char *strchr();
X
#ifndef AMIGA_AC_5
extern double sqrt(), atan2();
#endif
X
/*
X * chr_in_str() compares the characters in the string of token number t_num
X * with c, and returns TRUE if a match was found.
X */
chr_in_str(t_num, c)
int t_num;
char c;
{
register int i;
X
X if (!token[t_num].is_token)
X return(FALSE); /* must be a value--can't be equal */
X for (i = 0; i < token[t_num].length; i++) {
X if (input_line[token[t_num].start_index+i] == c)
X return(TRUE);
X }
X return FALSE;
}
X
X
/*
X * equals() compares string value of token number t_num with str[], and
X * returns TRUE if they are identical.
X */
equals(t_num, str)
int t_num;
char *str;
{
register int i;
X
X if (!token[t_num].is_token)
X return(FALSE); /* must be a value--can't be equal */
X for (i = 0; i < token[t_num].length; i++) {
X if (input_line[token[t_num].start_index+i] != str[i])
X return(FALSE);
X }
X /* now return TRUE if at end of str[], FALSE if not */
X return(str[i] == '\0');
}
X
X
X
/*
X * almost_equals() compares string value of token number t_num with str[], and
X * returns TRUE if they are identical up to the first $ in str[].
X */
almost_equals(t_num, str)
int t_num;
char *str;
{
register int i;
register int after = 0;
register start = token[t_num].start_index;
register length = token[t_num].length;
X
X if (!token[t_num].is_token)
X return(FALSE); /* must be a value--can't be equal */
X for (i = 0; i < length + after; i++) {
X if (str[i] != input_line[start + i]) {
X if (str[i] != '$')
X return(FALSE);
SHAR_EOF
true || echo 'restore of gnuplot/util.c failed'
fi
echo 'End of part 21'
echo 'File gnuplot/util.c is continued in part 22'
echo 22 > _shar_seq_.tmp
exit 0
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.