42#include <pcl/common/bivariate_polynomial.h>
54template<
typename real>
62template<
typename real>
70template<
typename real>
77template<
typename real>
void
98template<
typename real>
void
107template<
typename real>
void
110 if (
this == &other)
return;
140template<
typename real>
void
150 unsigned int parameterPosDx=0, parameterPosDy=0;
151 for (
int xDegree=
degree; xDegree>=0; xDegree--)
153 for (
int yDegree=
degree-xDegree; yDegree>=0; yDegree--)
171template<
typename real> real
175 real* tmpParameter = &
parameters[parametersSize-1];
176 real tmpX=1.0, tmpY, ret=0;
177 for (
int xDegree=0; xDegree<=
degree; xDegree++)
180 for (
int yDegree=0; yDegree<=
degree-xDegree; yDegree++)
182 ret += (*tmpParameter)*tmpX*tmpY;
192template<
typename real>
void
201template<
typename real>
void
203 std::vector<int>& types)
const
215 if (!std::isfinite(x) || !std::isfinite(y))
228 x_values.push_back(x);
229 y_values.push_back(y);
230 types.push_back(type);
234 std::cerr << __PRETTY_FUNCTION__ <<
" is not implemented for polynomials of degree "<<
degree<<
". Sorry.\n";
239template<
typename real> std::ostream&
244 real currentParameter;
245 for (
int xDegree=p.
degree; xDegree>=0; xDegree--)
247 for (
int yDegree=p.
degree-xDegree; yDegree>=0; yDegree--)
249 currentParameter = *tmpParameter;
252 os << (currentParameter<0.0?
" - ":
" + ");
253 currentParameter = std::abs (currentParameter);
255 os << currentParameter;
277template<
typename real>
void
280 os.write (
reinterpret_cast<const char*
> (&
degree),
sizeof (
int));
282 os.write (
reinterpret_cast<const char*
> (this->
parameters), paramCnt *
sizeof (real));
286template<
typename real>
void
289 std::ofstream fout (filename);
294template<
typename real>
void
298 os.read (
reinterpret_cast<char*
> (&this->
degree),
sizeof (
int));
301 os.read (
reinterpret_cast<char*
> (&(*this->
parameters)), paramCnt *
sizeof (real));
305template<
typename real>
void
308 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.
void readBinary(std::istream &os)
read binary from a stream
void writeBinary(std::ostream &os) const
write as binary to a stream
BivariatePolynomialT< real > * gradient_y
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)