Skip to content

Commit

Permalink
BUG: SetIdentity must retain FixedParameters
Browse files Browse the repository at this point in the history
When setting a transform to represent an Identity
mapping, it is crucial that the stationary component
of the transform is preserved.

```python
tfm.SetCenter( [1,2,3] );
tfm.SetIdentity();
out=tfm.GetCenter();
assert( out == [1,2,3] );
```
  • Loading branch information
hjmjohnson committed Feb 28, 2024
1 parent 198cc19 commit 96270fb
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ template <typename TParametersValueType, unsigned int VInputDimension, unsigned
void
MatrixOffsetTransformBase<TParametersValueType, VInputDimension, VOutputDimension>::SetIdentity()
{
// Fixed parameters must be preserved when setting the transform to identity
const auto tmp_fixed_parameters = this->GetFixedParameters();
m_Matrix.SetIdentity();
m_MatrixMTime.Modified();
m_Offset.Fill(OutputVectorValueType{});
Expand All @@ -103,7 +105,7 @@ MatrixOffsetTransformBase<TParametersValueType, VInputDimension, VOutputDimensio
m_Singular = false;
m_InverseMatrix.SetIdentity();
m_InverseMatrixMTime = m_MatrixMTime;
this->Modified();
this->SetFixedParameters(tmp_fixed_parameters);
}


Expand Down

0 comments on commit 96270fb

Please sign in to comment.