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.1 by greg, Tue Nov 12 17:02:10 1991 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();
# Line 27 | Line 29 | int    typecheck(), unitcheck(), geomcheck(), outpcheck()
29  
30   float   *lampcolor;             /* the lamp color (RGB) */
31   double  unit2meter;             /* conversion from units to meters */
32 < double  projarea;               /* projected area for this geometry */
32 > double  area;                   /* radiating area for this geometry */
33   double  lumens;                 /* total lamp lumens */
34  
35   struct {
# Line 173 | Line 175 | compute()                      /* compute lamp radiance */
175   {
176          double  whiteval;
177  
178 <        whiteval = lumens/470./projarea;
178 >        whiteval = lumens/area/(WHTEFFICACY*PI);
179  
180          printf("Lamp color (RGB) = %f %f %f\n",
181                          lampcolor[0]*whiteval,
# Line 182 | Line 184 | compute()                      /* compute lamp radiance */
184   }
185  
186  
187 < getd(dp)                        /* get a positive double from stdin */
187 > getd(name, dp, help)            /* get a positive double from stdin */
188 > char    *name;
189   double  *dp;
190 + char    *help;
191   {
192          char    buf[32];
193 <
193 > again:
194 >        printf("%s [%g]: ", name, *dp);
195          if (gets(buf) == NULL)
196                  return(0);
197 +        if (buf[0] == '?') {
198 +                puts(help);
199 +                goto again;
200 +        }
201          if ((buf[0] < '0' || buf[0] > '9') && buf[0] != '.')
202                  return(0);
203          *dp = atof(buf);
# Line 198 | Line 207 | double *dp;
207  
208   getpolygon()                    /* get projected area for a polygon */
209   {
210 <        static double   area = 1.0;
210 >        static double   parea = 1.0;
211  
212 <        printf("Polygon area [%g]: ", area);
213 <        getd(&area);
214 <        projarea = PI*unit2meter*unit2meter * area;
212 >        getd("Polygon area", &parea,
213 >                "Enter the total radiating area of the polygon.");
214 >        area = unit2meter*unit2meter * parea;
215          return(1);
216   }
217  
# Line 211 | Line 220 | getsphere()                    /* get projected area for a sphere */
220   {
221          static double   radius = 1.0;
222  
223 <        printf("Sphere radius [%g]: ", radius);
224 <        getd(&radius);
225 <        projarea = 4.*PI*PI*unit2meter*unit2meter * radius*radius;
223 >        getd("Sphere radius", &radius,
224 >                "Enter the distance from the sphere's center to its surface.");
225 >        area = 4.*PI*unit2meter*unit2meter * radius*radius;
226          return(1);
227   }
228  
# Line 222 | Line 231 | getcylinder()                  /* get projected area for a cylinder *
231   {
232          static double   length = 1.0, radius = 0.1;
233  
234 <        printf("Cylinder length [%g]: ", length);
235 <        getd(&length);
236 <        printf("Cylinder radius [%g]: ", radius);
237 <        getd(&radius);
238 <        projarea = PI*PI*2.*PI*unit2meter*unit2meter * radius*length;
234 >        getd("Cylinder length", &length,
235 >                "Enter the length of the cylinder.");
236 >        getd("Cylinder radius", &radius,
237 >                "Enter the distance from the cylinder's axis to its surface.");
238 >        area = 2.*PI*unit2meter*unit2meter * radius*length;
239          return(1);
240   }
241  
# Line 235 | Line 244 | getring()                      /* get projected area for a ring */
244   {
245          static double   radius = 1.0;
246  
247 <        printf("Disk radius [%g]: ", radius);
248 <        getd(&radius);
249 <        projarea = PI*PI*unit2meter*unit2meter * radius*radius;
247 >        getd("Disk radius", &radius,
248 > "Enter the distance from the ring's center to its outer edge.\n\
249 > The inner radius must be zero.");
250 >        area = PI*unit2meter*unit2meter * radius*radius;
251          return(1);
252   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines