Hi,all.I am struggling with this task,I will be very grateful if anyone can give me some possible advice.
This question is more about vtk.
I have a cube(volume) and the information is as follows:
image dimensions * image spacing = 30,30,40(mm)
So I want to adjust the camera to make sure the size of volume is 30(mm)x30(mm)x40(mm) and also I use the P-A orientation and show the ruler as follows:
So my goal is to make sure the rectangle is 30mm by 40 mm in this case.
I can get the camera
view = slicer.app.layoutManager().threeDWidget(0).threeDView()
renderWindow = view.renderWindow()
renderers = renderWindow.GetRenderers()
renderer = renderers.GetItemAsObject(0)
camera = renderer.GetActiveCamera()
Also,I have many parameters
angle = math.radians(camera.GetViewAngle())
point = camera.GetFocalPoint()
direction = camera.GetDirectionOfProjection()
scale = camera.GetParallelScale()
distance = scale / math.sin(.5 * angle)
I wonder if there is a way to calculate the width and height of the cube with above parameters and adjust the camera to make the size of the cube become the one I need.
Thank you in advance for your help!
Regards!