42#include <pcl/common/bivariate_polynomial.h>
54template<
typename real>
62template<
typename real>
64 degree(0), parameters(
NULL), gradient_x(
NULL), gradient_y(
NULL)
70template<
typename real>
77template<
typename real>
void
91 parameters =
new real[getNoOfParameters ()];
93 delete gradient_x; gradient_x =
nullptr;
94 delete gradient_y; gradient_y =
nullptr;
98template<
typename real>
void
101 delete[] parameters; parameters =
nullptr;
102 delete gradient_x; gradient_x =
nullptr;
103 delete gradient_y; gradient_y =
nullptr;
107template<
typename real>
void
110 if (
this == &
other)
return;
111 if (degree !=
other.degree)
114 degree =
other.degree;
115 parameters =
new real[getNoOfParameters ()];
117 if (!
other.gradient_x)
121 gradient_x =
nullptr;
122 gradient_y =
nullptr;
124 else if (!gradient_x)
130 std::copy_n(
other.parameters, getNoOfParameters (), parameters);
132 if (
other.gradient_x !=
nullptr)
134 gradient_x->deepCopy (*
other.gradient_x);
135 gradient_y->deepCopy (*
other.gradient_y);
140template<
typename real>
void
145 if (gradient_x ==
NULL)
147 if (gradient_y ==
NULL)
171template<
typename real>
real
192template<
typename real>
void
195 calculateGradient ();
196 gradX = gradient_x->getValue (x, y);
197 gradY = gradient_y->getValue (x, y);
201template<
typename real>
void
203 std::vector<int>&
types)
const
211 real x = (
real(2)*parameters[2]*parameters[3] - parameters[1]*parameters[4]) /
212 (parameters[1]*parameters[1] -
real(4)*parameters[0]*parameters[3]),
213 y = (
real(-2)*parameters[0]*x - parameters[2]) / parameters[1];
215 if (!std::isfinite(x) || !std::isfinite(y))
219 real det_H =
real(4)*parameters[0]*parameters[3] - parameters[1]*parameters[1];
223 if (parameters[0]+parameters[3] <
real(0))
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&
277template<
typename real>
void
280 os.write (
reinterpret_cast<const char*
> (°ree),
sizeof (
int));
281 unsigned int paramCnt = getNoOfParametersFromDegree (this->degree);
282 os.write (
reinterpret_cast<const char*
> (this->parameters),
paramCnt *
sizeof (
real));
286template<
typename real>
void
294template<
typename real>
void
298 os.read (
reinterpret_cast<char*
> (&this->degree),
sizeof (
int));
299 unsigned int paramCnt = getNoOfParametersFromDegree (this->degree);
301 os.read (
reinterpret_cast<char*
> (&(*this->parameters)),
paramCnt *
sizeof (
real));
305template<
typename real>
void
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
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...
void setDegree(int new_degree)
Initialize members to default values.
void getValueOfGradient(real x, real y, real &gradX, real &gradY)
Calculate the value of the gradient at the given point.
Iterator class for point clouds with or without given indices.
ConstCloudIterator(const PointCloud< PointT > &cloud)
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)