3#include <Common/assertion.h>
35 if(func.
numPoints() == 1)
return (m_x1 - m_x0) * p0.
y();
36 if(m_x1 < p0.
x())
return (m_x1 - m_x0) * p0.
y();
37 if(m_x0 > pN.
x())
return (m_x1 - m_x0) * pN.
y();
42 if(m_x0 <= p0.
x()) sum += (p0.
x() - m_x0) * p0.
y();
43 if(m_x1 >= pN.
x()) sum += (m_x1 - pN.
x()) * pN.
y();
47 for(std::size_t i = 0; i < func.
numPoints() - 1; i++)
51 const auto& p1 = func.
getPoint(i + 1);
52 const T x0 = std::max(m_x0, p0.
x());
53 const T x1 = std::min(m_x1, p1.x());
58 sum += (func.
evaluate(x0, i, i + 1) + func.
evaluate(x1, i, i + 1)) * (x1 - x0) / 2;
Definition TAnalyticalIntegrator1D.h:10
T integrate(const TPiecewiseLinear1D< T > &func) const
Definition TAnalyticalIntegrator1D.ipp:23
void setIntegrationDomain(T x0, T x1)
Definition TAnalyticalIntegrator1D.ipp:66
TAnalyticalIntegrator1D()
Definition TAnalyticalIntegrator1D.ipp:11
Definition TPiecewiseLinear1D.h:26
TVector2< T > getPoint(std::size_t pointIndex) const
Definition TPiecewiseLinear1D.h:127
std::size_t numPoints() const
Definition TPiecewiseLinear1D.h:121
T evaluate(T x) const
Definition TPiecewiseLinear1D.h:54
Represents a 2-D vector.
Definition TVector2.h:19
T & x()
Definition TVector2.ipp:38
T & y()
Definition TVector2.ipp:44
Math functions and utilities.
Definition TransformInfo.h:10