Routines for processing tables (curves) of data with one independent parameter which is common to many sets of dependent data values.
More...
|
void | bn_table_free (struct bn_table *tabp) |
|
void | bn_tabdata_free (struct bn_tabdata *data) |
|
void | bn_ck_table (const struct bn_table *tabp) |
|
struct bn_table * | bn_table_make_uniform (size_t num, double first, double last) |
|
void | bn_tabdata_add (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2) |
|
void | bn_tabdata_mul (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2) |
|
void | bn_tabdata_mul3 (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, const struct bn_tabdata *in3) |
|
void | bn_tabdata_incr_mul3_scale (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, const struct bn_tabdata *in3, double scale) |
|
void | bn_tabdata_incr_mul2_scale (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, double scale) |
|
void | bn_tabdata_scale (struct bn_tabdata *out, const struct bn_tabdata *in1, double scale) |
|
void | bn_table_scale (struct bn_table *tabp, double scale) |
|
void | bn_tabdata_join1 (struct bn_tabdata *out, const struct bn_tabdata *in1, double scale, const struct bn_tabdata *in2) |
|
void | bn_tabdata_join2 (struct bn_tabdata *out, const struct bn_tabdata *in1, double scale2, const struct bn_tabdata *in2, double scale3, const struct bn_tabdata *in3) |
|
void | bn_tabdata_blend2 (struct bn_tabdata *out, double scale1, const struct bn_tabdata *in1, double scale2, const struct bn_tabdata *in2) |
|
void | bn_tabdata_blend3 (struct bn_tabdata *out, double scale1, const struct bn_tabdata *in1, double scale2, const struct bn_tabdata *in2, double scale3, const struct bn_tabdata *in3) |
|
double | bn_tabdata_area1 (const struct bn_tabdata *in) |
|
double | bn_tabdata_area2 (const struct bn_tabdata *in) |
|
double | bn_tabdata_mul_area1 (const struct bn_tabdata *in1, const struct bn_tabdata *in2) |
|
double | bn_tabdata_mul_area2 (const struct bn_tabdata *in1, const struct bn_tabdata *in2) |
|
fastf_t | bn_table_lin_interp (const struct bn_tabdata *samp, double wl) |
|
struct bn_tabdata * | bn_tabdata_resample_max (const struct bn_table *newtable, const struct bn_tabdata *olddata) |
|
struct bn_tabdata * | bn_tabdata_resample_avg (const struct bn_table *newtable, const struct bn_tabdata *olddata) |
|
int | bn_table_write (const char *filename, const struct bn_table *tabp) |
|
struct bn_table * | bn_table_read (const char *filename) |
|
void | bn_pr_table (const char *title, const struct bn_table *tabp) |
|
void | bn_pr_tabdata (const char *title, const struct bn_tabdata *data) |
|
int | bn_print_table_and_tabdata (const char *filename, const struct bn_tabdata *data) |
|
struct bn_tabdata * | bn_read_table_and_tabdata (const char *filename) |
|
struct bn_tabdata * | bn_tabdata_binary_read (const char *filename, size_t num, const struct bn_table *tabp) |
|
struct bn_tabdata * | bn_tabdata_malloc_array (const struct bn_table *tabp, size_t num) |
|
void | bn_tabdata_copy (struct bn_tabdata *out, const struct bn_tabdata *in) |
|
struct bn_tabdata * | bn_tabdata_dup (const struct bn_tabdata *in) |
|
struct bn_tabdata * | bn_tabdata_get_constval (double val, const struct bn_table *tabp) |
|
void | bn_tabdata_constval (struct bn_tabdata *data, double val) |
|
void | bn_tabdata_to_tcl (struct bu_vls *vp, const struct bn_tabdata *data) |
|
struct bn_tabdata * | bn_tabdata_from_array (const double *array) |
|
void | bn_tabdata_freq_shift (struct bn_tabdata *out, const struct bn_tabdata *in, double offset) |
|
size_t | bn_table_interval_num_samples (const struct bn_table *tabp, double low, double hi) |
|
size_t | bn_table_delete_sample_pnts (struct bn_table *tabp, size_t i, size_t j) |
|
struct bn_table * | bn_table_merge2 (const struct bn_table *a, const struct bn_table *b) |
|
struct bn_tabdata * | bn_tabdata_mk_linear_filter (const struct bn_table *spectrum, double lower_wavelen, double upper_wavelen) |
|
Routines for processing tables (curves) of data with one independent parameter which is common to many sets of dependent data values.
Data structures to assist with recording many sets of data sampled along the same set of independent variables.
The overall notion is that each sample should be as compact as possible (an array of measurements), with all the context stored in one place.
These structures and support routines apply to any measured "curve" or "function" or "table" with one independent variable and one or more scalar dependent variable(s).
The context is kept in an 'bn_table' structure, and the data for one particular sample are kept in an 'bn_tabdata' structure.
The contents of the sample in val[j] are interpreted in the interval (wavel[j]..wavel[j+1]). This value could be power, albedo, absorption, refractive index, or any other wavelength-specific parameter.
For example, if the val[] array contains power values, then val[j] contains the integral of the power from wavel[j] to wavel[j+1]
As an example, assume nwave=2, wavel[0]=500, wavel[1]=600, wavel[2]=700. Then val[0] would contain data for the 500 to 600nm interval, and val[1] would contain data for the 600 to 700nm interval. There would be no storage allocated for val[2] – don't use it! There are several interpretations of this: 1) val[j] stores the total (integral, area) value for the interval, or 2) val[j] stores the average value across the interval.
The intervals need not be uniformly spaced; it is acceptable to increase wavelength sampling density around "important" frequencies.
Operates on bn_table (independent var) and bn_tabdata (dependent variable) structures.
One application is for storing spectral curves, see spectrum.c
- Inspired by -
- Roy Hall and his book "Illumination and Color in Computer
@n Generated Imagery", Springer Verlag, New York, 1989.
ISBN 0-387-96774-5
With thanks to Russ Moulton Jr, EOSoft Inc. for his "rad.c" module.
◆ BN_CK_TABLE
◆ BN_TABLE_NULL
#define BN_TABLE_NULL ((struct bn_table *)NULL) |
◆ BN_GET_TABLE
#define BN_GET_TABLE |
( |
|
_table, |
|
|
|
_nx |
|
) |
| |
Value: { \
if ((_nx) < 1)
bu_bomb("RT_GET_TABLE() _nx < 1\
n"); \
_table->nx = (_nx); }
NORETURN void bu_bomb(const char *str)
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
double fastf_t
fastest 64-bit (or larger) floating point type
Definition at line 101 of file tabdata.h.
◆ BN_CK_TABDATA
◆ BN_TABDATA_NULL
#define BN_TABDATA_NULL ((struct bn_tabdata *)NULL) |
◆ BN_SIZEOF_TABDATA_Y
#define BN_SIZEOF_TABDATA_Y |
( |
|
_tabdata | ) |
sizeof(fastf_t)*((_tabdata)->ny) |
◆ BN_SIZEOF_TABDATA
#define BN_SIZEOF_TABDATA |
( |
|
_table | ) |
|
◆ BN_GET_TABDATA
#define BN_GET_TABDATA |
( |
|
_data, |
|
|
|
_table |
|
) |
| |
Value: { \
BN_CK_TABLE(_table);\
_data->ny = (_table)->nx; \
_data->table = (_table); }
#define BN_SIZEOF_TABDATA(_table)
Definition at line 131 of file tabdata.h.
◆ bn_table_free()
void bn_table_free |
( |
struct bn_table * |
tabp | ) |
|
◆ bn_tabdata_free()
◆ bn_ck_table()
void bn_ck_table |
( |
const struct bn_table * |
tabp | ) |
|
◆ bn_table_make_uniform()
struct bn_table * bn_table_make_uniform |
( |
size_t |
num, |
|
|
double |
first, |
|
|
double |
last |
|
) |
| |
◆ bn_tabdata_add()
◆ bn_tabdata_mul()
◆ bn_tabdata_mul3()
◆ bn_tabdata_incr_mul3_scale()
◆ bn_tabdata_incr_mul2_scale()
◆ bn_tabdata_scale()
◆ bn_table_scale()
void bn_table_scale |
( |
struct bn_table * |
tabp, |
|
|
double |
scale |
|
) |
| |
◆ bn_tabdata_join1()
◆ bn_tabdata_join2()
◆ bn_tabdata_blend2()
◆ bn_tabdata_blend3()
◆ bn_tabdata_area1()
double bn_tabdata_area1 |
( |
const struct bn_tabdata * |
in | ) |
|
◆ bn_tabdata_area2()
double bn_tabdata_area2 |
( |
const struct bn_tabdata * |
in | ) |
|
◆ bn_tabdata_mul_area1()
◆ bn_tabdata_mul_area2()
◆ bn_table_lin_interp()
◆ bn_tabdata_resample_max()
◆ bn_tabdata_resample_avg()
◆ bn_table_write()
int bn_table_write |
( |
const char * |
filename, |
|
|
const struct bn_table * |
tabp |
|
) |
| |
◆ bn_table_read()
struct bn_table * bn_table_read |
( |
const char * |
filename | ) |
|
◆ bn_pr_table()
void bn_pr_table |
( |
const char * |
title, |
|
|
const struct bn_table * |
tabp |
|
) |
| |
◆ bn_pr_tabdata()
void bn_pr_tabdata |
( |
const char * |
title, |
|
|
const struct bn_tabdata * |
data |
|
) |
| |
◆ bn_print_table_and_tabdata()
int bn_print_table_and_tabdata |
( |
const char * |
filename, |
|
|
const struct bn_tabdata * |
data |
|
) |
| |
◆ bn_read_table_and_tabdata()
struct bn_tabdata * bn_read_table_and_tabdata |
( |
const char * |
filename | ) |
|
◆ bn_tabdata_binary_read()
struct bn_tabdata * bn_tabdata_binary_read |
( |
const char * |
filename, |
|
|
size_t |
num, |
|
|
const struct bn_table * |
tabp |
|
) |
| |
◆ bn_tabdata_malloc_array()
◆ bn_tabdata_copy()
◆ bn_tabdata_dup()
◆ bn_tabdata_get_constval()
◆ bn_tabdata_constval()
void bn_tabdata_constval |
( |
struct bn_tabdata * |
data, |
|
|
double |
val |
|
) |
| |
◆ bn_tabdata_to_tcl()
◆ bn_tabdata_from_array()
struct bn_tabdata * bn_tabdata_from_array |
( |
const double * |
array | ) |
|
◆ bn_tabdata_freq_shift()
◆ bn_table_interval_num_samples()
size_t bn_table_interval_num_samples |
( |
const struct bn_table * |
tabp, |
|
|
double |
low, |
|
|
double |
hi |
|
) |
| |
◆ bn_table_delete_sample_pnts()
size_t bn_table_delete_sample_pnts |
( |
struct bn_table * |
tabp, |
|
|
size_t |
i, |
|
|
size_t |
j |
|
) |
| |
◆ bn_table_merge2()
◆ bn_tabdata_mk_linear_filter()
struct bn_tabdata * bn_tabdata_mk_linear_filter |
( |
const struct bn_table * |
spectrum, |
|
|
double |
lower_wavelen, |
|
|
double |
upper_wavelen |
|
) |
| |