40 #include <visp3/core/vpMomentAlpha.h>
41 #include <visp3/core/vpMomentCentered.h>
42 #include <visp3/core/vpMomentGravityCenter.h>
52 : m_isRef(true), m_symmetric(false), m_mu3Ref(), m_alphaRef(0.), m_symmetricThreshold(1e-6)
69 :
vpMoment(), m_isRef(false), m_symmetric(true), m_mu3Ref(mu3_ref), m_alphaRef(alpha_ref),
70 m_symmetricThreshold(threshold)
72 for (std::vector<double>::const_iterator it = mu3_ref.begin(); it != mu3_ref.end(); ++it) {
73 if (std::fabs(*it) > m_symmetricThreshold) {
89 bool found_moment_centered;
94 if (!found_moment_centered)
97 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
99 std::vector<double> rotMu(4);
105 double r11 = cos(alpha - m_alphaRef);
106 double r12 = sin(alpha - m_alphaRef);
109 unsigned int idx = 0;
110 unsigned int order = 4;
111 for (
unsigned int c = 0; c < (order) * (order); c++) {
112 unsigned int i = c % order;
113 unsigned int j = c / order;
117 for (
unsigned int k = 0; k <= i; k++) {
118 double r12_i_k = pow(r12, (
int)(i - k));
119 double comb_i_k =
static_cast<double>(
vpMath::comb(i, k));
120 for (
unsigned int l = 0; l <= j; l++) {
121 rotMu[idx] +=
static_cast<double>(comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k *
122 pow(r22, (
int)(j - l)) *
123 momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
132 bool signChange =
false;
133 for (
unsigned int i = 0; i < 4; i++) {
134 if (std::fabs(rotMu[i]) > m_symmetricThreshold && std::fabs(m_mu3Ref[i]) > m_symmetricThreshold &&
135 rotMu[i] * m_mu3Ref[i] < 0) {
138 sum += std::fabs(rotMu[i] * m_mu3Ref[i]);
141 if (sum < std::numeric_limits<double>::epsilon()) {
162 os << (__FILE__) << std::endl;
172 os << (__FILE__) << std::endl;
173 bool found_moment_centered;
176 if (!found_moment_centered)
179 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
180 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
181 os <<
"mu02 = " << momentCentered.
get(0, 2) << std::endl;
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
error that can be emitted by ViSP classes.
@ notInitialized
Used to indicate that a parameter is not initialized.
static long double comb(unsigned int n, unsigned int p)
static double deg(double rad)
This class defines the orientation of the object inside the plane parallel to the object.
void printDependencies(std::ostream &os) const
This class defines the double-indexed centered moment descriptor .
double get(unsigned int i, unsigned int j) const
const vpMoment & get(const char *type, bool &found) const
This class defines shared methods/attributes for 2D moments.
std::vector< double > values
vpMomentDatabase & getMoments() const