Path Tracer
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
ptracey::spd Class Reference

Public Member Functions

 spd (uint size=471/SPD_STRIDE)
 
 spd (const sampled_wave< Power > &sampled_powers, WaveLength wstart)
 
 spd (const sampled_wave< Power > &sampled_powers, const std::vector< WaveLength > &wlengths)
 
 spd (uint wave_range, const std::function< WaveLength(uint)> &wavelength_generator, const std::function< Power(WaveLength)> &power_generator)
 
template<typename V >
void fill_with_stride (std::vector< V > &dest, const std::vector< V > &srcv, unsigned int stride)
 
 spd (const path &csv_path, const std::string &wave_col_name="wavelength", const std::string &power_col_name="power", const char &sep=',', const unsigned int stride=SPD_STRIDE, const std::function< WaveLength(WaveLength)> &wave_transform=[](auto j) { return j;}, const std::function< Power(Power)> &power_transform=[](auto j) { return j;})
 
void resample (const spd &s)
 
void resample (const WaveLength &waveLStart, const WaveLength &waveLEnd, const uint &outSize)
 
spd resample_c (const spd &s) const
 
spd resample_c (const uint &outSize) const
 
spd resample_c (const WaveLength &waveLStart, const WaveLength &waveLEnd, const uint &outSize) const
 
sampled_wave< Power > powers () const
 
std::vector< WaveLength > wavelengths () const
 
spd interpolate (Real low=0.0, Real high=FLT_MAX) const
 
spd clamp (Power low=0.0, Power high=FLT_MAX) const
 
spd normalized () const
 
void normalize ()
 
int min_wave () const
 
int max_wave () const
 
Power min_power () const
 
Power max_power () const
 
uint size () const
 
Power integrate (const spd &nspd) const
 
void apply (Power pvalue, const std::function< Power(Power, Power)> &fn)
 
spd apply_c (Power pvalue, const std::function< Power(Power, Power)> &fn) const
 
bool apply (WaveLength wave_length, Power pvalue, const std::function< Power(Power, Power)> &fn)
 
bool apply (const spd &s, const std::function< spd(spd, spd)> &fn, spd &ss) const
 
spd rapply (const spd &s, const std::function< spd(spd, spd)> &eqfn, const std::function< bool(spd, WaveLength, Power)> &uneqfn) const
 
Power interpolate_wave_power (WaveLength wl) const
 
Power operator[] (WaveLength wave_length) const
 
bool in (WaveLength wave_length) const
 
void insert (WaveLength wave_length, Power pvalue)
 
void update (WaveLength wave_length, Power pvalue)
 
void add (WaveLength wave_length, Power pvalue)
 
void scale (Power pvalue)
 
spd operator* (Power pvalue) const
 
spdoperator*= (Power pvalue)
 
spd operator- (Power pvalue) const
 
spd operator+ (Power pvalue) const
 
spdoperator+= (Power pvalue)
 
spdoperator+= (const spd &s)
 

Static Public Member Functions

static spd random ()
 
static spd random (Real mn, Real mx)
 
static spd zeros_like (const spd &s)
 

Public Attributes

WaveLength wave_start
 
WaveLength wave_end
 
std::map< WaveLength, Power > wavelength_power
 

Friends

spd operator* (Power pvalue, const spd &s)
 
spd operator- (Power pvalue, const spd &s)
 
spd operator+ (Power pvalue, const spd &s)
 

Constructor & Destructor Documentation

◆ spd()

ptracey::spd::spd ( uint  wave_range,
const std::function< WaveLength(uint)> &  wavelength_generator,
const std::function< Power(WaveLength)> &  power_generator 
)
inline

Slightly more correct way of making a spds. If the user knows exact functions that generate corresponding power for a given wavelength. That function should be passed in the body of power generator. @power_generator: takes a wavelength as input and generates the corresponding power. @wavelength_generator: maps a discreet range of numbers [0,1,2,...,n] to wavelengths. @wave_range: gives the size of the discreet range of numbers. If the desired range of numbers is [0,1,2,...,n] then n+1 should be given.

Member Function Documentation

◆ rapply()

spd ptracey::spd::rapply ( const spd s,
const std::function< spd(spd, spd)> &  eqfn,
const std::function< bool(spd, WaveLength, Power)> &  uneqfn 
) const
inline

Slightly more robust implementation of apply.

The idea is to give two functions: 1 for matching spds, two for not matching spds. If they match we apply the first function if they don't match. We apply the second function for each wavelength and power value. If the wavelength is not present in the spd we insert it with the given power value.


The documentation for this class was generated from the following files: