Skip to content

Commit

Permalink
STYLE: Remove std::pow calls from BoundingBox::ComputeCorners()
Browse files Browse the repository at this point in the history
The use of `std::bitset` is a bit clearer in this case, it may be slightly faster
than those `std::pow` calls, and it takes away the need to do static_cast's.
  • Loading branch information
N-Dekker authored and dzenanz committed Feb 26, 2025
1 parent 59d877d commit 5c8dbc1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkBoundingBox.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define itkBoundingBox_hxx

#include <algorithm> // For max.
#include <bitset>

namespace itk
{
Expand Down Expand Up @@ -94,12 +95,11 @@ BoundingBox<TPointIdentifier, VPointDimension, TCoordinate, TPointsContainer>::C

for (SizeValueType j = 0; j < NumberOfCorners; ++j)
{
PointType pnt;
const std::bitset<PointDimension> cornerBitset{ j };
PointType pnt;
for (unsigned int i = 0; i < PointDimension; ++i)
{
pnt[i] = center[i] +
std::pow(-1.0, (static_cast<double>(j / (static_cast<int>(std::pow(2.0, static_cast<double>(i))))))) *
radius[i];
pnt[i] = center[i] + (cornerBitset[i] ? -1 : 1) * radius[i];
}

result[j] = pnt;
Expand Down

0 comments on commit 5c8dbc1

Please sign in to comment.