ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/gentree.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     /*
5     * gentree.c - program to generate 2-D Christmas trees.
6     *
7     * 12/4/85
8     *
9     * cc gentree.c libmeta.a
10     */
11    
12    
13     #include "meta.h"
14    
15    
16     #define ratio 1/3
17    
18    
19     char *progname;
20    
21     int nbranch;
22    
23    
24     main(argc, argv)
25     int argc;
26     char *argv[];
27     {
28     #ifdef CPM
29     fixargs("gentree", &argc, &argv);
30     #endif
31     progname = argv[0];
32     if (argc != 7) {
33     sprintf(errmsg, "Usage: %s x0 y0 x1 y1 nbranch depth", progname);
34     error(USER, errmsg);
35     }
36     nbranch = atoi(argv[5]);
37     gentree(atoi(argv[1]), atoi(argv[2]),
38     atoi(argv[3]), atoi(argv[4]), atoi(argv[6]));
39     pglob(PEOP, 0200, NULL);
40     writeof(stdout);
41     exit(0);
42     }
43    
44    
45     gentree(x0, y0, x1, y1, depth)
46     int x0, y0, x1, y1, depth;
47     {
48     int xstart, ystart;
49     int xend, yend;
50     register int i;
51    
52     plseg(0, x0, y0, x1, y1);
53     if (depth <= 0)
54     return;
55     for (i = 1; i < nbranch+1; i++) {
56     xstart = (x1-x0)*(long)i/(nbranch+2)+x0;
57     ystart = (y1-y0)*(long)i/(nbranch+2)+y0;
58     xend = xstart+(x1-x0)/(nbranch+2);
59     yend = ystart+(y1-y0)/(nbranch+2);
60     gentree(xstart, ystart,
61     xend+(y1-yend)*ratio, yend+(xend-x1)*ratio,
62     depth-1);
63     gentree(xstart, ystart,
64     xend+(yend-y1)*ratio, yend+(x1-xend)*ratio,
65     depth-1);
66     }
67     }