From 85e5c6341ced12a690d0be634c14005689576bb5 Mon Sep 17 00:00:00 2001 From: Sergey Alexandrov Date: Sun, 7 Apr 2019 17:19:47 +0200 Subject: [PATCH] Use std::isnan instead of != comparison trick --- apps/point_cloud_editor/src/trackball.cpp | 2 +- features/include/pcl/features/impl/3dsc.hpp | 2 +- features/include/pcl/features/impl/usc.hpp | 2 +- people/include/pcl/people/impl/head_based_subcluster.hpp | 2 +- people/include/pcl/people/impl/height_map_2d.hpp | 2 +- registration/include/pcl/registration/impl/ndt.hpp | 6 +++--- surface/include/pcl/surface/organized_fast_mesh.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/point_cloud_editor/src/trackball.cpp b/apps/point_cloud_editor/src/trackball.cpp index 5c9fc852dcb..2102fcc5b67 100644 --- a/apps/point_cloud_editor/src/trackball.cpp +++ b/apps/point_cloud_editor/src/trackball.cpp @@ -165,7 +165,7 @@ TrackBall::update(int s_x, int s_y) normalize(cross_x, cross_y, cross_z, nc_x, nc_y, nc_z); quat_ = quaternionFromAngleAxis(angle, nc_x, nc_y, nc_z); - if (quat_.R_component_1() != quat_.R_component_1()) + if (std::isnan(quat_.R_component_1())) quat_ = boost::math::quaternion(1.0f); origin_x_ = cur_x; diff --git a/features/include/pcl/features/impl/3dsc.hpp b/features/include/pcl/features/impl/3dsc.hpp index 7ff9172539a..f5671394efa 100644 --- a/features/include/pcl/features/impl/3dsc.hpp +++ b/features/include/pcl/features/impl/3dsc.hpp @@ -261,7 +261,7 @@ pcl::ShapeContext3DEstimation::computePoint ( assert (w >= 0.0); if (w == std::numeric_limits::infinity ()) PCL_ERROR ("Shape Context Error INF!\n"); - if (w != w) + if (std::isnan(w)) PCL_ERROR ("Shape Context Error IND!\n"); /// Accumulate w into correspondent Bin(j,k,l) desc[(l*elevation_bins_*radius_bins_) + (k*radius_bins_) + j] += w; diff --git a/features/include/pcl/features/impl/usc.hpp b/features/include/pcl/features/impl/usc.hpp index b6557299a95..bd239548a33 100644 --- a/features/include/pcl/features/impl/usc.hpp +++ b/features/include/pcl/features/impl/usc.hpp @@ -233,7 +233,7 @@ pcl::UniqueShapeContext::computePointDescriptor ( assert (w >= 0.0); if (w == std::numeric_limits::infinity ()) PCL_ERROR ("Shape Context Error INF!\n"); - if (w != w) + if (std::isnan(w)) PCL_ERROR ("Shape Context Error IND!\n"); /// Accumulate w into correspondent Bin(j,k,l) desc[(l*elevation_bins_*radius_bins_) + (k*radius_bins_) + j] += w; diff --git a/people/include/pcl/people/impl/head_based_subcluster.hpp b/people/include/pcl/people/impl/head_based_subcluster.hpp index 6555243c170..0a7e1b349c7 100644 --- a/people/include/pcl/people/impl/head_based_subcluster.hpp +++ b/people/include/pcl/people/impl/head_based_subcluster.hpp @@ -255,7 +255,7 @@ template void pcl::people::HeadBasedSubclustering::subcluster (std::vector >& clusters) { // Check if all mandatory variables have been set: - if (sqrt_ground_coeffs_ != sqrt_ground_coeffs_) + if (std::isnan(sqrt_ground_coeffs_)) { PCL_ERROR ("[pcl::people::pcl::people::HeadBasedSubclustering::subcluster] Floor parameters have not been set or they are not valid!\n"); return; diff --git a/people/include/pcl/people/impl/height_map_2d.hpp b/people/include/pcl/people/impl/height_map_2d.hpp index 427b4951b3f..997c52b9c2c 100644 --- a/people/include/pcl/people/impl/height_map_2d.hpp +++ b/people/include/pcl/people/impl/height_map_2d.hpp @@ -59,7 +59,7 @@ template void pcl::people::HeightMap2D::compute (pcl::people::PersonCluster& cluster) { // Check if all mandatory variables have been set: - if (sqrt_ground_coeffs_ != sqrt_ground_coeffs_) + if (std::isnan(sqrt_ground_coeffs_)) { PCL_ERROR ("[pcl::people::HeightMap2D::compute] Floor parameters have not been set or they are not valid!\n"); return; diff --git a/registration/include/pcl/registration/impl/ndt.hpp b/registration/include/pcl/registration/impl/ndt.hpp index 7210c865933..b9cde24775a 100644 --- a/registration/include/pcl/registration/impl/ndt.hpp +++ b/registration/include/pcl/registration/impl/ndt.hpp @@ -132,7 +132,7 @@ pcl::NormalDistributionsTransform::computeTransformati //Calculate step length with guarnteed sufficient decrease [More, Thuente 1994] delta_p_norm = delta_p.norm (); - if (delta_p_norm == 0 || delta_p_norm != delta_p_norm) + if (delta_p_norm == 0 || std::isnan(delta_p_norm)) { trans_probability_ = score / static_cast (input_->points.size ()); converged_ = delta_p_norm == delta_p_norm; @@ -368,7 +368,7 @@ pcl::NormalDistributionsTransform::updateDerivatives ( e_x_cov_x = gauss_d2_ * e_x_cov_x; // Error checking for invalid values. - if (e_x_cov_x > 1 || e_x_cov_x < 0 || e_x_cov_x != e_x_cov_x) + if (e_x_cov_x > 1 || e_x_cov_x < 0 || std::isnan(e_x_cov_x)) return (0); // Reusable portion of Equation 6.12 and 6.13 [Magnusson 2009] @@ -459,7 +459,7 @@ pcl::NormalDistributionsTransform::updateHessian (Eige double e_x_cov_x = gauss_d2_ * exp (-gauss_d2_ * x_trans.dot (c_inv * x_trans) / 2); // Error checking for invalid values. - if (e_x_cov_x > 1 || e_x_cov_x < 0 || e_x_cov_x != e_x_cov_x) + if (e_x_cov_x > 1 || e_x_cov_x < 0 || std::isnan(e_x_cov_x)) return; // Reusable portion of Equation 6.12 and 6.13 [Magnusson 2009] diff --git a/surface/include/pcl/surface/organized_fast_mesh.h b/surface/include/pcl/surface/organized_fast_mesh.h index 1beeaba41bb..6411092d6ba 100644 --- a/surface/include/pcl/surface/organized_fast_mesh.h +++ b/surface/include/pcl/surface/organized_fast_mesh.h @@ -362,7 +362,7 @@ namespace pcl if (cos_angle_tolerance_ > 0) { float cos_angle = dir_a.dot (dir_b) / (distance_to_points*distance_between_points); - if (cos_angle != cos_angle) + if (std::isnan(cos_angle)) cos_angle = 1.0f; bool check_angle = fabs (cos_angle) >= cos_angle_tolerance_;