cisst-saw
|
#include <nmrBernsteinPolynomialLineIntegral.h>
Classes | |
struct | ProfilingInfo |
struct | TermSummationElement |
Public Types | |
typedef nmrPolynomialBase::ValueType | ValueType |
typedef nmrPolynomialBase::VariableType | VariableType |
typedef nmrPolynomialBase::VariableIndexType | VariableIndexType |
typedef nmrPolynomialBase::CoefficientType | CoefficientType |
typedef nmrPolynomialBase::PowerType | PowerType |
typedef nmrBernsteinPolynomial | IntegrandType |
typedef nmrPolynomialTermPowerIndex::MultinomialCoefficientType | MultinomialType |
Public Member Functions | |
nmrBernsteinPolynomialLineIntegral (const IntegrandType &integrand) | |
void | UpdateIntegrationTableau () |
ValueType | EvaluateForSegment (const VariableType p0[], const VariableType p1[], const VariableType gradientNorm, const double roundoffTolerance=DefaultRoundoffTolerance, CoefficientType const *coefficients=NULL) |
const IntegrandType & | GetIntegrand () const |
Static Public Attributes | |
static const double | DefaultRoundoffTolerance |
Protected Types | |
typedef std::vector< PowerType > | PowerIndexType |
typedef std::vector < TermSummationElement > | SingleTermIntegrationTableau |
typedef std::vector < SingleTermIntegrationTableau > | PolynomialIntegrationTableau |
typedef std::vector < VariableIndexType > | IndexContainerForZeroVariables |
Static Protected Member Functions | |
static ValueType | IntegrateSingleTerm (const CoefficientType termCoefficient, const CoefficientType gradientNorm, const nmrPolynomialTermPowerIndex &termIndex, const nmrMultiVariablePowerBasis &powersAtP0, const nmrMultiVariablePowerBasis &powersAtP1, const double roundoffTolerance=DefaultRoundoffTolerance) |
static ValueType | IntegrateSingleTerm (const CoefficientType termCoefficient, const CoefficientType gradientNorm, const PowerType termDegree, const SingleTermIntegrationTableau &termIntegrationTableau, const nmrMultiVariablePowerBasis &powersAtP0, const nmrMultiVariablePowerBasis &powersAtP1, const IndexContainerForZeroVariables &zerosOfP0, const IndexContainerForZeroVariables &zerosOfP1) |
static void | InitializePolynomialIntegrationTableau (const IntegrandType &integrand, PolynomialIntegrationTableau &tableau) |
static void | InitializeSingleTermIntegrationTableau (const nmrPolynomialTermPowerIndex &termIndex, SingleTermIntegrationTableau &termTableau) |
class nmrBernsteinPolynomialLineIntegral
Evaluates the line integral of a Bernstein polynomial in n variables. The class is initialized with the integrand polynomial. To evaluate the integral for a segment, call the function EvaluateForSegment() and give the coordinates of two points in n-space between which is the line segment to be integrated.
The integration method iterates for each term of the integrand, and evaluates the integral for the term, then sums all the term integrals together. The following paragraphs should be compiled by LaTex to be visualized as formulas.
For the purpose of this discussion we shall use coordinate indexes starting with 0 instead of the mathematical convention of 1, to correspond to the indexing in C.
Let be the ``barycentric'' plane. Let
be two points in the plane. We want to integrate a (Bernstein) polynomial
along the line segment
. For simplicity, we will show here the formula for the integration of a single term of the polynomial, given by
. We know that we can parametrize
in the segment as:
We note that . To evaluate the integral using the parametrized version, we need to multiply the function
by the norm of the gradient:
where is the degree of the Bernstein term;
,
are
-length lists of powers of the corresponding variables of the polynomial, s.t.
;
is the operator of summing the elements (powers) in the list; and
is the Bernstein term
The formulas above evaluate the line integral when ,
, and
are all in barycentric coordinates. This formula produces erroneous result if we want to compute the integral in the Cartesian space, as it does not take the Cartesian distances into account. For example, consider a tetrahedron with a constant density function. The integral between two points which are given in barycentric coordinates will be the same regardless of the size of the tetrahedron. But for a tetrahedron twice as large, the segment is twice as long, and we integrate the same constant density function over a doubled distance, which should have yielded a doubled integral value. To correct this error, all we need is to re-formulate the gradient. Instead of taking the gradient in barycentric coordinates, we will take it in Cartesian coordinates. Thus the scaling of the integral should change from
to
, where
and
are the ends of the segment given in Cartesian coordinates.
For an actual development of this formula, see Russ Taylor's technical paper on Bernstein Polynomial Properties.
|
protected |
typedef nmrPolynomialTermPowerIndex::MultinomialCoefficientType nmrBernsteinPolynomialLineIntegral::MultinomialType |
|
protected |
|
protected |
|
protected |
|
inline |
ValueType nmrBernsteinPolynomialLineIntegral::EvaluateForSegment | ( | const VariableType | p0[], |
const VariableType | p1[], | ||
const VariableType | gradientNorm, | ||
const double | roundoffTolerance = DefaultRoundoffTolerance , |
||
CoefficientType const * | coefficients = NULL |
||
) |
Evaluate the line integral for the segment [p0..p1]. The formulas for the integral are in this class's main documentation.
p0 | first vertex of the segment, given in barycentric coordinates |
p1 | second vertex of the segmend, given in barycentric coordinates |
gradientNorm | the norm of the gradient, as described in the integration formula. As the inputs to this function are given in barycentric coordinates, the gradient norm must be provided from outside. The user may use the length of the segment in Cartesian coordinates or in barycentric coordinates. |
roundoffTolerance | a small positive real number. If the absolute value of a variable is <= roundoffTolerance, it is rounded to zero, and reduces the number of iterations required for the integration. |
coefficients | if this argument is non-null, then our algorithm uses externally defined coefficients, which are stored in this array. Note that the external coefficients must be in the same order as the ones in the polynomial. See nmrPolynomialBase::EvaluateForCoefficients(). Using external coefficients can improve the runtime efficiency when the integrals are computed with many sets of coefficients, and then the coefficient sets can be cached elsewhere (the polynomial only has one set of coefficients). |
|
inline |
|
staticprotected |
|
staticprotected |
|
staticprotected |
Integration of a single term of the integrand polynomial, using the formula developed above.
termCoefficient | the coefficient of the integrand term |
gradientNorm | the norm of the gradient, which is a constant equal to the distance between the vertices of the segment. |
termIndex | the power index of the integrand term |
powersAtP0 | pre-computed power basis for all the variables at the "P0" vertex. In old versions, we used nmrStandardPolynomial as a container for the powers. It is now replaced with the independent object nmrMultiVariablePowerBasis. |
powersAtP1 | pre-computed power basis for all the variables at the "P1" vertex. |
roundoffTolerance | a small positive real number. If the absolute value of a variable is <= roundoffTolerance, it is rounded to zero, and reduces the number of iterations required for the integration. |
|
staticprotected |
Integration of a single term of the integrand polynomial using a pre-computed tableau which stores the power-indices of all the summation elements constituting the term.
termCoefficient | the coefficient of the integrand term |
gradientNorm | the norm of the gradient, which is a constant equal to the distance between the endpoints of the segment. |
termDegree | the degree of the integrand term. The product (gradientNorm * (termDegree+1)) is a denominator of the integral. |
powersAtP0 | pre-computed power basis for all the variables at the "P0" vertex. |
powersAtP1 | pre-computed power basis for all the variables at the "P1" vertex. |
zerosOfP0 | indices of the P0 variables which are equal to zero. Summation element in which the power of a zero variable is positive are skipped. |
zerosOfP1 | indices of the P1 variables which are equal to zero. |
profileInfo | (optional) pointer to a struct that stores inegration profiling. |
|
inline |
As the integrand may change since the initialization of this object, this method lets the user update the integration tableau after changing the integrand (e.g., by adding or removing terms).
|
static |
|
protected |
|
protected |
|
protected |
|
protected |