Operating system: win 11
Slicer version:5.0.2
I need to calculate the local coordinates of a Line and a Plane, in a new coordinate system.
When I execute this code I can retrieve the coordinates in a world coordinate system. But I need the local coordinates of the L_1 (blue line) Line with respect to the yellow coordinate system. Thanks for the help.
import multiprocessing as mp
import numpy as np # import library
lineNodeNames = [“L_1”]
lineNode = slicer.util.getFirstNodeByClassByName(“vtkMRMLMarkupsLineNode”, lineNodeNames[0]) # Return the first node in the scene that matches the specified node class(“vtkMRMLMarkupsLineNode” in this case ) and node name(ech plane "lineNodeName " in the list lineNodeNames ) .
print(“lineNode:”, lineNode)
lineStartPos = np.zeros(3) # Return a new array of given shape and type, filled with “3” zeros and saves in lineStartPos
print(“lineStartPos:”, lineStartPos)
lineEndPos = np.zeros(3) # Return a new array of given shape and type, filled with “3” zeros and saves in lineEndPos
print(“lineEndPos:”, lineEndPos)
lineNode.GetNthControlPointPositionWorld(0, lineStartPos) # Get the position of the Nth control point in World coordinate system Returns 0 on failure, 1 on success.
print(“lineNode _ 0:”, lineStartPos)
lineNode.GetNthControlPointPositionWorld(1, lineEndPos) # Get the position of the Nth control point in World coordinate system Returns 0 on failure, 1 on success.
print(“lineNode _ 1:”, lineEndPos)