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 */ |
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 { |
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\ |
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, |
208 |
|
|
209 |
|
getpolygon() /* get projected area for a polygon */ |
210 |
|
{ |
211 |
< |
static double area = 1.0; |
211 |
> |
static double parea = 1.0; |
212 |
|
|
213 |
< |
getd("Polygon area", &area, |
213 |
> |
getd("Polygon area", &parea, |
214 |
|
"Enter the total radiating area of the polygon."); |
215 |
< |
projarea = PI*unit2meter*unit2meter * area; |
215 |
> |
area = unit2meter*unit2meter * parea; |
216 |
|
return(1); |
217 |
|
} |
218 |
|
|
223 |
|
|
224 |
|
getd("Sphere radius", &radius, |
225 |
|
"Enter the distance from the sphere's center to its surface."); |
226 |
< |
projarea = 4.*PI*PI*unit2meter*unit2meter * radius*radius; |
226 |
> |
area = 4.*PI*unit2meter*unit2meter * radius*radius; |
227 |
|
return(1); |
228 |
|
} |
229 |
|
|
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 |
< |
projarea = PI*PI*2.*PI*unit2meter*unit2meter * radius*length; |
239 |
> |
area = 2.*PI*unit2meter*unit2meter * radius*length; |
240 |
|
return(1); |
241 |
|
} |
242 |
|
|
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 |
< |
projarea = PI*PI*unit2meter*unit2meter * radius*radius; |
251 |
> |
area = PI*unit2meter*unit2meter * radius*radius; |
252 |
|
return(1); |
253 |
|
} |