00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "common.h"
00043
00044 #include <stdio.h>
00045 #include <math.h>
00046 #include <string.h>
00047
00048 #include "vmath.h"
00049 #include "plot3.h"
00050
00051 #define TICK_YLEN (char_width)
00052 #define NUM_YOFF (3*char_width)
00053 #define TITLE_YOFF (5*char_width)
00054
00055 void
00056 tp_3axis(FILE *fp,
00057 char *string,
00058 fastf_t *origin,
00059 fastf_t *rot,
00060 double length,
00061 int ccw,
00062 int ndigits,
00063 double label_start,
00064 double label_incr,
00065 double tick_separation,
00066 double char_width)
00067 {
00068 register int i;
00069 int nticks;
00070 point_t tick_bottom;
00071 vect_t axis_incr;
00072 vect_t axis_dir;
00073 point_t title_left;
00074 point_t cur_point;
00075 point_t num_start;
00076 point_t num_center;
00077 point_t num_last_end;
00078 vect_t temp;
00079 vect_t diff;
00080 mat_t xlate_to_0;
00081 mat_t mat;
00082 char fmt[32];
00083 char str[64];
00084
00085
00086 if (ccw)
00087 ccw = -1;
00088 else
00089 ccw = 1;
00090
00091 if (ZERO(tick_separation)) tick_separation = 1;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 MAT_IDN(xlate_to_0);
00102 MAT_DELTAS_VEC(xlate_to_0, origin);
00103 bn_mat_mul(mat, rot, xlate_to_0);
00104 VMOVE(cur_point, origin);
00105
00106
00107 VSET(temp, 0, -TICK_YLEN * ccw, 0);
00108 MAT4X3PNT(tick_bottom, mat, temp);
00109
00110
00111 VSET(temp, 0, -NUM_YOFF * ccw, 0);
00112 MAT4X3PNT(num_center, mat, temp);
00113 temp[X] = -char_width*ndigits;
00114 MAT4X3PNT(num_last_end, mat, temp);
00115
00116
00117 VSET(temp, 1, 0, 0);
00118 MAT4X3VEC(axis_dir, mat, temp);
00119 VSCALE(axis_incr, axis_dir, tick_separation);
00120
00121
00122 VSET(temp, 0.5*(length - strlen(string)*char_width), -TITLE_YOFF*ccw, 0);
00123 MAT4X3PNT(title_left, mat, temp);
00124 tp_3symbol(fp, string, title_left, rot, char_width);
00125
00126 nticks = length/tick_separation+0.5;
00127 pdv_3move(fp, cur_point);
00128 for (i=0; i<=nticks; i++) {
00129
00130
00131
00132
00133
00134
00135 pdv_3cont(fp, tick_bottom);
00136
00137 if (ndigits > 64) {
00138 bu_bomb("ERROR: Number of digits exceeds available buffer space");
00139 }
00140
00141 if (ndigits > 0) {
00142 double f;
00143 snprintf(fmt, 32, "%%%dg", ndigits);
00144 snprintf(str, 64, fmt, label_start);
00145 f = strlen(str) * char_width * 0.5;
00146 VJOIN1(num_start, num_center, -f, axis_dir);
00147
00148
00149
00150
00151 VSUB2(diff, num_start, num_last_end);
00152 if (VDOT(diff, axis_dir) >= 0) {
00153 tp_3symbol(fp, str, num_start, rot, char_width);
00154 VJOIN1(num_last_end, num_center, f, axis_dir);
00155 }
00156 }
00157
00158 if (i == nticks) break;
00159
00160
00161 pdv_3move(fp, cur_point);
00162 VADD2(cur_point, cur_point, axis_incr);
00163 VADD2(tick_bottom, tick_bottom, axis_incr);
00164 VADD2(num_center, num_center, axis_incr);
00165
00166 label_start += label_incr;
00167
00168 pdv_3cont(fp, cur_point);
00169 }
00170 }
00171
00172
00173 void
00174 PL_FORTRAN(f3axis, F3AXIS)(FILE **fp,
00175 char *string ,
00176 float *x, float *y, float *z ,
00177 float *length ,
00178 float *theta ,
00179 int *ccw,
00180 int *ndigits ,
00181 float *label_start ,
00182 float *label_incr ,
00183 float *tick_separation ,
00184 float *char_width )
00185 {
00186 char buf[128];
00187 mat_t mat;
00188 vect_t pnt;
00189
00190 VSET(pnt, *x, *y, *z);
00191 MAT_IDN(mat);
00192 bn_mat_angles(mat, 0.0, 0.0, *theta);
00193 bu_strlcpy(buf, string, sizeof(buf));
00194
00195 tp_3axis(*fp, buf, pnt, mat, *length, *ccw,
00196 *ndigits, *label_start, *label_incr,
00197 *tick_separation, *char_width);
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208