iheartla / Iheartla.github.io

0 stars 0 forks source link

[cpp/Eigen] Integration #10

Open pressureless opened 3 years ago

pressureless commented 3 years ago

Create by @soufianekhiat:

With sample: https://cragl.cs.gmu.edu/iheartla/evaluation/gallery/course_curvature/index.html

Generate a 'hole' in the source code:

double H_left_parenthesis_p_right_parenthesis = 1 / double((2 * M_PI)) * ;

I guess, mainly due to a lack of Eigen integration module.

We could 'hack' that do have a work around like:

template < typename Lambda >
double Integrate( Lambda fun, float min, float max, int step )
{
    double dx = (max - min) / static_cast<double>( step );
    double integral = 0.0;
    for (double xi = min; xi <= max; xi += dx)
    {
        integral += dx * fun( xi );
    }
    return integral;
}

At least that would make the code compilable.

The could sample will became:


double H_left_parenthesis_p_right_parenthesis = 1 / double((2 * M_PI)) * Integrate( [&](double phi){ return kₙ(phi, p) }, 0.0, 2.0*M_PI );```
pressureless commented 3 years ago

You're correct, we haven't supported it due to a lack of Eigen integration module. The output code shouldn't include C++ code for that example. Thanks for the reminder and the suggestion!