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

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...
 
SHVectoroperator= (const SHVector &v)
 Assignment. More...
 
void clear ()
 Set all coefficients to zero. More...
 
SHVectoroperator+= (const SHVector &v)
 Component-wise addition. More...
 
SHVector operator+ (const SHVector &v) const
 Component-wise addition. More...
 
SHVectoroperator-= (const SHVector &v)
 Component-wise subtraction. More...
 
SHVector operator- (const SHVector &v) const
 Component-wise subtraction. More...
 
SHVectormadd (Float f, const SHVector &v)
 Add a scalar multiple of another vector. More...
 
SHVectoroperator*= (Float f)
 Scalar multiplication. More...
 
SHVector operator* (Float f) const
 Scalar multiplication. More...
 
SHVectoroperator/= (Float f)
 Scalar division. More...
 
SHVector operator/ (Float f) const
 Scalar division. More...
 
SHVector operator- () const
 Negation operator. More...
 
Floatoperator() (int l, int m)
 Access coefficient m (in {-l, ..., l}) on band l. More...
 
const Floatoperator() (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...
 

Detailed Description

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:

SphericalHarmonicQ[l_, m_, \[Theta]_, \[Phi]_] :=
Piecewise[{
{SphericalHarmonicY[l, m, \[Theta], \[Phi]], m == 0},
{Sqrt[2]*Re[SphericalHarmonicY[l, m, \[Theta], \[Phi]]], m > 0},
{Sqrt[2]*Im[SphericalHarmonicY[l, -m, \[Theta], \[Phi]]], m < 0}
}]

Constructor & Destructor Documentation

mitsuba::SHVector::SHVector ( )
inline

Construct an invalid SH vector.

mitsuba::SHVector::SHVector ( int  bands)
inline

Construct a new SH vector (initialized to zero)

mitsuba::SHVector::SHVector ( Stream stream)

Unserialize a SH vector to a binary data stream.

mitsuba::SHVector::SHVector ( const SHVector v)
inline

Copy constructor.

Member Function Documentation

void mitsuba::SHVector::addOffset ( Float  value)

Add a constant value.

void mitsuba::SHVector::clear ( )
inline

Set all coefficients to zero.

static Float mitsuba::SHVector::computeNormalization ( int  l,
int  m 
)
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.

Float mitsuba::SHVector::energy ( int  band) const
inline

Get the energy per band.

Float mitsuba::SHVector::eval ( Float  theta,
Float  phi 
) const

Evaluate for a direction given in spherical coordinates.

Float mitsuba::SHVector::eval ( const Vector v) const

Evaluate for a direction given in Cartesian coordinates.

Float mitsuba::SHVector::evalAzimuthallyInvariant ( Float  theta,
Float  phi 
) const

Evaluate for a direction given in spherical coordinates.

This function is much faster but only works for azimuthally invariant functions

Float mitsuba::SHVector::evalAzimuthallyInvariant ( const Vector v) const

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.

int mitsuba::SHVector::getBands ( ) const
inline

Return the number of stored SH coefficient bands.

bool mitsuba::SHVector::isAzimuthallyInvariant ( ) const

Check if this function is azumuthally invariant.

template<typename Functor >
Float mitsuba::SHVector::l2Error ( const Functor &  f,
int  res = 32 
) const
inline

Compute the relative L2 error.

SHVector& mitsuba::SHVector::madd ( Float  f,
const SHVector v 
)
inline

Add a scalar multiple of another vector.

Matrix3x3 mitsuba::SHVector::mu2 ( ) const

Compute the second spherical moment (analytic)

static Float mitsuba::SHVector::normalization ( int  l,
int  m 
)
inlinestatic

Return a normalization coefficient.

void mitsuba::SHVector::normalize ( )

Normalize so that the represented function becomes a valid distribution.

bool mitsuba::SHVector::operator!= ( const SHVector v) const
inline

Equality comparison operator.

Float& mitsuba::SHVector::operator() ( int  l,
int  m 
)
inline

Access coefficient m (in {-l, ..., l}) on band l.

const Float& mitsuba::SHVector::operator() ( int  l,
int  m 
) const
inline

Access coefficient m (in {-l, ..., l}) on band l.

SHVector mitsuba::SHVector::operator* ( Float  f) const
inline

Scalar multiplication.

SHVector& mitsuba::SHVector::operator*= ( Float  f)
inline

Scalar multiplication.

SHVector mitsuba::SHVector::operator+ ( const SHVector v) const
inline

Component-wise addition.

SHVector& mitsuba::SHVector::operator+= ( const SHVector v)
inline

Component-wise addition.

SHVector mitsuba::SHVector::operator- ( const SHVector v) const
inline

Component-wise subtraction.

SHVector mitsuba::SHVector::operator- ( ) const
inline

Negation operator.

SHVector& mitsuba::SHVector::operator-= ( const SHVector v)
inline

Component-wise subtraction.

SHVector mitsuba::SHVector::operator/ ( Float  f) const
inline

Scalar division.

SHVector& mitsuba::SHVector::operator/= ( Float  f)
inline

Scalar division.

SHVector& mitsuba::SHVector::operator= ( const SHVector v)
inline

Assignment.

bool mitsuba::SHVector::operator== ( const SHVector v) const
inline

Equality comparison operator.

template<typename Functor >
void mitsuba::SHVector::project ( const Functor &  f,
int  res = 32 
)
inline

Project the given function onto a SH basis (using a 2D composite Simpson's rule)

static void mitsuba::SHVector::rotation ( const Transform t,
SHRotation rot 
)
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.

static void mitsuba::SHVector::rotationBlock ( const SHRotation::Matrix M1,
const SHRotation::Matrix Mp,
SHRotation::Matrix Mn 
)
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 void mitsuba::SHVector::staticInitialization ( )
static

Precomputes normalization coefficients for the first few bands.

static void mitsuba::SHVector::staticShutdown ( )
static

Free the memory taken up by staticInitialization()

std::string mitsuba::SHVector::toString ( ) const

Turn into a string representation.

Friends And Related Function Documentation

Float dot ( const SHVector v1,
const SHVector v2 
)
friend

Dot product.


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