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 #ifndef lint
00037 static const char RCSmkbundle[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/librt/mkbundle.c,v 14.10 2006/09/16 02:04:25 lbutler Exp $ (BRL)";
00038 #endif
00039
00040 #include "common.h"
00041
00042
00043
00044 #include <stdio.h>
00045 #include <math.h>
00046 #include "machine.h"
00047 #include "vmath.h"
00048 #include "bu.h"
00049 #include "bn.h"
00050 #include "raytrace.h"
00051 #include "./debug.h"
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 void
00071 rt_raybundle_maker(struct xray *rp, double radius, const fastf_t *avec, const fastf_t *bvec, int rays_per_ring, int nring)
00072 {
00073 register struct xray *rayp = rp+1;
00074 int ring;
00075 double fraction = 1.0;
00076 double theta;
00077 double delta;
00078 double radial_scale;
00079 int count = 0;
00080
00081 rp[0].index = count++;
00082 rp[0].magic =RT_RAY_MAGIC;
00083
00084 for( ring=0; ring < nring; ring++ ) {
00085 register int i;
00086
00087 theta = 0;
00088 delta = bn_twopi / rays_per_ring;
00089 fraction = ((double)(ring+1)) / nring;
00090 theta = delta * fraction;
00091 radial_scale = radius * fraction;
00092 for( i=0; i < rays_per_ring; i++ ) {
00093 register double ct, st;
00094
00095 ct = cos(theta) * radial_scale;
00096 st = sin(theta) * radial_scale;
00097 VJOIN2( rayp->r_pt, rp[0].r_pt, ct, avec, st, bvec );
00098 VMOVE( rayp->r_dir, rp[0].r_dir );
00099 rayp->index = count++;
00100 rayp->magic = RT_RAY_MAGIC;
00101 theta += delta;
00102 rayp++;
00103 }
00104 }
00105 }
00106
00107
00108
00109
00110
00111 #if 0
00112 main()
00113 {
00114 FILE *fp = fopen("bundle.pl", "w");
00115 int rays_per_ring=5;
00116 int nring=3;
00117 fastf_t bundle_radius=1000.0;
00118 int i;
00119 vect_t avec, bvec;
00120 struct xray *rp;
00121 vect_t dir;
00122
00123
00124 VSET( dir, 0, 0, -1 );
00125
00126 bn_vec_ortho( avec, dir );
00127 VCROSS( bvec, dir, avec );
00128 VUNITIZE( bvec );
00129
00130 rp = (struct xray *)bu_calloc( sizeof( struct xray ),
00131 (rays_per_ring * nring) + 1,
00132 "ray bundle" );
00133 VSET( rp[0].r_pt, 0, 0, 2000);
00134 VMOVE( rp[0].r_dir, dir );
00135 rt_raybundle_maker( rp, bundle_radius, avec, bvec, rays_per_ring, nring );
00136
00137
00138 for( i=0; i <= rays_per_ring * nring; i++ ) {
00139 point_t tip;
00140 VJOIN1( tip, rp[i].r_pt, 3500, rp[i].r_dir );
00141 pdv_3line( fp, rp[i].r_pt, tip );
00142 }
00143 fclose(fp);
00144 }
00145 #endif
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155