38#include <visp3/core/vpMomentAlpha.h>
39#include <visp3/core/vpMomentCentered.h>
40#include <visp3/core/vpMomentGravityCenter.h>
51 : m_isRef(true), m_symmetric(false), m_mu3Ref(), m_alphaRef(0.), m_symmetricThreshold(1e-6)
68 :
vpMoment(), m_isRef(false), m_symmetric(true), m_mu3Ref(mu3_ref), m_alphaRef(alpha_ref),
69 m_symmetricThreshold(threshold)
71 for (std::vector<double>::const_iterator it = mu3_ref.begin(); it != mu3_ref.end(); ++it) {
72 if (std::fabs(*it) > m_symmetricThreshold) {
88 bool found_moment_centered;
93 if (!found_moment_centered)
96 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
98 std::vector<double> rotMu(4);
105 double r11 = cos(alpha - m_alphaRef);
106 double r12 = sin(alpha - m_alphaRef);
109 unsigned int idx = 0;
110 unsigned int order = 4;
111 for (
unsigned int c = 0; c < (order) * (order); c++) {
112 unsigned int i = c % order;
113 unsigned int j = c / order;
117 for (
unsigned int k = 0; k <= i; k++) {
118 double r12_i_k = pow(r12,
static_cast<int>(i - k));
119 double comb_i_k =
static_cast<double>(
vpMath::comb(i, k));
120 for (
unsigned int l = 0; l <= j; l++) {
121 rotMu[idx] +=
static_cast<double>(comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21,
static_cast<int>(l)) * r12_i_k *
122 pow(r22,
static_cast<int>(j - l)) *
123 momentCentered.
get(k + l,
static_cast<unsigned int>(
static_cast<int>(i + j - k - l))));
132 bool signChange =
false;
133 for (
unsigned int i = 0; i < 4; i++) {
134 if (std::fabs(rotMu[i]) > m_symmetricThreshold && std::fabs(m_mu3Ref[i]) > m_symmetricThreshold &&
135 rotMu[i] * m_mu3Ref[i] < 0) {
138 sum += std::fabs(rotMu[i] * m_mu3Ref[i]);
141 if (sum < std::numeric_limits<double>::epsilon()) {
163 os << (__FILE__) << std::endl;
164 bool found_moment_centered;
167 if (!found_moment_centered)
170 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
171 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
172 os <<
"mu02 = " << momentCentered.
get(0, 2) << std::endl;
180#ifdef ENABLE_VISP_NAMESPACE
183 os << (__FILE__) << std::endl;
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)
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMomentAlpha &v)
void compute() VP_OVERRIDE
void printDependencies(std::ostream &os) const VP_OVERRIDE
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
std::vector< double > values
vpMomentDatabase & getMoments() const
vpMoment(const vpMoment &)=delete