Skip to content

fix: vtkTransformInterpolator returns wrong answers

Josef Kohout requested to merge besoft/vtk:vtkTransformInterpolator_Fixes into master

If only one vtkTransform object is passed to vtkTransformInterpolator (for time t), vtkTransformInterpolator::Interpolate() fails to return the same transformation even for the same time, instead of returning the same transformation as one would expect from an interpolator. Furthermore, an error is raised because by default, vtkKochanekSpline is used, which requires at least two values.

Even with multiple vtkTransform objects passed, the result of the interpolation is incorrect due to two tiny bugs in vtkQuaternionInterpolator::InterpolateQuaternion:

  1. if the time == last time, the first quaternion is returned instead of the last one
  2. the interpolated quaternion is normalized at the end and the angle surprisingly converted from radians to degrees (which is inconsistent with the special cases (t = tmin or t = tmax) that return the input quaternions, where the angle is in radians). As vtkTransformInterpolator::Interpolate() expects that the angle is in radians, it converts the returned angle once again to degrees, which causes errors.

This merge request contains the changes that address the issues described above. The "same" transformation is now returned at the times for which the transformation was given at the beginning (the differences are caused by round-off errors and are negligible). The method vtkQuaternionInterpolator::InterpolateQuaternion is not used from any other VTK source file, so the change should be OK.

Merge request reports