--- ray/src/cv/bsdf2rad.c 2018/07/20 00:50:40 2.34 +++ ray/src/cv/bsdf2rad.c 2021/12/07 23:55:02 2.39 @@ -1,16 +1,14 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf2rad.c,v 2.34 2018/07/20 00:50:40 greg Exp $"; +static const char RCSid[] = "$Id: bsdf2rad.c,v 2.39 2021/12/07 23:55:02 greg Exp $"; #endif /* * Plot 3-D BSDF output based on scattering interpolant or XML representation */ -#include -#include #include +#include "rtio.h" #include "paths.h" #include "rtmath.h" -#include "resolu.h" #include "bsdfrep.h" #ifndef NINCIDENT @@ -43,8 +41,6 @@ const double sph_xoffset = 15.; #define bsdf_rad (sph_rad*.25) #define arrow_rad (bsdf_rad*.015) -#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) - #define set_minlog() overall_min = (overall_min < 1e-5) ? 1e-5 : overall_min; \ min_log10 = log10(overall_min) - .1 @@ -148,8 +144,8 @@ plotBSDF(const char *fname, const FVECT ivec, int dfl, SDValue sval; double bsdf; ovec_from_pos(ovec, i*GRIDSTEP, j*GRIDSTEP); - if (SDreportError(SDevalBSDF(&sval, ovec, - ivec, sd), stderr)) + if (SDreportError(SDevalBSDF(&sval, ivec, + ovec, sd), stderr)) return(0); if (sval.cieY > overall_max) overall_max = sval.cieY; @@ -350,19 +346,19 @@ addrot(char *xf, const FVECT xp, const FVECT yp, const return(4); } theta = atan2(yp[2], zp[2]); - if (!FEQ(theta,0.0)) { + if (!FABSEQ(theta,0.0)) { sprintf(xf, " -rx %f", theta*(180./PI)); while (*xf) ++xf; n += 2; } theta = Asin(-xp[2]); - if (!FEQ(theta,0.0)) { + if (!FABSEQ(theta,0.0)) { sprintf(xf, " -ry %f", theta*(180./PI)); while (*xf) ++xf; n += 2; } theta = atan2(xp[1], xp[0]); - if (!FEQ(theta,0.0)) { + if (!FABSEQ(theta,0.0)) { sprintf(xf, " -rz %f", theta*(180./PI)); /* while (*xf) ++xf; */ n += 2; @@ -676,7 +672,7 @@ convert_mgf(const char *mgfdata) static int rbf_headline(char *s, void *p) { - char fmt[64]; + char fmt[MAXFMTLEN]; if (formatval(fmt, s)) { if (strcmp(fmt, BSDFREP_FMT)) @@ -756,9 +752,10 @@ main(int argc, char *argv[]) overall_min = myBSDF.rLambFront.cieY/PI; if (back_comp & SDsampR && myBSDF.rLambBack.cieY < overall_min*PI) overall_min = myBSDF.rLambBack.cieY/PI; - if ((front_comp|back_comp) & SDsampT && - myBSDF.tLamb.cieY < overall_min*PI) - overall_min = myBSDF.tLamb.cieY/PI; + if (front_comp & SDsampT && myBSDF.tLambFront.cieY < overall_min*PI) + overall_min = myBSDF.tLambFront.cieY/PI; + if (back_comp & SDsampT && myBSDF.tLambBack.cieY < overall_min*PI) + overall_min = myBSDF.tLambBack.cieY/PI; } set_minlog(); if (!build_wBSDF(&myBSDF))