ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/gentree.c
Revision: 1.2
Committed: Fri Aug 1 14:14:24 2003 UTC (20 years, 9 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6P1, rad3R6
Changes since 1.1: +1 -4 lines
Log Message:
Eliminated CPM, MAC, and UNIX conditional compiles.

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 schorsch 1.2 static const char RCSid[] = "$Id: gentree.c,v 1.1 2003/02/22 02:07:26 greg Exp $";
3 greg 1.1 #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     progname = argv[0];
29     if (argc != 7) {
30     sprintf(errmsg, "Usage: %s x0 y0 x1 y1 nbranch depth", progname);
31     error(USER, errmsg);
32     }
33     nbranch = atoi(argv[5]);
34     gentree(atoi(argv[1]), atoi(argv[2]),
35     atoi(argv[3]), atoi(argv[4]), atoi(argv[6]));
36     pglob(PEOP, 0200, NULL);
37     writeof(stdout);
38     exit(0);
39     }
40    
41    
42     gentree(x0, y0, x1, y1, depth)
43     int x0, y0, x1, y1, depth;
44     {
45     int xstart, ystart;
46     int xend, yend;
47     register int i;
48    
49     plseg(0, x0, y0, x1, y1);
50     if (depth <= 0)
51     return;
52     for (i = 1; i < nbranch+1; i++) {
53     xstart = (x1-x0)*(long)i/(nbranch+2)+x0;
54     ystart = (y1-y0)*(long)i/(nbranch+2)+y0;
55     xend = xstart+(x1-x0)/(nbranch+2);
56     yend = ystart+(y1-y0)/(nbranch+2);
57     gentree(xstart, ystart,
58     xend+(y1-yend)*ratio, yend+(xend-x1)*ratio,
59     depth-1);
60     gentree(xstart, ystart,
61     xend+(yend-y1)*ratio, yend+(x1-xend)*ratio,
62     depth-1);
63     }
64     }