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

Comparing ray/src/cv/lampcolor.c (file contents):
Revision 1.2 by greg, Thu Sep 5 15:09:08 1991 UTC vs.
Revision 2.3 by greg, Fri Jan 10 11:17:13 1992 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include <stdio.h>
12  
13 + #include "color.h"
14 +
15   #define PI      3.14159265358979323846
16  
17   extern char     *gets(), *strcpy();
18 + #ifndef atof
19   extern double   atof();
20 + #endif
21   extern float    *matchlamp();
22  
23                                  /* lamp parameters */
# Line 27 | Line 31 | int    typecheck(), unitcheck(), geomcheck(), outpcheck()
31  
32   float   *lampcolor;             /* the lamp color (RGB) */
33   double  unit2meter;             /* conversion from units to meters */
34 < double  projarea;               /* projected area for this geometry */
34 > double  area;                   /* radiating area for this geometry */
35   double  lumens;                 /* total lamp lumens */
36  
37   struct {
# Line 36 | Line 40 | struct {
40          int     (*check)();
41          char    *help;
42   } param[NPARAMS] = {
43 <        { "lamp type", "white", typecheck,
43 >        { "lamp type", "D65WHITE", typecheck,
44   "The lamp type is a string which corresponds to one of the types registered\n\
45 < in the lamp table file.  A value of \"white\" means an uncolored source,\n\
45 > in the lamp table file.  A value of \"D65WHITE\" means an uncolored source,\n\
46   which may be preferable because it results in a color balanced image." },
47          { "length unit", "meter", unitcheck,
48   "Unit must be one of:  \"meter\", \"centimeter\", \"foot\", or \"inch\".\n\
# Line 49 | Line 53 | or \"ring\".  These may be abbreviated as a single let
53          { "total lamp lumens", "0", outpcheck,
54   "This is the overall light output of the lamp and its fixture.  If you do\n\
55   not know this value explicitly, you can compute the approximate lumens\n\
56 < by multiplying the input wattage by 15 for incandescent fixtures or 40\n\
56 > by multiplying the input wattage by 14 for incandescent fixtures or 70\n\
57   for fluorescent fixtures." },
58   };
59  
# Line 173 | Line 177 | compute()                      /* compute lamp radiance */
177   {
178          double  whiteval;
179  
180 <        whiteval = lumens/470./projarea;
180 >        whiteval = lumens/area/(WHTEFFICACY*PI);
181  
182          printf("Lamp color (RGB) = %f %f %f\n",
183                          lampcolor[0]*whiteval,
# Line 182 | Line 186 | compute()                      /* compute lamp radiance */
186   }
187  
188  
189 < getd(dp)                        /* get a positive double from stdin */
189 > getd(name, dp, help)            /* get a positive double from stdin */
190 > char    *name;
191   double  *dp;
192 + char    *help;
193   {
194          char    buf[32];
195 <
195 > again:
196 >        printf("%s [%g]: ", name, *dp);
197          if (gets(buf) == NULL)
198                  return(0);
199 +        if (buf[0] == '?') {
200 +                puts(help);
201 +                goto again;
202 +        }
203          if ((buf[0] < '0' || buf[0] > '9') && buf[0] != '.')
204                  return(0);
205          *dp = atof(buf);
# Line 198 | Line 209 | double *dp;
209  
210   getpolygon()                    /* get projected area for a polygon */
211   {
212 <        printf("Enter area of polygon: ");
213 <        if (!getd(&projarea))
214 <                return(0);
215 <        projarea *= unit2meter*unit2meter;
216 <        projarea *= PI;
212 >        static double   parea = 1.0;
213 >
214 >        getd("Polygon area", &parea,
215 >                "Enter the total radiating area of the polygon.");
216 >        area = unit2meter*unit2meter * parea;
217          return(1);
218   }
219  
220  
221   getsphere()                     /* get projected area for a sphere */
222   {
223 <        double  radius;
223 >        static double   radius = 1.0;
224  
225 <        printf("Enter sphere radius: ");
226 <        if (!getd(&radius))
227 <                return(0);
217 <        radius *= unit2meter;
218 <        projarea = 4.*PI*PI*radius*radius;
225 >        getd("Sphere radius", &radius,
226 >                "Enter the distance from the sphere's center to its surface.");
227 >        area = 4.*PI*unit2meter*unit2meter * radius*radius;
228          return(1);
229   }
230  
231  
232   getcylinder()                   /* get projected area for a cylinder */
233   {
234 <        double  length, radius;
234 >        static double   length = 1.0, radius = 0.1;
235  
236 <        printf("Enter cylinder length: ");
237 <        if (!getd(&length))
238 <                return(0);
239 <        length *= unit2meter;
240 <        printf("Enter cylinder radius: ");
232 <        if (!getd(&radius))
233 <                return(0);
234 <        radius *= unit2meter;
235 <        projarea = PI*PI*2.*PI*radius*length;
236 >        getd("Cylinder length", &length,
237 >                "Enter the length of the cylinder.");
238 >        getd("Cylinder radius", &radius,
239 >                "Enter the distance from the cylinder's axis to its surface.");
240 >        area = 2.*PI*unit2meter*unit2meter * radius*length;
241          return(1);
242   }
243  
244  
245   getring()                       /* get projected area for a ring */
246   {
247 <        double  radius;
247 >        static double   radius = 1.0;
248  
249 <        printf("Enter disk radius: ");
250 <        if (!getd(&radius))
251 <                return(0);
252 <        radius *= unit2meter;
248 <        projarea = PI*PI*radius*radius;
249 >        getd("Disk radius", &radius,
250 > "Enter the distance from the ring's center to its outer edge.\n\
251 > The inner radius must be zero.");
252 >        area = PI*unit2meter*unit2meter * radius*radius;
253          return(1);
254   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines