Code Monkey home page Code Monkey logo

integralsh's Introduction

Analytical Integration of Spherical Harmonics

This code implements the analytical integration method from Integrating Clipped Spherical Harmonics Expansions. It permits to efficiently integrates Spherical Harmonics (SH) over polygonal geometries.

Use this code

The integration code is header only and template based. It requires a C++11 compiler and uses Eigen to perform linear algebra operations. Eigen is provided as a submodule of this git repository.

A CMake script is provided to perform the sanity check of the code. Examples of use of the spherical integration code can be found in test. To compile the test suite, please init the different submodules using git submodule update --init --recursive and use the CMake script to generate the different binaries.

Templates

This code relies on templates to enable a simpler integration into other codebases. We provide examples of our wrappers in tests/Test.hpp. To use our code, you will have to define the following class wrappers:

  • class SH that provides FastBasis, a method to compute the vector of Spherical Harmonics basis elements for a given input vector and other SH related functions. See our implementation in tests/SphericalInt.cpp.
  • class Vector that represent 3D vectors. This class needs to provide static functions such as Dot, Normalize and Cross.
  • class Triangle and class Edge that represent a spherical triangle which is a simple iterator over a set of edges.

Using Spherical Integration Code

The spherical integration code is located in the SphericalIntegration.hpp header. Given an input triangle triangle and a Spherical Harmonics decomposition a function to integrate clm, the method works as follows:

First, convert the SH expansion to a Zonal Harmonics expansion zlm with a set of basis vectors basis. You can use our SamplingBlueNoise method located in DirectionsSampling.hpp to generate a basis vectors:

  // Generate a basis vector for an order `order` SH
  const auto basis = SamplingBlueNoise<Vector>(2*order+1);

Then use this basis vectors to compute the conversion SH -> ZH -> Power of cosines:

  // Get the Zonal weights matrix and the Zlm -> Ylm conversion matrix
  // and compute the product of the two: `Prod = A x Zw`.
  const auto ZW  = ZonalWeights<Vector>(basis);
  const auto Y   = ZonalExpansion<SH, Vector>(basis);
  const auto A   = computeInverse(Y);
  const auto cpw = clm.transpose() * (A*ZW);

Note that the matrix A*ZW can be cached to improve performances.

Then the AxialMoments method will return the vector of cosine power integrals for the triangle triangle:

  // Analytical evaluation of the integral of power of cosines for
  // the different basis elements up to the order defined by the
  // number of elements in the basis
  const auto moments = AxialMoments<Triangle, Vector>(triangle, basis);
  return cpw.dot(moments);

integralsh's People

Contributors

belcour avatar

Watchers

James Cloos avatar 且听风吟 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.