@@ -149,58 +149,37 @@ static void ComputePoseSymmetricKernelCPU(const scalar_t *source_points_ptr,
149149#pragma omp parallel for reduction(+ : A_reduction[:29]) schedule(static) num_threads(utility::EstimateMaxThreads())
150150 for (int workload_idx = 0 ; workload_idx < n; ++workload_idx) {
151151#endif
152- if (correspondence_indices[workload_idx] == -1 ) continue ;
153- int target_idx = 3 * correspondence_indices[workload_idx];
154- int source_idx = 3 * workload_idx;
155-
156- scalar_t sx = source_points_ptr[source_idx];
157- scalar_t sy = source_points_ptr[source_idx + 1 ];
158- scalar_t sz = source_points_ptr[source_idx + 2 ];
159- scalar_t tx = target_points_ptr[target_idx];
160- scalar_t ty = target_points_ptr[target_idx + 1 ];
161- scalar_t tz = target_points_ptr[target_idx + 2 ];
162- scalar_t nsx = source_normals_ptr[source_idx];
163- scalar_t nsy = source_normals_ptr[source_idx + 1 ];
164- scalar_t nsz = source_normals_ptr[source_idx + 2 ];
165- scalar_t ntx = target_normals_ptr[target_idx];
166- scalar_t nty = target_normals_ptr[target_idx + 1 ];
167- scalar_t ntz = target_normals_ptr[target_idx + 2 ];
168-
169- scalar_t dx = sx - tx;
170- scalar_t dy = sy - ty;
171- scalar_t dz = sz - tz;
172-
173- scalar_t r1 = dx * ntx + dy * nty + dz * ntz;
174- scalar_t r2 = dx * nsx + dy * nsy + dz * nsz;
175-
176- scalar_t J1[6 ] = {-sz * nty + sy * ntz,
177- sz * ntx - sx * ntz,
178- -sy * ntx + sx * nty,
179- ntx,
180- nty,
181- ntz};
182- scalar_t J2[6 ] = {-sz * nsy + sy * nsz,
183- sz * nsx - sx * nsz,
184- -sy * nsx + sx * nsy,
185- nsx,
186- nsy,
187- nsz};
188-
189- scalar_t w1 = GetWeightFromRobustKernel (r1);
190- scalar_t w2 = GetWeightFromRobustKernel (r2);
191-
192- int i = 0 ;
193- for (int j = 0 ; j < 6 ; ++j) {
194- for (int k = 0 ; k <= j; ++k) {
195- A_reduction[i] +=
196- J1[j] * w1 * J1[k] + J2[j] * w2 * J2[k];
197- ++i;
152+ scalar_t J_ij[12 ] = {0 };
153+ scalar_t r1 = 0 , r2 = 0 ;
154+ const bool valid = GetJacobianSymmetric<scalar_t >(
155+ workload_idx, source_points_ptr, target_points_ptr,
156+ source_normals_ptr, target_normals_ptr,
157+ correspondence_indices, J_ij, r1, r2);
158+
159+ if (valid) {
160+ const scalar_t w1 = GetWeightFromRobustKernel (r1);
161+ const scalar_t w2 = GetWeightFromRobustKernel (r2);
162+
163+ // Accumulate JtJ and Jtr for both terms
164+ int i = 0 ;
165+ for (int j = 0 ; j < 6 ; ++j) {
166+ for (int k = 0 ; k <= j; ++k) {
167+ // Contribution from first term (source to
168+ // target)
169+ A_reduction[i] += J_ij[j] * w1 * J_ij[k];
170+ // Contribution from second term (target to
171+ // source)
172+ A_reduction[i] +=
173+ J_ij[j + 6 ] * w2 * J_ij[k + 6 ];
174+ ++i;
175+ }
176+ // Jtr contributions
177+ A_reduction[21 + j] +=
178+ J_ij[j] * w1 * r1 + J_ij[j + 6 ] * w2 * r2;
198179 }
199- A_reduction[21 + j] +=
200- J1[j] * w1 * r1 + J2[j] * w2 * r2 ;
180+ A_reduction[27 ] += r1 * r1 + r2 * r2;
181+ A_reduction[ 28 ] += 1 ;
201182 }
202- A_reduction[27 ] += r1 * r1 + r2 * r2;
203- A_reduction[28 ] += 1 ;
204183 }
205184#ifdef _WIN32
206185 return A_reduction;
0 commit comments