--- ray/src/cv/lampcolor.c 1991/09/12 13:36:43 1.6 +++ ray/src/cv/lampcolor.c 2003/02/22 02:07:23 2.6 @@ -1,19 +1,19 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: lampcolor.c,v 2.6 2003/02/22 02:07:23 greg Exp $"; #endif - /* * Program to convert lamp color from table and compute radiance. */ #include +#include + +#include "color.h" + #define PI 3.14159265358979323846 extern char *gets(), *strcpy(); -extern double atof(); extern float *matchlamp(); /* lamp parameters */ @@ -27,7 +27,7 @@ int typecheck(), unitcheck(), geomcheck(), outpcheck() float *lampcolor; /* the lamp color (RGB) */ double unit2meter; /* conversion from units to meters */ -double projarea; /* projected area for this geometry */ +double area; /* radiating area for this geometry */ double lumens; /* total lamp lumens */ struct { @@ -36,9 +36,9 @@ struct { int (*check)(); char *help; } param[NPARAMS] = { - { "lamp type", "white", typecheck, + { "lamp type", "WHITE", typecheck, "The lamp type is a string which corresponds to one of the types registered\n\ -in the lamp table file. A value of \"white\" means an uncolored source,\n\ +in the lamp table file. A value of \"WHITE\" means an uncolored source,\n\ which may be preferable because it results in a color balanced image." }, { "length unit", "meter", unitcheck, "Unit must be one of: \"meter\", \"centimeter\", \"foot\", or \"inch\".\n\ @@ -173,7 +173,7 @@ compute() /* compute lamp radiance */ { double whiteval; - whiteval = lumens/470./projarea; + whiteval = lumens/area/(WHTEFFICACY*PI); printf("Lamp color (RGB) = %f %f %f\n", lampcolor[0]*whiteval, @@ -205,11 +205,11 @@ again: getpolygon() /* get projected area for a polygon */ { - static double area = 1.0; + static double parea = 1.0; - getd("Polygon area", &area, + getd("Polygon area", &parea, "Enter the total radiating area of the polygon."); - projarea = PI*unit2meter*unit2meter * area; + area = unit2meter*unit2meter * parea; return(1); } @@ -220,7 +220,7 @@ getsphere() /* get projected area for a sphere */ getd("Sphere radius", &radius, "Enter the distance from the sphere's center to its surface."); - projarea = 4.*PI*PI*unit2meter*unit2meter * radius*radius; + area = 4.*PI*unit2meter*unit2meter * radius*radius; return(1); } @@ -233,7 +233,7 @@ getcylinder() /* get projected area for a cylinder * "Enter the length of the cylinder."); getd("Cylinder radius", &radius, "Enter the distance from the cylinder's axis to its surface."); - projarea = PI*PI*2.*PI*unit2meter*unit2meter * radius*length; + area = 2.*PI*unit2meter*unit2meter * radius*length; return(1); } @@ -245,6 +245,6 @@ getring() /* get projected area for a ring */ getd("Disk radius", &radius, "Enter the distance from the ring's center to its outer edge.\n\ The inner radius must be zero."); - projarea = PI*PI*unit2meter*unit2meter * radius*radius; + area = PI*unit2meter*unit2meter * radius*radius; return(1); }