Skip to content

Commit

Permalink
changed abs to std::fabs, also changed double numeric limit to float …
Browse files Browse the repository at this point in the history
…numeric limit
  • Loading branch information
gilpazintel committed Jan 7, 2025
1 parent 2308519 commit e2a18b2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4108,9 +4108,9 @@ NOEXCEPT_RETURN(, pixel)
/* Helper inner function (not part of the API) */
inline bool is_intrinsics_distortion_zero(const struct rs2_intrinsics* intrin)
{
return (abs(intrin->coeffs[0]) < std::numeric_limits<double>::epsilon() && abs(intrin->coeffs[1]) < std::numeric_limits<double>::epsilon() &&
abs(intrin->coeffs[2]) < std::numeric_limits<double>::epsilon() && abs(intrin->coeffs[3]) < std::numeric_limits<double>::epsilon() &&
abs(intrin->coeffs[4]) < std::numeric_limits<double>::epsilon());
return (std::fabs(intrin->coeffs[0]) < FLT_EPSILON && std::fabs(intrin->coeffs[1]) < FLT_EPSILON &&
std::fabs(intrin->coeffs[2]) < FLT_EPSILON && std::fabs(intrin->coeffs[3]) < FLT_EPSILON &&
std::fabs(intrin->coeffs[4]) < FLT_EPSILON);
}

void rs2_deproject_pixel_to_point(float point[3], const struct rs2_intrinsics* intrin, const float pixel[2], float depth) BEGIN_API_CALL
Expand Down Expand Up @@ -4171,7 +4171,7 @@ void rs2_deproject_pixel_to_point(float point[3], const struct rs2_intrinsics* i
for (int i = 0; i < 4; i++)
{
float f = theta * (1 + theta2 * (intrin->coeffs[0] + theta2 * (intrin->coeffs[1] + theta2 * (intrin->coeffs[2] + theta2 * intrin->coeffs[3])))) - rd;
if (fabs(f) < FLT_EPSILON)
if (std::fabs(f) < FLT_EPSILON)
{
break;
}
Expand All @@ -4190,7 +4190,7 @@ void rs2_deproject_pixel_to_point(float point[3], const struct rs2_intrinsics* i
{
rd = FLT_EPSILON;
}
float r = (fabs(intrin->coeffs[0]) < FLT_EPSILON) ? 0.0f : (float)(tan(intrin->coeffs[0] * rd) / atan(2 * tan(intrin->coeffs[0] / 2.0f)));
float r = (std::fabs(intrin->coeffs[0]) < FLT_EPSILON) ? 0.0f : (float)(tan(intrin->coeffs[0] * rd) / atan(2 * tan(intrin->coeffs[0] / 2.0f)));
x *= r / rd;
y *= r / rd;
}
Expand Down

0 comments on commit e2a18b2

Please sign in to comment.