Skip to content

Commit

Permalink
BUG: VersorTransform did not update offset in SetParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
zivy authored and N-Dekker committed Oct 10, 2021
1 parent f66267b commit fb64eb2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions Modules/Core/Transform/include/itkVersorTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ VersorTransform<TParametersValueType>::SetParameters(const ParametersType & para
itkDebugMacro(<< "Versor is now " << m_Versor);

this->ComputeMatrix();
this->ComputeOffset();

// Modified is always called since we just have a pointer to the
// parameters and cannot know if the parameters have changed.
Expand Down
29 changes: 29 additions & 0 deletions Modules/Core/Transform/test/itkVersorTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,35 @@ itkVersorTransformTest(int, char *[])
}
}

{
// Check that setting parameters updates the transformation offset
t = TransformType::New();

const TransformType::InputPointType center = itk::MakePoint(2, 4, 8);

// 90 degree rotation around x axis
ParametersType q(3);
q[0] = itk::Math::sqrt1_2;
q[1] = 0.0;
q[2] = 0.0;

t->SetCenter(center);
t->SetParameters(q);

const double expectedOffset[] = { 0.0, 12.0, 4.0 };

TransformType::OffsetType offset = t->GetOffset();
for (unsigned int k = 0; k < 3; ++k)
{
if (std::fabs(expectedOffset[k] - offset[k]) > epsilon)
{
std::cerr << " [ FAILED ] " << std::endl;
std::cerr << "Expected offset: " << expectedOffset << std::endl;
std::cerr << "but got: " << offset << std::endl;
return EXIT_FAILURE;
}
}
}
{
TransformType::Pointer tInverse = TransformType::New();
if (!t->GetInverse(tInverse))
Expand Down

0 comments on commit fb64eb2

Please sign in to comment.