93 double pcombkqcombl = 0.0;
99 double minus1pow = 0.;
102 for (
unsigned int k = 0; k <= p; ++k) {
103 int pmk =
static_cast<int>(p) -
static_cast<int>(k);
104 double pcombk =
static_cast<double>(
vpMath::comb(p, k));
105 for (
unsigned int l = 0; l <= q; ++l) {
106 qml =
static_cast<int>(q) -
static_cast<int>(l);
108 minus1pow = pow(-1.0,
static_cast<double>(pmk + qml));
109 pcombkqcombl = pcombk * qcombl;
111 pintom = pcombkqcombl * mkl;
114 term1 += pintom * pmk * pow(xg, pmk - 1) * pow(yg, qml) * minus1pow;
116 term2 += pintom * qml * pow(xg, pmk) * pow(yg, qml - 1) * minus1pow;
117 Lterm3 += pcombkqcombl * pow(xg, pmk) * pow(yg, qml) * L_mkl * minus1pow;
123 vpMatrix L_mupq = L_xg * term1 + L_yg * term2 + Lterm3;
141#ifdef VISP_MOMENTS_COMBINE_MATRICES
148 bool found_moment_gravity;
151 if (!found_moment_gravity)
153 double xg = momentGravity.
get()[0];
154 double yg = momentGravity.
get()[1];
156 bool found_feature_gravity_center;
159 if (!found_feature_gravity_center)
164 bool found_moment_basic;
167 if (!found_moment_basic)
170 bool found_featuremoment_basic;
173 if (!found_featuremoment_basic)
177 for (
int i = 0; i < static_cast<int>(
order) - 1; i++) {
178 for (
int j = 0; j < static_cast<int>(
order) - 1 - i; j++) {
180 compute_Lmu_pq(i, j, xg, yg, Lxg, Lyg, momentbasic, featureMomentBasic);
184 bool found_moment_centered;
185 bool found_moment_gravity;
192 if (!found_moment_centered)
194 if (!found_moment_gravity)
212 double n11 = momentCentered.
get(1, 1) / momentObject.
get(0, 0);
213 double n20 = momentCentered.
get(2, 0) / momentObject.
get(0, 0);
214 double n02 = momentCentered.
get(0, 2) / momentObject.
get(0, 0);
215 double Xg = momentGravity.
getXg();
216 double Yg = momentGravity.
getYg();
217 double mu00 = momentCentered.
get(0, 0);
239 for (
int i = 1; i < static_cast<int>(
order) - 1; i++) {
240 unsigned int i_ =
static_cast<unsigned int>(i);
241 unsigned int im1_ = i_ - 1;
242 unsigned int ip1_ = i_ + 1;
244 double mu_im10 = momentCentered.
get(im1_, 0);
245 double mu_ip10 = momentCentered.
get(ip1_, 0);
246 double mu_im11 = momentCentered.
get(im1_, 1);
247 double mu_i0 = momentCentered.
get(i_, 0);
248 double mu_i1 = momentCentered.
get(i_, 1);
254 (i + 3 * delta) * mu_i1 + (i + 3 * delta) * Yg * mu_i0 + i * Xg * mu_im11 - i * epsilon * n11 * mu_im10;
256 -(i + 3 * delta) * mu_ip10 - (2 * i + 3 * delta) * Xg * mu_i0 + i * epsilon * n20 * mu_im10;
262 for (
int j = 1; j < static_cast<int>(
order) - 1; j++) {
263 unsigned int j_ =
static_cast<unsigned int>(j);
264 unsigned int jm1_ = j_ - 1;
265 unsigned int jp1_ = j_ + 1;
267 double mu_0jm1 = momentCentered.
get(0, jm1_);
268 double mu_0jp1 = momentCentered.
get(0, jp1_);
269 double mu_1jm1 = momentCentered.
get(1, jm1_);
270 double mu_0j = momentCentered.
get(0, j_);
271 double mu_1j = momentCentered.
get(1, j_);
277 (j + 3 * delta) * mu_0jp1 + (2 * j + 3 * delta) * Yg * mu_0j - j * epsilon * n02 * mu_0jm1;
279 -(j + 3 * delta) * mu_1j - (j + 3 * delta) * Xg * mu_0j - j * Yg * mu_1jm1 + j * epsilon * n11 * mu_0jm1;
285 for (
int j = 1; j < static_cast<int>(
order) - 1; j++) {
286 unsigned int j_ =
static_cast<unsigned int>(j);
287 unsigned int jm1_ = j_ - 1;
288 unsigned int jp1_ = j_ + 1;
289 for (
int i = 1; i < static_cast<int>(
order) - j - 1; i++) {
290 unsigned int i_ =
static_cast<unsigned int>(i);
291 unsigned int im1_ = i_ - 1;
292 unsigned int ip1_ = i_ + 1;
294 double mu_ijm1 = momentCentered.
get(i_, jm1_);
295 double mu_ij = momentCentered.
get(i_, j_);
296 double mu_ijp1 = momentCentered.
get(i_, jp1_);
297 double mu_im1j = momentCentered.
get(im1_, j_);
298 double mu_im1jp1 = momentCentered.
get(im1_, jp1_);
299 double mu_ip1jm1 = momentCentered.
get(ip1_, jm1_);
300 double mu_ip1j = momentCentered.
get(ip1_, j_);
306 (i + 2 * j + 3 * delta) * Yg * mu_ij + i * Xg * mu_im1jp1 -
307 i * epsilon * n11 * mu_im1j - j * epsilon * n02 * mu_ijm1;
309 (2 * i + j + 3 * delta) * Xg * mu_ij - j * Yg * mu_ip1jm1 +
310 i * epsilon * n20 * mu_im1j + j * epsilon * n11 * mu_ijm1;
313 (i + j + 2 * delta) *
C * mu_ij;
vpMatrix compute_Lmu_pq(const unsigned int &p, const unsigned int &q, const double &xg, const double &yg, const vpMatrix &L_xg, const vpMatrix &L_yg, const vpMomentBasic &m, const vpFeatureMomentBasic &feature_moment_m) const