/* * R T _ S P E C T _ C U R V E _ T O _ X Y Z * * Convenience routine. * Serves same function as Roy Hall's CLR_spect_to_xyz(), pg 233. * The normalization xyz_scale = 1.0 / bn_tabdata_area2(cie_y); * has been folded into spect_make_CIE_XYZ(); */ void spect_curve_to_xyz(point_t xyz, const struct bn_tabdata *tabp, const struct bn_tabdata *cie_x, const struct bn_tabdata *cie_y, const struct bn_tabdata *cie_z) { fastf_t tab_area; BN_CK_TABDATA(tabp); #if 0 tab_area = bn_tabdata_area2(tabp); bu_log(" tab_area = %g\n", tab_area); if (fabs(tab_area) < VDIVIDE_TOL) { bu_log("spect_curve_to_xyz(): Area = 0 (no luminance) in this part of the spectrum\n"); VSETALL(xyz, 0); return; } tab_area = 1 / tab_area; #else /* This is what Roy says to do, but I'm not certain */ tab_area = 1; #endif xyz[X] = bn_tabdata_mul_area2(tabp, cie_x) * tab_area; xyz[Y] = bn_tabdata_mul_area2(tabp, cie_y) * tab_area; xyz[Z] = bn_tabdata_mul_area2(tabp, cie_z) * tab_area; }
static int test_bn_tabdata_mul_area2(int argc, char *argv[]) { struct bn_table *tab_in; struct bn_tabdata *td_in1; struct bn_tabdata *td_in2; fastf_t expected, actual; if (argc != 6) { bu_exit(1, "<args> format: table tabdata1 tabdata2 expected_result [%s]\n", argv[0]); } scan_tab_args(argv[2], &tab_in); scan_tabdata_args(argv[3], &td_in1, tab_in); scan_tabdata_args(argv[4], &td_in2, tab_in); sscanf(argv[5], "%lg", &expected); actual = bn_tabdata_mul_area2(td_in1, td_in2); bu_log("Result: %g\n", actual); return !NEAR_EQUAL(expected, actual, BN_TOL_DIST); }