Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::InterpolatedSpectrum Class Reference

Linearly interpolated spectral power distribution. More...

#include <mitsuba/core/spectrum.h>

+ Inheritance diagram for mitsuba::InterpolatedSpectrum:

Public Member Functions

 InterpolatedSpectrum (size_t size=0)
 Create a new interpolated spectrum with space for the specified number of samples. More...
 
 InterpolatedSpectrum (const Float *wavelengths, const Float *values, size_t nEntries)
 Create a interpolated spectrum instance from a float array. More...
 
 InterpolatedSpectrum (const fs::path &path)
 Read an interpolated spectrum from a simple ASCII format. More...
 
void append (Float lambda, Float value)
 Append an entry to the spectral power distribution. More...
 
void zeroExtend ()
 This function adds a zero entry before and after the stored wavelength range. More...
 
void clear ()
 Clear all stored entries. More...
 
Float eval (Float lambda) const
 Return the value of the spectral power distribution at the given wavelength. More...
 
Float average (Float lambdaMin, Float lambdaMax) const
 Integrate the spectral power distribution over a given interval and return the average value. More...
 
std::string toString () const
 Return a string representation. More...
 
virtual ~InterpolatedSpectrum ()
 Virtual destructor. More...
 
- Public Member Functions inherited from mitsuba::ContinuousSpectrum
virtual ~ContinuousSpectrum ()
 Virtual destructor. More...
 

Protected Attributes

std::vector< Floatm_wavelengths
 
std::vector< Floatm_values
 

Detailed Description

Linearly interpolated spectral power distribution.

This class implements a linearly interpolated spectral power distribution that is defined over a discrete set of measurements at different wavelengths. Outside of the specified range, the spectrum is assumed to be zero. Hence, at least two entries are required to produce a nonzero spectrum.

Constructor & Destructor Documentation

mitsuba::InterpolatedSpectrum::InterpolatedSpectrum ( size_t  size = 0)

Create a new interpolated spectrum with space for the specified number of samples.

mitsuba::InterpolatedSpectrum::InterpolatedSpectrum ( const Float wavelengths,
const Float values,
size_t  nEntries 
)

Create a interpolated spectrum instance from a float array.

mitsuba::InterpolatedSpectrum::InterpolatedSpectrum ( const fs::path &  path)

Read an interpolated spectrum from a simple ASCII format.

Each line of the file should contain an entry of the form

* <wavelength in nm> <value>
* 

Comments preceded by '#' are also valid.

virtual mitsuba::InterpolatedSpectrum::~InterpolatedSpectrum ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

void mitsuba::InterpolatedSpectrum::append ( Float  lambda,
Float  value 
)

Append an entry to the spectral power distribution.

Entries must be added in order of increasing wavelength

Float mitsuba::InterpolatedSpectrum::average ( Float  lambdaMin,
Float  lambdaMax 
) const
virtual

Integrate the spectral power distribution over a given interval and return the average value.

This method overrides the implementation in ContinousSpectrum, since the integral can be analytically computed for linearly interpolated spectra.

Parameters
lambdaMinThe lower interval bound in nanometers
lambdaMaxThe upper interval bound in nanometers
Remarks
If lambdaMin >= lambdaMax, the implementation will return zero.

Reimplemented from mitsuba::ContinuousSpectrum.

void mitsuba::InterpolatedSpectrum::clear ( )

Clear all stored entries.

Float mitsuba::InterpolatedSpectrum::eval ( Float  lambda) const
virtual

Return the value of the spectral power distribution at the given wavelength.

Implements mitsuba::ContinuousSpectrum.

std::string mitsuba::InterpolatedSpectrum::toString ( ) const
virtual

Return a string representation.

Implements mitsuba::ContinuousSpectrum.

void mitsuba::InterpolatedSpectrum::zeroExtend ( )

This function adds a zero entry before and after the stored wavelength range.

This is useful when handling datasets that don't fall off to zero at the ends. The spacing of the added entries is determined by computing the average spacing of the existing samples.

Member Data Documentation

std::vector<Float> mitsuba::InterpolatedSpectrum::m_values
protected
std::vector<Float> mitsuba::InterpolatedSpectrum::m_wavelengths
protected

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