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.5 by greg, Thu Sep 12 13:26:16 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 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 <        static double   area = 1.0;
211 >        static double   parea = 1.0;
212  
213 <        printf("Polygon area [%g]: ", area);
214 <        getd(&area);
215 <        projarea = PI*unit2meter*unit2meter * area;
213 >        getd("Polygon area", &parea,
214 >                "Enter the total radiating area of the polygon.");
215 >        area = unit2meter*unit2meter * parea;
216          return(1);
217   }
218  
# Line 211 | Line 221 | getsphere()                    /* get projected area for a sphere */
221   {
222          static double   radius = 1.0;
223  
224 <        printf("Sphere radius [%g]: ", radius);
225 <        getd(&radius);
226 <        projarea = 4.*PI*PI*unit2meter*unit2meter * 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  
# Line 222 | Line 232 | getcylinder()                  /* get projected area for a cylinder *
232   {
233          static double   length = 1.0, radius = 0.1;
234  
235 <        printf("Cylinder length [%g]: ", length);
236 <        getd(&length);
237 <        printf("Cylinder radius [%g]: ", radius);
238 <        getd(&radius);
239 <        projarea = PI*PI*2.*PI*unit2meter*unit2meter * 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  
# Line 235 | Line 245 | getring()                      /* get projected area for a ring */
245   {
246          static double   radius = 1.0;
247  
248 <        printf("Disk radius [%g]: ", radius);
249 <        getd(&radius);
250 <        projarea = PI*PI*unit2meter*unit2meter * 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