38 #include <visp3/core/vpMomentAlpha.h>
39 #include <visp3/core/vpMomentGravityCenter.h>
40 #include <visp3/core/vpMomentCentered.h>
59 :
vpMoment(),isRef(false),symmetric(false),ref(ref_),alphaRef(alpha_ref)
61 for (std::vector<double>::iterator it = ref_.begin(); it!=ref_.end(); ++it)
62 if (std::fabs(*it)<=1e-4)
74 bool found_moment_centered;
77 found_moment_centered)));
79 if (!found_moment_centered)
82 double t = 2.0 * momentCentered.
get(1, 1) / (momentCentered.
get(2, 0) - momentCentered.
get(0, 2));
84 double alpha = 0.5 * atan(t);
86 std::vector<double> rotMu(4);
97 double r11 = cos(alpha - alphaRef);
98 double r12 = sin(alpha - alphaRef);
101 unsigned int idx = 0;
102 unsigned int order = 4;
103 for (
unsigned int c = 0; c < (order) * (order); c++)
105 unsigned int i = c % order;
106 unsigned int j = c / order;
111 for (
unsigned int k = 0; k <= i; k++)
113 double r12_i_k = pow(r12, (
int)(i - k));
114 double comb_i_k =
static_cast<double> (
vpMath::comb(i, k));
115 for (
unsigned int l = 0; l <= j; l++)
117 rotMu[idx] +=
static_cast<double> (comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k
118 * pow(r22, (
int)(j - l)) * momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
128 bool signChange =
true;
129 for (
unsigned int i = 0; i < 4; i++)
131 if (std::fabs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() && std::fabs(ref[i]) > 1e10
132 * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0)
134 sum += std::fabs(rotMu[i] * ref[i]);
137 if (sum < 1e4 * std::numeric_limits<double>::epsilon())
155 os << (__FILE__) << std::endl;
164 os << (__FILE__) << std::endl;
165 bool found_moment_centered;
167 found_moment_centered)));
168 if (!found_moment_centered)
171 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
172 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
173 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