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.5 by saba, Tue Jul 5 15:49:51 1994 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines