40 #include <visp3/core/vpMomentAlpha.h>
41 #include <visp3/core/vpMomentCentered.h>
42 #include <visp3/core/vpMomentGravityCenter.h>
53 : m_isRef(true), m_symmetric(false), m_mu3Ref(), m_alphaRef(0.), m_symmetricThreshold(1e-6)
70 :
vpMoment(), m_isRef(false), m_symmetric(true), m_mu3Ref(mu3_ref), m_alphaRef(alpha_ref),
71 m_symmetricThreshold(threshold)
73 for (std::vector<double>::const_iterator it = mu3_ref.begin(); it != mu3_ref.end(); ++it) {
74 if (std::fabs(*it) > m_symmetricThreshold) {
90 bool found_moment_centered;
95 if (!found_moment_centered)
98 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
100 std::vector<double> rotMu(4);
107 double r11 = cos(alpha - m_alphaRef);
108 double r12 = sin(alpha - m_alphaRef);
111 unsigned int idx = 0;
112 unsigned int order = 4;
113 for (
unsigned int c = 0; c < (order) * (order); c++) {
114 unsigned int i = c % order;
115 unsigned int j = c / order;
119 for (
unsigned int k = 0; k <= i; k++) {
120 double r12_i_k = pow(r12, (
int)(i - k));
121 double comb_i_k =
static_cast<double>(
vpMath::comb(i, k));
122 for (
unsigned int l = 0; l <= j; l++) {
123 rotMu[idx] +=
static_cast<double>(comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k *
124 pow(r22, (
int)(j - l)) *
125 momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
134 bool signChange =
false;
135 for (
unsigned int i = 0; i < 4; i++) {
136 if (std::fabs(rotMu[i]) > m_symmetricThreshold && std::fabs(m_mu3Ref[i]) > m_symmetricThreshold &&
137 rotMu[i] * m_mu3Ref[i] < 0) {
140 sum += std::fabs(rotMu[i] * m_mu3Ref[i]);
143 if (sum < std::numeric_limits<double>::epsilon()) {
165 os << (__FILE__) << std::endl;
166 bool found_moment_centered;
169 if (!found_moment_centered)
172 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
173 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
174 os <<
"mu02 = " << momentCentered.
get(0, 2) << std::endl;
182 #ifdef ENABLE_VISP_NAMESPACE
185 os << (__FILE__) << 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 std::string &moment_name, bool &found) const
This class defines shared methods/attributes for 2D moments.
std::vector< double > values
vpMomentDatabase & getMoments() const