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 2.22 by schorsch, Sun Nov 16 10:29:38 2003 UTC vs.
Revision 2.26 by greg, Wed Jul 30 17:30:27 2014 UTC

# Line 15 | Line 15 | static const char      RCSid[] = "$Id$";
15   #include  <string.h>
16   #include  <math.h>
17   #include  <ctype.h>
18 <
18 > #include  "sun.h"
19   #include  "color.h"
20  
21 extern int jdate(int month, int day);
22 extern double stadj(int  jd);
23 extern double sdec(int  jd);
24 extern double salt(double sd, double st);
25 extern double sazi(double sd, double st);
26
21   #ifndef  PI
22   #define  PI             3.14159265358979323846
23   #endif
# Line 38 | Line 32 | extern double sazi(double sd, double st);
32   #define  overcast       ((skytype==S_OVER)|(skytype==S_UNIF))
33  
34   double  normsc();
41                                        /* sun calculation constants */
42 extern double  s_latitude;
43 extern double  s_longitude;
44 extern double  s_meridian;
35  
36   #undef  toupper
37   #define  toupper(c)     ((c) & ~0x20)   /* ASCII trick to convert case */
# Line 78 | Line 68 | int  skytype = S_CLEAR;                                /* sky type */
68   int  dosun = 1;
69   double  zenithbr = 0.0;
70   int     u_zenith = 0;                           /* -1=irradiance, 1=radiance */
71 < double  turbidity = 2.75;
71 > double  turbidity = 2.45;
72   double  gprefl = 0.2;
73                                          /* computed values */
74   double  sundir[3];
# Line 95 | Line 85 | void printsky(void);
85   void printdefaults(void);
86   void userror(char  *msg);
87   double normsc(void);
88 < void cvthour(char  *hs);
89 < void printhead(register int  ac, register char  **av);
88 > int cvthour(char  *hs);
89 > void printhead(int  ac, char  **av);
90  
91  
92   int
93 < main(argc, argv)
94 < int  argc;
95 < char  *argv[];
93 > main(
94 >        int  argc,
95 >        char  *argv[]
96 > )
97   {
98 +        int  got_meridian = 0;
99          int  i;
100  
101          progname = argv[0];
# Line 124 | Line 116 | char  *argv[];
116                  day = atoi(argv[2]);
117                  if (day < 1 || day > 31)
118                          userror("bad day");
119 <                cvthour(argv[3]);
119 >                got_meridian = cvthour(argv[3]);
120          }
121          for (i = 4; i < argc; i++)
122                  if (argv[i][0] == '-' || argv[i][0] == '+')
# Line 166 | Line 158 | char  *argv[];
158                                  s_longitude = atof(argv[++i]) * (PI/180);
159                                  break;
160                          case 'm':
161 +                                if (got_meridian) {
162 +                                        ++i;
163 +                                        break;          /* time overrides */
164 +                                }
165                                  s_meridian = atof(argv[++i]) * (PI/180);
166                                  break;
167                          default:
# Line 175 | Line 171 | char  *argv[];
171                  else
172                          userror("bad option");
173  
174 <        if (fabs(s_meridian-s_longitude) > 45*PI/180)
174 >        if (month && !tsolar && fabs(s_meridian-s_longitude) > 45*PI/180)
175                  fprintf(stderr,
176 <        "%s: warning: %.1f hours btwn. standard meridian and longitude\n",
176 >        "%s: warning - %.1f hours btwn. standard meridian and longitude\n",
177                          progname, (s_longitude-s_meridian)*12/PI);
178  
179          printhead(argc, argv);
# Line 356 | Line 352 | normsc(void)                   /* compute normalization factor (E0*F2/
352                                  /* intermediate sky approx. */
353                  {3.5556, -2.7152, -1.3081, 1.0660, 0.60227},
354          };
355 <        register double  *nf;
355 >        double  *nf;
356          double  x, nsc;
357 <        register int  i;
357 >        int  i;
358                                          /* polynomial approximation */
359          nf = nfc[skytype==S_INTER];
360          x = (altitude - PI/4.0)/(PI/4.0);
# Line 370 | Line 366 | normsc(void)                   /* compute normalization factor (E0*F2/
366   }
367  
368  
369 < void
369 > int
370   cvthour(                        /* convert hour string */
371          char  *hs
372   )
373   {
374 <        register char  *cp = hs;
375 <        register int    i, j;
374 >        char  *cp = hs;
375 >        int     i, j;
376  
377          if ( (tsolar = *cp == '+') ) cp++;              /* solar time? */
378          while (isdigit(*cp)) cp++;
# Line 388 | Line 384 | cvthour(                       /* convert hour string */
384          }
385          while (isdigit(*cp)) cp++;
386          if (!*cp)
387 <                return;
387 >                return(0);
388          if (tsolar || !isalpha(*cp)) {
389                  fprintf(stderr, "%s: bad time format: %s\n", progname, hs);
390                  exit(1);
# Line 400 | Line 396 | cvthour(                       /* convert hour string */
396                                  break;
397                  if (!cp[j] && !tzone[i].zname[j]) {
398                          s_meridian = tzone[i].zmer * (PI/180);
399 <                        return;
399 >                        return(1);
400                  }
401          } while (tzone[i++].zname[0]);
402  
# Line 415 | Line 411 | cvthour(                       /* convert hour string */
411  
412   void
413   printhead(              /* print command header */
414 <        register int  ac,
415 <        register char  **av
414 >        int  ac,
415 >        char  **av
416   )
417   {
418          putchar('#');

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines