Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer std::isnan over != comparison trick #2977

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/point_cloud_editor/src/trackball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(1.0f);

origin_x_ = cur_x;
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/impl/3dsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pcl::ShapeContext3DEstimation<PointInT, PointNT, PointOutT>::computePoint (
assert (w >= 0.0);
if (w == std::numeric_limits<float>::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;
Expand Down
2 changes: 1 addition & 1 deletion features/include/pcl/features/impl/usc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pcl::UniqueShapeContext<PointInT, PointOutT, PointRFT>::computePointDescriptor (
assert (w >= 0.0);
if (w == std::numeric_limits<float>::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;
Expand Down
2 changes: 1 addition & 1 deletion people/include/pcl/people/impl/head_based_subcluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ template <typename PointT> void
pcl::people::HeadBasedSubclustering<PointT>::subcluster (std::vector<pcl::people::PersonCluster<PointT> >& 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;
Expand Down
2 changes: 1 addition & 1 deletion people/include/pcl/people/impl/height_map_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ template <typename PointT> void
pcl::people::HeightMap2D<PointT>::compute (pcl::people::PersonCluster<PointT>& 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;
Expand Down
6 changes: 3 additions & 3 deletions registration/include/pcl/registration/impl/ndt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::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<double> (input_->points.size ());
converged_ = delta_p_norm == delta_p_norm;
Expand Down Expand Up @@ -368,7 +368,7 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::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]
Expand Down Expand Up @@ -459,7 +459,7 @@ pcl::NormalDistributionsTransform<PointSource, PointTarget>::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]
Expand Down
2 changes: 1 addition & 1 deletion surface/include/pcl/surface/organized_fast_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down