40 #include <visp3/core/vpMomentAlpha.h> 41 #include <visp3/core/vpMomentCentered.h> 42 #include <visp3/core/vpMomentGravityCenter.h> 61 :
vpMoment(), isRef(false), symmetric(false), ref(ref_), alphaRef(alpha_ref)
63 for (std::vector<double>::const_iterator it = ref_.begin(); it != ref_.end(); ++it)
64 if (std::fabs(*it) <= 1e-4)
77 bool found_moment_centered;
82 if (!found_moment_centered)
85 double t = 2.0 * momentCentered.
get(1, 1) / (momentCentered.
get(2, 0) - momentCentered.
get(0, 2));
88 double alpha = 0.5 * atan(t);
90 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++) {
104 unsigned int i = c % order;
105 unsigned int j = c / order;
109 for (
unsigned int k = 0; k <= i; k++) {
110 double r12_i_k = pow(r12, (
int)(i - k));
111 double comb_i_k =
static_cast<double>(
vpMath::comb(i, k));
112 for (
unsigned int l = 0; l <= j; l++) {
113 rotMu[idx] +=
static_cast<double>(comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k *
114 pow(r22, (
int)(j - l)) *
115 momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
125 bool signChange =
true;
126 for (
unsigned int i = 0; i < 4; i++) {
127 if (std::fabs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() &&
128 std::fabs(ref[i]) > 1e10 * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0)
130 sum += std::fabs(rotMu[i] * ref[i]);
133 if (sum < 1e4 * std::numeric_limits<double>::epsilon())
152 os << (__FILE__) << std::endl;
162 os << (__FILE__) << std::endl;
163 bool found_moment_centered;
166 if (!found_moment_centered)
169 os <<
"mu11 = " << momentCentered.
get(1, 1) <<
"\t";
170 os <<
"mu20 = " << momentCentered.
get(2, 0) <<
"\t";
171 os <<
"mu02 = " << momentCentered.
get(0, 2) << std::endl;
double get(unsigned int i, unsigned int j) const
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMomentAlpha &v)
const vpMoment & get(const char *type, bool &found) const
void printDependencies(std::ostream &os) const
error that can be emited by ViSP classes.
This class defines shared methods/attributes for 2D moments.
This class defines the double-indexed centered moment descriptor .
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)
static double deg(double rad)
vpMomentDatabase & getMoments() const
std::vector< double > values