42 #include <visp/vpMomentAlpha.h>
43 #include <visp/vpMomentGravityCenter.h>
44 #include <visp/vpMomentCentered.h>
65 for (std::vector<double>::iterator it = ref.begin(); it!=ref.end(); it++)
78 bool found_moment_centered;
81 found_moment_centered)));
83 if (!found_moment_centered)
86 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
88 unsigned int order = 4;
89 std::vector<double> rotMu(4);
90 std::vector<double> realMu(4);
100 double r11 = cos(alpha - alphaRef);
101 double r12 = sin(alpha - alphaRef);
102 double r21 = -sin(alpha - alphaRef);
103 double r22 = cos(alpha - alphaRef);
104 unsigned int idx = 0;
105 for (
register unsigned int c = 0; c < (order) * (order); c++)
107 unsigned int i = c % order;
108 unsigned int j = c / order;
113 for (
register unsigned int k = 0; k <= i; k++)
115 double r12_i_k = pow(r12, (
int)(i - k));
116 double comb_i_k =
static_cast<double> (
vpMath::comb(i, k));
117 for (
register unsigned int l = 0; l <= j; l++)
119 rotMu[idx] +=
static_cast<double> (comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k
120 * pow(r22, (
int)(j - l)) * momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
124 realMu[idx] = momentCentered.
get(i, j);
130 bool signChange =
true;
131 for (
register unsigned int i = 0; i < 4; i++)
133 if (std::abs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() && std::abs(ref[i]) > 1e10
134 * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0)
136 sum += std::abs(rotMu[i] * ref[i]);
139 if (sum < 1e4 * std::numeric_limits<double>::epsilon())
142 alpha = alpha + M_PI;
vpMomentDatabase & getMoments()
double get(unsigned int i, unsigned int j)
error that can be emited by ViSP classes.
vpMoment & get(const char *type, bool &found)
This class defines shared methods/attributes for 2D moments.
This class defines the double-indexed centered moment descriptor .
VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpImagePoint &ip)
This class defines the orientation of the object inside the plane parallel to the object...
static long double comb(unsigned int n, unsigned int p)
std::vector< double > values