ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/gensky.c
(Generate patch)

Comparing ray/src/gen/gensky.c (file contents):
Revision 1.6 by greg, Thu Oct 24 13:43:22 1991 UTC vs.
Revision 2.5 by greg, Fri Mar 20 15:29:10 1992 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19  
20   #include  "color.h"
21  
22 + #ifndef atof
23 + extern double  atof();
24 + #endif
25   extern char  *strcpy(), *strcat(), *malloc();
26   extern double  stadj(), sdec(), sazi(), salt();
27  
# Line 32 | Line 35 | extern double  s_latitude;
35   extern double  s_longitude;
36   extern double  s_meridian;
37                                          /* required values */
38 < int  month, day;
39 < double  hour;
38 > int  month, day;                                /* date */
39 > double  hour;                                   /* time */
40 > int  tsolar;                                    /* 0=standard, 1=solar */
41 > double  altitude, azimuth;                      /* or solar angles */
42                                          /* default values */
43 < int  cloudy = 0;
43 > int  cloudy = 0;                                /* 1=standard, 2=uniform */
44   int  dosun = 1;
45   double  zenithbr = -1.0;
46   double  turbidity = 2.75;
# Line 54 | Line 59 | main(argc, argv)
59   int  argc;
60   char  *argv[];
61   {
62 <        extern double  atof(), fabs();
62 >        extern double  fabs();
63          int  i;
64  
65          progname = argv[0];
# Line 64 | Line 69 | char  *argv[];
69          }
70          if (argc < 4)
71                  userror("arg count");
72 <        month = atoi(argv[1]);
73 <        day = atoi(argv[2]);
74 <        hour = atof(argv[3]);
72 >        if (!strcmp(argv[1], "-ang")) {
73 >                altitude = atof(argv[2]) * (PI/180);
74 >                azimuth = atof(argv[3]) * (PI/180);
75 >                month = 0;
76 >        } else {
77 >                month = atoi(argv[1]);
78 >                day = atoi(argv[2]);
79 >                hour = atof(argv[3]);
80 >                tsolar = argv[3][0] == '+';
81 >        }
82          for (i = 4; i < argc; i++)
83                  if (argv[i][0] == '-' || argv[i][0] == '+')
84                          switch (argv[i][1]) {
# Line 75 | Line 87 | char  *argv[];
87                                  dosun = argv[i][0] == '+';
88                                  break;
89                          case 'c':
90 <                                cloudy = 1;
90 >                                cloudy = argv[i][0] == '+' ? 2 : 1;
91                                  dosun = 0;
92                                  break;
93                          case 't':
# Line 117 | Line 129 | char  *argv[];
129  
130   computesky()                    /* compute sky parameters */
131   {
120        int  jd;
121        double  sd, st;
122        double  altitude, azimuth;
132                                          /* compute solar direction */
133 <        jd = jdate(month, day);                 /* Julian date */
134 <        sd = sdec(jd);                          /* solar declination */
135 <        st = hour + stadj(jd);                  /* solar time */
136 <        altitude = salt(sd, st);
137 <        azimuth = sazi(sd, st);
133 >        if (month) {                    /* from date and time */
134 >                int  jd;
135 >                double  sd, st;
136 >
137 >                jd = jdate(month, day);         /* Julian date */
138 >                sd = sdec(jd);                  /* solar declination */
139 >                if (tsolar)                     /* solar time */
140 >                        st = hour;
141 >                else
142 >                        st = hour + stadj(jd);
143 >                altitude = salt(sd, st);
144 >                azimuth = sazi(sd, st);
145 >        }
146          sundir[0] = -sin(azimuth)*cos(altitude);
147          sundir[1] = -cos(azimuth)*cos(altitude);
148          sundir[2] = sin(altitude);
# Line 143 | Line 160 | computesky()                   /* compute sky parameters */
160                  zenithbr = 0.0;
161                                          /* Compute horizontal radiance */
162          if (cloudy) {
163 <                groundbr = zenithbr*0.777778;
163 >                if (cloudy == 2)
164 >                        groundbr = zenithbr;
165 >                else
166 >                        groundbr = zenithbr*0.777778;
167                  printf("# Ground ambient level: %f\n", groundbr);
168          } else {
169                  F2 = 0.274*(0.91 + 10.0*exp(-3.0*(PI/2.0-altitude)) +
# Line 179 | Line 199 | printsky()                     /* print out sky */
199          printf("2 skybright skybright.cal\n");
200          printf("0\n");
201          if (cloudy)
202 <                printf("3 1 %.2e %.2e\n", zenithbr, groundbr);
202 >                printf("3 %d %.2e %.2e\n", cloudy, zenithbr, groundbr);
203          else
204                  printf("7 -1 %.2e %.2e %.2e %f %f %f\n", zenithbr, groundbr,
205                                  F2, sundir[0], sundir[1], sundir[2]);
# Line 188 | Line 208 | printsky()                     /* print out sky */
208  
209   printdefaults()                 /* print default values */
210   {
211 <        if (cloudy)
211 >        if (cloudy == 1)
212                  printf("-c\t\t\t\t# Cloudy sky\n");
213 +        else if (cloudy == 2)
214 +                printf("+c\t\t\t\t# Uniform cloudy sky\n");
215          else if (dosun)
216                  printf("+s\t\t\t\t# Sunny sky with sun\n");
217          else
# Line 211 | Line 233 | char  *msg;
233          if (msg != NULL)
234                  fprintf(stderr, "%s: Use error - %s\n", progname, msg);
235          fprintf(stderr, "Usage: %s month day hour [options]\n", progname);
236 +        fprintf(stderr, "   Or: %s -ang altitude azimuth [options]\n", progname);
237          fprintf(stderr, "   Or: %s -defaults\n", progname);
238          exit(1);
239   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines