42 #include <visp/vpMomentAlpha.h>
43 #include <visp/vpMomentGravityCenter.h>
44 #include <visp/vpMomentCentered.h>
64 :
vpMoment(),isRef(false),symmetric(false),ref(ref_),alphaRef(alpha_ref)
66 for (std::vector<double>::iterator it = ref_.begin(); it!=ref_.end(); it++)
79 bool found_moment_centered;
82 found_moment_centered)));
84 if (!found_moment_centered)
87 double alpha = 0.5 * atan2(2.0 * momentCentered.
get(1, 1), (momentCentered.
get(2, 0) - momentCentered.
get(0, 2)));
89 unsigned int order = 4;
90 std::vector<double> rotMu(4);
91 std::vector<double> realMu(4);
101 double r11 = cos(alpha - alphaRef);
102 double r12 = sin(alpha - alphaRef);
103 double r21 = -sin(alpha - alphaRef);
104 double r22 = cos(alpha - alphaRef);
105 unsigned int idx = 0;
106 for (
register unsigned int c = 0; c < (order) * (order); c++)
108 unsigned int i = c % order;
109 unsigned int j = c / order;
114 for (
register unsigned int k = 0; k <= i; k++)
116 double r12_i_k = pow(r12, (
int)(i - k));
117 double comb_i_k =
static_cast<double> (
vpMath::comb(i, k));
118 for (
register unsigned int l = 0; l <= j; l++)
120 rotMu[idx] +=
static_cast<double> (comb_i_k *
vpMath::comb(j, l) * r11_k * pow(r21, (
int)l) * r12_i_k
121 * pow(r22, (
int)(j - l)) * momentCentered.
get(k + l, (
unsigned int)(
int)(i + j - k - l)));
125 realMu[idx] = momentCentered.
get(i, j);
131 bool signChange =
true;
132 for (
register unsigned int i = 0; i < 4; i++)
134 if (std::abs(rotMu[i]) > 1e10 * std::numeric_limits<double>::epsilon() && std::abs(ref[i]) > 1e10
135 * std::numeric_limits<double>::epsilon() && rotMu[i] * ref[i] > 0)
137 sum += std::abs(rotMu[i] * ref[i]);
140 if (sum < 1e4 * std::numeric_limits<double>::epsilon())
143 alpha = alpha + M_PI;
152 VISP_EXPORT std::ostream & operator<<(std::ostream & os,
const vpMomentAlpha& c){
vpMomentDatabase & getMoments()
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
static long double comb(unsigned int n, unsigned int p)
std::vector< double > values