Slider rotation appears incorrect - vtkSliderRepresentation3D

I have created a small test program that creates vtkSliderWidgets with the vtkSliderRepresentation3D. I create one slider per axis (not necessarily along the main coordinate system axes). Even though the three sliders have the same start point, one of the sliders seems to start offset from the start point and pointing slightly in the wrong direction.

sliderRep->SetPoint1InWorldCoordinates(0.0, 0.0, -6.0); // Note: All sliders have the same start point
sliderRep->SetPoint2InWorldCoordinates(x, y, z);

The (x,y,z) coordinates for the axes are the following where the x-axis looks rotated incorrectly:

(0.8060793615028174, -4.596267436520017, -6.0)
(-6.465520758172843, -1.1339033066529178, -6.0)
(0.0, 0.0, 0.0)

vtkSliderRepresentation3D seems to want to rotate some geometry aligned along the x-axis with the slider axis defined by point1 and point2. Could there be an issue with the rotation calculation?

Also note that I have tried using vtkLineWidget instead of vtkSliderWidget and that seems to render the axes correctly with the correct start point and end point.

Got any ideas?

Is the problem that sliders appear incorrectly or they don’t rotate objects as you expect? Can you post a screenshot?

Here is a screenshot of the sliders - one for each axis and you will see one which does not have the same start point as the others.

Here is my test with vtkLineWidget with the same coordinates - it appears to render as expected.

Not the same starting point is a minor issue compared to the text being distorted and mirrored. You would normally use these sliders in a 2D renderer layer that does not move/rotate with your 3D scene content.

My application does use sliders a part of a scene that can be rotated. Seems this could be a normal use case scenario? Currently used for moving slices inside a volume dataset.

The start point is incorrect, but so is probably the end point since the rotation used is probably not what it should be (guess maybe the middle point could be correct though :slight_smile: ) .

I do believe correctness should be important when it comes to positioning though also agree that text should be readable preferably from any rotation. Think the position issue could easily be fixed?

My application does use sliders a part of a scene that can be rotated. Seems this could be a normal use case scenario? Currently used for moving slices inside a volume dataset.

I recently implemented something very similar but I dont get the problem with the widgets orientation:

you can check out how it’s done here, here and here.

Would it be possible for you to test with the coordinates provided above and see if the sliders appear correct for you?

point1: (0.0, 0.0, -6.0)
point2:
(0.8060793615028174, -4.596267436520017, -6.0) -> this should appear incorrect
(-6.465520758172843, -1.1339033066529178, -6.0)
(0.0, 0.0, 0.0)

I have also pushed my test code to a repo if you would like to try there.

https://bitbucket.org/jornskaa/vtksliderwidget/

is it that maybe point1 and point2 are swapped wrt the linewidget case?

  sliderRep->SetPoint1InWorldCoordinates(x+0.5, y, z);
  sliderRep->SetPoint2InWorldCoordinates(0,0,0);
//...
  auto sliderWidgetX = createSliderWidget(30, renderWindowInteractor,  1, 0, 0);
  auto sliderWidgetY = createSliderWidget(30, renderWindowInteractor,  0, 1, 0);
  auto sliderWidgetZ = createSliderWidget(30, renderWindowInteractor,  0, 0, 1);

image

I have tried swapping the coordinates as well, but the situation is still the same/similar. Have you tried to use the coordinates I provided? Would be interesting if you can reproduce the situation. In your post you use the main coordinate axes which I think should work fine for me as well.