Skip to content

Commit

Permalink
STYLE: Simplify local variable compuations
Browse files Browse the repository at this point in the history
Provide simpler code to more closely match the mathematical description
of computations that are occuring.

Remove unnecessary "if" statement that is very rarely used,
and is never required for correct computation.
  • Loading branch information
hjmjohnson committed Oct 20, 2022
1 parent c5dafc7 commit 682ad7c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Modules/Core/Transform/include/itkVersorRigid3DTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,14 @@ VersorRigid3DTransform<TParametersValueType>::SetParameters(const ParametersType
// Transfer the versor part

AxisType axis;

double norm = parameters[0] * parameters[0];
axis[0] = parameters[0];
norm += parameters[1] * parameters[1];
axis[1] = parameters[1];
norm += parameters[2] * parameters[2];
axis[2] = parameters[2];
if (norm > 0)
{
norm = std::sqrt(norm);
}

double epsilon = 1e-10;
const double norm =
std::sqrt(parameters[0] * parameters[0] + parameters[1] * parameters[1] + parameters[2] * parameters[2]);

constexpr double epsilon = 1e-10;
if (norm >= 1.0 - epsilon)
{
axis = axis / (norm + epsilon * norm);
Expand Down

0 comments on commit 682ad7c

Please sign in to comment.