BRL-CAD
test_bundle.c
Go to the documentation of this file.
1 /* T E S T _ B U N D L E . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2013-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 
24 #include "bn.h"
25 #include "vmath.h"
26 #include "plot3.h"
27 #include "raytrace.h"
28 
29 
30 int
31 main(int ac, char *av[])
32 {
33  FILE *fp;
34  int rays_per_ring=50;
35  int nring=30;
36  fastf_t bundle_radius=1000.0;
37  int i;
38  vect_t avec, bvec;
39  struct xray *rp;
40  vect_t dir;
41 
42  if (ac > 1)
43  bu_exit(1, "Usage: %s\n", av[0]);
44 
45  fp = fopen("bundle.plot3", "wb");
46 
47  VSET(dir, 0, 0, -1);
48 
49  /* create orthogonal rays for basis of bundle */
50  bn_vec_ortho(avec, dir);
51  VCROSS(bvec, dir, avec);
52  VUNITIZE(bvec);
53 
54  rp = (struct xray *)bu_calloc(sizeof(struct xray),
55  (rays_per_ring * nring) + 1,
56  "ray bundle");
57  VSET(rp[0].r_pt, 0, 0, 2000);
58  VMOVE(rp[0].r_dir, dir);
59  rt_raybundle_maker(rp, bundle_radius, avec, bvec, rays_per_ring, nring);
60 
61 
62  for (i=0; i <= rays_per_ring * nring; i++) {
63  point_t tip;
64  VJOIN1(tip, rp[i].r_pt, 3500, rp[i].r_dir);
65  pdv_3line(fp, rp[i].r_pt, tip);
66  }
67  fclose(fp);
68  bu_free(rp, "ray bundle");
69 
70  return 0;
71 }
72 
73 /*
74  * Local Variables:
75  * tab-width: 8
76  * mode: C
77  * indent-tabs-mode: t
78  * c-file-style: "stroustrup"
79  * End:
80  * ex: shiftwidth=4 tabstop=8
81  */
#define VSET(a, b, c, d)
Definition: color.c:53
Definition: raytrace.h:215
Header file for the BRL-CAD common definitions.
void bu_exit(int status, const char *fmt,...) _BU_ATTR_NORETURN _BU_ATTR_PRINTF23
Definition: bomb.c:195
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
Definition: malloc.c:321
int rt_raybundle_maker(struct xray *rp, double radius, const fastf_t *avec, const fastf_t *bvec, int rays_per_ring, int nring)
Definition: mkbundle.c:54
vect_t r_dir
Direction of ray (UNIT Length)
Definition: raytrace.h:219
void pdv_3line(register FILE *plotfp, const fastf_t *a, const fastf_t *b)
Definition: plot3.c:642
point_t r_pt
Point at which ray starts.
Definition: raytrace.h:218
void bn_vec_ortho(vect_t out, const vect_t in)
int main(int ac, char *av[])
Definition: test_bundle.c:31
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
double fastf_t
Definition: defines.h:300