40 #include <visp3/core/vpMomentAlpha.h> 41 #include <visp3/core/vpMomentCentered.h> 42 #include <visp3/core/vpMomentGravityCenter.h> 65 :
vpMoment(), m_isRef(false), m_symmetric(true), m_mu3Ref(mu3_ref), m_alphaRef(alpha_ref), m_symmetricThreshold(threshold)
67 for (std::vector<double>::const_iterator it = mu3_ref.begin(); it != mu3_ref.end(); ++it) {
68 if (std::fabs(*it) > m_symmetricThreshold) {
84 bool found_moment_centered;
89 if (!found_moment_centered)
92 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
94 std::vector<double> rotMu(4);
100 double r11 = cos(alpha - m_alphaRef);
101 double r12 = sin(alpha - m_alphaRef);
104 unsigned int idx = 0;
105 unsigned int order = 4;
106 for (
unsigned int c = 0; c < (order) * (order); c++) {
107 unsigned int i = c % order;
108 unsigned int j = c / order;
112 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++) {
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)) *
118 momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
127 bool signChange =
false;
128 for (
unsigned int i = 0; i < 4; i++) {
129 if (std::fabs(rotMu[i]) > m_symmetricThreshold &&
130 std::fabs(m_mu3Ref[i]) > m_symmetricThreshold && rotMu[i] * m_mu3Ref[i] < 0) {
133 sum += std::fabs(rotMu[i] * m_mu3Ref[i]);
136 if (sum < std::numeric_limits<double>::epsilon()) {
158 os << (__FILE__) << std::endl;
168 os << (__FILE__) << std::endl;
169 bool found_moment_centered;
172 if (!found_moment_centered)
175 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
176 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
177 os <<
"mu02 = " << momentCentered.
get(0, 2) << std::endl;
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMomentAlpha &v)
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 .
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)
Used to indicate that a parameter is not initialized.
std::vector< double > values