42#include <pcl/common/bivariate_polynomial.h>
54template<
typename real>
61template<
typename real>
68template<
typename real>
75template<
typename real>
void
96template<
typename real>
void
105template<
typename real>
void
108 if (
this == &other)
return;
138template<
typename real>
void
141 if (
gradient_x!=
nullptr && !forceRecalc)
return;
148 unsigned int parameterPosDx=0, parameterPosDy=0;
149 for (
int xDegree=
degree; xDegree>=0; xDegree--)
151 for (
int yDegree=
degree-xDegree; yDegree>=0; yDegree--)
169template<
typename real> real
173 real* tmpParameter = &
parameters[parametersSize-1];
174 real tmpX=1.0, tmpY, ret=0;
175 for (
int xDegree=0; xDegree<=
degree; xDegree++)
178 for (
int yDegree=0; yDegree<=
degree-xDegree; yDegree++)
180 ret += (*tmpParameter)*tmpX*tmpY;
190template<
typename real>
void
199template<
typename real>
void
201 std::vector<int>& types)
const
213 if (!std::isfinite(x) || !std::isfinite(y))
219 if (det_H >
static_cast<real
>(0))
226 x_values.push_back(x);
227 y_values.push_back(y);
228 types.push_back(type);
232 std::cerr << __PRETTY_FUNCTION__ <<
" is not implemented for polynomials of degree "<<
degree<<
". Sorry.\n";
237template<
typename real> std::ostream&
242 real currentParameter;
243 for (
int xDegree=p.
degree; xDegree>=0; xDegree--)
245 for (
int yDegree=p.
degree-xDegree; yDegree>=0; yDegree--)
247 currentParameter = *tmpParameter;
250 os << (currentParameter<0.0?
" - ":
" + ");
251 currentParameter = std::abs (currentParameter);
253 os << currentParameter;
275template<
typename real>
void
278 os.write (
reinterpret_cast<const char*
> (&
degree),
sizeof (
int));
280 os.write (
reinterpret_cast<const char*
> (this->
parameters), paramCnt *
sizeof (real));
284template<
typename real>
void
287 std::ofstream fout (filename);
292template<
typename real>
void
296 os.read (
reinterpret_cast<char*
> (&this->
degree),
sizeof (
int));
299 os.read (
reinterpret_cast<char*
> (&(*this->
parameters)), paramCnt *
sizeof (real));
303template<
typename real>
void
306 std::ifstream fin (filename);
This represents a bivariate polynomial and provides some functionality for it.
~BivariatePolynomialT()
Destructor.
void deepCopy(const BivariatePolynomialT< real > &other)
Create a deep copy of the given polynomial.
void findCriticalPoints(std::vector< real > &x_values, std::vector< real > &y_values, std::vector< int > &types) const
Returns critical points of the polynomial.
BivariatePolynomialT(int new_degree=0)
Constructor.
void memoryCleanUp()
Delete all members.
BivariatePolynomialT< real > * gradient_y
void readBinary(std::istream &os)
read binary from a stream
void writeBinary(std::ostream &os) const
write as binary to a stream
real getValue(real x, real y) const
Calculate the value of the polynomial at the given point.
void calculateGradient(bool forceRecalc=false)
Calculate the gradient of this polynomial If forceRecalc is false, it will do nothing when the gradie...
unsigned int getNoOfParameters() const
How many parameters has a bivariate polynomial with this degree.
void setDegree(int new_degree)
Initialize members to default values.
static unsigned int getNoOfParametersFromDegree(int n)
How many parameters has a bivariate polynomial of the given degree.
BivariatePolynomialT< real > * gradient_x
void getValueOfGradient(real x, real y, real &gradX, real &gradY)
Calculate the value of the gradient at the given point.
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)