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 #ifndef lint
00038 static const char RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbn/vector.c,v 14.11 2006/09/07 01:19:17 lbutler Exp $ (BRL)";
00039 #endif
00040
00041 #include "common.h"
00042
00043
00044
00045 #include <stdio.h>
00046 #include <math.h>
00047
00048 #include "machine.h"
00049 #include "vmath.h"
00050 #include "plot3.h"
00051 #include "bu.h"
00052 #include "bn.h"
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 void
00068 tp_3vector(FILE *plotfp, fastf_t *from, fastf_t *to, double fromheadfract, double toheadfract)
00069 {
00070 register fastf_t len;
00071 register fastf_t hooklen;
00072 vect_t diff;
00073 vect_t c1, c2;
00074 vect_t h1, h2;
00075 vect_t backup;
00076 point_t tip;
00077
00078 pdv_3line( plotfp, from, to );
00079
00080
00081 VSUB2( diff, to, from );
00082 if( (len = MAGNITUDE(diff)) < SMALL ) return;
00083 VSCALE( diff, diff, 1/len );
00084 bn_vec_ortho( c1, diff );
00085 VCROSS( c2, c1, diff );
00086
00087 if( fromheadfract != 0 ) {
00088 hooklen = fromheadfract*len;
00089 VSCALE( backup, diff, -hooklen );
00090
00091 VSCALE( h1, c1, hooklen );
00092 VADD3( tip, from, h1, backup );
00093 pdv_3move( plotfp, from );
00094 pdv_3cont( plotfp, tip );
00095
00096 VSCALE( h2, c2, hooklen );
00097 VADD3( tip, from, h2, backup );
00098 pdv_3move( plotfp, tip );
00099 }
00100 if( toheadfract != 0 ) {
00101 hooklen = toheadfract*len;
00102 VSCALE( backup, diff, -hooklen );
00103
00104 VSCALE( h1, c1, hooklen );
00105 VADD3( tip, to, h1, backup );
00106 pdv_3move( plotfp, to );
00107 pdv_3cont( plotfp, tip );
00108
00109 VSCALE( h2, c2, hooklen );
00110 VADD3( tip, to, h2, backup );
00111 pdv_3move( plotfp, tip );
00112 }
00113
00114 if( fromheadfract != 0 || toheadfract != 0 )
00115 pdv_3cont( plotfp, to );
00116
00117 }
00118
00119 void
00120 PL_FORTRAN(f3vect, F3VECT)(fp, fx, fy, fz, tx, ty, tz, fl, tl )
00121 FILE **fp;
00122 float *fx;
00123 float *fy;
00124 float *fz;
00125 float *tx;
00126 float *ty;
00127 float *tz;
00128 float *fl;
00129 float *tl;
00130 {
00131 point_t from, to;
00132
00133 VSET( from, *fx, *fy, *fz );
00134 VSET( to, *tx, *ty, *tz );
00135 tp_3vector( *fp, from, to, *fl, *tl );
00136 }
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147