Slider rotation appears incorrect - vtkSliderRepresentation3D

I have found vtkSliderRepresentation3D::BuildRepresentation to calculate an incorrect angle of rotation of the slider mesh in some cases. I have tried correcting this by replacing:

vtkMath::Normalize(v);
vtkMath::Cross(v,x,axis);
double theta, axisLen = vtkMath::Norm(axis);
if ( axisLen != 0.0 )
{
  theta = vtkMath::DegreesFromRadians( asin( axisLen ) );
}

With this:

vtkMath::Normalize(v);
vtkMath::Cross(v,x,axis);
double dotProd = vtkMath::Dot(v, x);
double theta, axisLen = vtkMath::Norm(axis);
if ( axisLen != 0.0 )
{
  theta = vtkMath::DegreesFromRadians(vtkMath::Pi() - atan2(axisLen, dotProd));
}

Basically a directional angle is found instead of the one found by asin, and that seems to work for my case. Haven’t tested this a lot yet, but seems to work for me right now. Hopefully a similar fix can be made to VTK as well :slight_smile:

1 Like