38 #include <visp3/core/vpMomentAlpha.h>
39 #include <visp3/core/vpMomentGravityCenter.h>
40 #include <visp3/core/vpMomentCentered.h>
60 :
vpMoment(),isRef(false),symmetric(false),ref(ref_),alphaRef(alpha_ref)
62 for (std::vector<double>::iterator it = ref_.begin(); it!=ref_.end(); it++)
75 bool found_moment_centered;
78 found_moment_centered)));
80 if (!found_moment_centered)
83 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
85 unsigned int order = 4;
86 std::vector<double> rotMu(4);
87 std::vector<double> realMu(4);
97 double r11 = cos(alpha - alphaRef);
98 double r12 = sin(alpha - alphaRef);
99 double r21 = -sin(alpha - alphaRef);
100 double r22 = cos(alpha - alphaRef);
101 unsigned int idx = 0;
102 for (
register unsigned int c = 0; c < (order) * (order); c++)
104 unsigned int i = c % order;
105 unsigned int j = c / order;
110 for (
register unsigned int k = 0; k <= i; k++)
112 double r12_i_k = pow(r12, (
int)(i - k));
113 double comb_i_k =
static_cast<double> (
vpMath::comb(i, k));
114 for (
register unsigned int l = 0; l <= j; l++)
116 rotMu[idx] +=
static_cast<double> (comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k
117 * pow(r22, (
int)(j - l)) * momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
121 realMu[idx] = momentCentered.
get(i, j);
127 bool signChange =
true;
128 for (
register unsigned int i = 0; i < 4; i++)
130 if (std::abs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() && std::abs(ref[i]) > 1e10
131 * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0)
133 sum += std::abs(rotMu[i] * ref[i]);
136 if (sum < 1e4 * std::numeric_limits<double>::epsilon())
139 alpha = alpha + M_PI;
149 os << (__FILE__) << std::endl;
158 os << (__FILE__) << std::endl;
159 bool found_moment_centered;
161 found_moment_centered)));
162 if (!found_moment_centered)
165 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
166 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
167 os <<
"mu02 = " << momentCentered.
get(0, 2) << std::endl;
error that can be emited by ViSP classes.
This class defines shared methods/attributes for 2D moments.
const vpMoment & get(const char *type, bool &found) const
This class defines the double-indexed centered moment descriptor .
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
This class defines the orientation of the object inside the plane parallel to the object...
double get(unsigned int i, unsigned int j) const
vpMomentDatabase & getMoments() const
void printDependencies(std::ostream &os) const
static long double comb(unsigned int n, unsigned int p)
static double deg(double rad)
std::vector< double > values