Stores a truncated real spherical harmonics representation of an L2-integrable function. More...
#include <mitsuba/core/shvector.h>
Public Member Functions | |
SHVector () | |
Construct an invalid SH vector. More... | |
SHVector (int bands) | |
Construct a new SH vector (initialized to zero) More... | |
SHVector (Stream *stream) | |
Unserialize a SH vector to a binary data stream. More... | |
SHVector (const SHVector &v) | |
Copy constructor. More... | |
int | getBands () const |
Return the number of stored SH coefficient bands. More... | |
void | serialize (Stream *stream) const |
Serialize a SH vector to a binary data stream. More... | |
Float | energy (int band) const |
Get the energy per band. More... | |
SHVector & | operator= (const SHVector &v) |
Assignment. More... | |
void | clear () |
Set all coefficients to zero. More... | |
SHVector & | operator+= (const SHVector &v) |
Component-wise addition. More... | |
SHVector | operator+ (const SHVector &v) const |
Component-wise addition. More... | |
SHVector & | operator-= (const SHVector &v) |
Component-wise subtraction. More... | |
SHVector | operator- (const SHVector &v) const |
Component-wise subtraction. More... | |
SHVector & | madd (Float f, const SHVector &v) |
Add a scalar multiple of another vector. More... | |
SHVector & | operator*= (Float f) |
Scalar multiplication. More... | |
SHVector | operator* (Float f) const |
Scalar multiplication. More... | |
SHVector & | operator/= (Float f) |
Scalar division. More... | |
SHVector | operator/ (Float f) const |
Scalar division. More... | |
SHVector | operator- () const |
Negation operator. More... | |
Float & | operator() (int l, int m) |
Access coefficient m (in {-l, ..., l}) on band l. More... | |
const Float & | operator() (int l, int m) const |
Access coefficient m (in {-l, ..., l}) on band l. More... | |
Float | eval (Float theta, Float phi) const |
Evaluate for a direction given in spherical coordinates. More... | |
Float | eval (const Vector &v) const |
Evaluate for a direction given in Cartesian coordinates. More... | |
Float | evalAzimuthallyInvariant (Float theta, Float phi) const |
Evaluate for a direction given in spherical coordinates. More... | |
Float | evalAzimuthallyInvariant (const Vector &v) const |
Evaluate for a direction given in cartesian coordinates. More... | |
bool | isAzimuthallyInvariant () const |
Check if this function is azumuthally invariant. More... | |
bool | operator== (const SHVector &v) const |
Equality comparison operator. More... | |
bool | operator!= (const SHVector &v) const |
Equality comparison operator. More... | |
void | normalize () |
Normalize so that the represented function becomes a valid distribution. More... | |
Matrix3x3 | mu2 () const |
Compute the second spherical moment (analytic) More... | |
Float | findMinimum (int res) const |
Brute-force search for the minimum value over the sphere. More... | |
void | addOffset (Float value) |
Add a constant value. More... | |
void | convolve (const SHVector &kernel) |
Convolve the SH representation with the supplied kernel. More... | |
template<typename Functor > | |
void | project (const Functor &f, int res=32) |
Project the given function onto a SH basis (using a 2D composite Simpson's rule) More... | |
template<typename Functor > | |
Float | l2Error (const Functor &f, int res=32) const |
Compute the relative L2 error. More... | |
std::string | toString () const |
Turn into a string representation. More... | |
Static Public Member Functions | |
static Float | normalization (int l, int m) |
Return a normalization coefficient. More... | |
static void | rotation (const Transform &t, SHRotation &rot) |
Recursively computes rotation matrices for each band of SH coefficients. More... | |
static void | staticInitialization () |
Precomputes normalization coefficients for the first few bands. More... | |
static void | staticShutdown () |
Free the memory taken up by staticInitialization() More... | |
Static Protected Member Functions | |
static void | rotationBlock (const SHRotation::Matrix &M1, const SHRotation::Matrix &Mp, SHRotation::Matrix &Mn) |
Helper function for rotation() – computes a diagonal block based on the previous level. More... | |
static Float | computeNormalization (int l, int m) |
Compute a normalization coefficient. More... | |
Friends | |
Float | dot (const SHVector &v1, const SHVector &v2) |
Dot product. More... | |
Stores a truncated real spherical harmonics representation of an L2-integrable function.
Also provides some other useful functionality, such as evaluation, projection and rotation.
The Mathematica equivalent of the basis functions implemented here is:
|
inline |
Construct an invalid SH vector.
|
inline |
Construct a new SH vector (initialized to zero)
mitsuba::SHVector::SHVector | ( | Stream * | stream | ) |
Unserialize a SH vector to a binary data stream.
|
inline |
Copy constructor.
void mitsuba::SHVector::addOffset | ( | Float | value | ) |
Add a constant value.
|
inline |
Set all coefficients to zero.
|
staticprotected |
Compute a normalization coefficient.
void mitsuba::SHVector::convolve | ( | const SHVector & | kernel | ) |
Convolve the SH representation with the supplied kernel.
Based on the Funk-Hecke theorem – the kernel must be rotationally symmetric around the Z-axis.
|
inline |
Get the energy per band.
Evaluate for a direction given in spherical coordinates.
Evaluate for a direction given in Cartesian coordinates.
Evaluate for a direction given in spherical coordinates.
This function is much faster but only works for azimuthally invariant functions
Evaluate for a direction given in cartesian coordinates.
This function is much faster but only works for azimuthally invariant functions
Float mitsuba::SHVector::findMinimum | ( | int | res | ) | const |
Brute-force search for the minimum value over the sphere.
|
inline |
Return the number of stored SH coefficient bands.
bool mitsuba::SHVector::isAzimuthallyInvariant | ( | ) | const |
Check if this function is azumuthally invariant.
|
inline |
Compute the relative L2 error.
Add a scalar multiple of another vector.
Matrix3x3 mitsuba::SHVector::mu2 | ( | ) | const |
Compute the second spherical moment (analytic)
|
inlinestatic |
Return a normalization coefficient.
void mitsuba::SHVector::normalize | ( | ) |
Normalize so that the represented function becomes a valid distribution.
|
inline |
Access coefficient m (in {-l, ..., l}) on band l.
|
inline |
Access coefficient m (in {-l, ..., l}) on band l.
Component-wise subtraction.
|
inline |
Negation operator.
|
inline |
Project the given function onto a SH basis (using a 2D composite Simpson's rule)
|
static |
Recursively computes rotation matrices for each band of SH coefficients.
Based on 'Rotation Matrices for Real Spherical Harmonics. Direct Determination by Recursion' by Ivanic and Ruedenberg. The implemented tables follow the notation in 'Spherical Harmonic Lighting: The Gritty Details' by Robin Green.
|
staticprotected |
Helper function for rotation() – computes a diagonal block based on the previous level.
void mitsuba::SHVector::serialize | ( | Stream * | stream | ) | const |
Serialize a SH vector to a binary data stream.
|
static |
Precomputes normalization coefficients for the first few bands.
|
static |
Free the memory taken up by staticInitialization()
std::string mitsuba::SHVector::toString | ( | ) | const |
Turn into a string representation.