<commit_before>/*=========================================================================
 *
 *  Copyright NumFOCUS
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         https://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef itkVersorRigid3DTransform_hxx
#define itkVersorRigid3DTransform_hxx


namespace itk
{
// Constructor with default arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform()
  : Superclass(ParametersDimension)
{}

// Constructor with arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform(unsigned int paramDim)
  : Superclass(paramDim)
{}

// Constructor with arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform(const MatrixType &       matrix,
                                                                     const OutputVectorType & offset)
  : Superclass(matrix, offset)
{}

// Set Parameters
template <typename TParametersValueType>
void
VersorRigid3DTransform<TParametersValueType>::SetParameters(const ParametersType & parameters)
{
  itkDebugMacro(<< "Setting parameters " << parameters);

  // Save parameters. Needed for proper operation of TransformUpdateParameters.
  if (&parameters != &(this->m_Parameters))
  {
    this->m_Parameters = parameters;
  }

  // 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;
  if (norm >= 1.0 - epsilon)
  {
    axis = axis / (norm + epsilon * norm);
  }
  VersorType newVersor;
  newVersor.Set(axis);<commit_msg>STYLE: Simplify local variable compuations<commit_after>/*=========================================================================
 *
 *  Copyright NumFOCUS
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         https://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef itkVersorRigid3DTransform_hxx
#define itkVersorRigid3DTransform_hxx


namespace itk
{
// Constructor with default arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform()
  : Superclass(ParametersDimension)
{}

// Constructor with arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform(unsigned int paramDim)
  : Superclass(paramDim)
{}

// Constructor with arguments
template <typename TParametersValueType>
VersorRigid3DTransform<TParametersValueType>::VersorRigid3DTransform(const MatrixType &       matrix,
                                                                     const OutputVectorType & offset)
  : Superclass(matrix, offset)
{}

// Set Parameters
template <typename TParametersValueType>
void
VersorRigid3DTransform<TParametersValueType>::SetParameters(const ParametersType & parameters)
{
  itkDebugMacro(<< "Setting parameters " << parameters);

  // Save parameters. Needed for proper operation of TransformUpdateParameters.
  if (&parameters != &(this->m_Parameters))
  {
    this->m_Parameters = parameters;
  }

  // Transfer the versor part

  AxisType axis;
  axis[0] = parameters[0];
  axis[1] = parameters[1];
  axis[2] = parameters[2];

  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);
  }
  VersorType newVersor;
  newVersor.Set(axis);
{'fraction_non_alphanumeric': 0.14882182720132286, 'fraction_numerical': 0.012608515915667631, 'mean_word_length': 4.294310722100657, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 26, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7247769', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1315, 'n_words': 374}