Create new line: Fiducial marker to Plane

Operating system:Windows 10/ 64
Slicer version:4.11.20200930
Expected behavior:Unk
Actual behavior: Is there a way for a line to be projected from a point to a plane at a designated angle? For example on a skull, a plane bisecting the skull along the midline and placing a fiducial maker at the external auditory meatus, a line to be drawn from the fiducial marker at 90 degrees to the plane. Ideally, the newly drawn line would have an output of a linear measure.

You can look up a formula on the web and adapt it to Slicer by getting inputs from markups and setting results in markups.

For example, a complete working implementation that takes a markups plane P and a markups line L as input, it takes the first control point of the line and sets its second control point to the projected position on the plane.

plane = getNode('P')
line = getNode('L')

point = np.zeros(3)
planeOrigin = np.zeros(3)
planeNormal = np.zeros(3)
plane.GetOriginWorld(planeOrigin)
plane.GetNormalWorld(planeNormal)
line.GetNthControlPointPositionWorld(0, point)
distanceFromPlane = np.dot(np.subtract(point, planeOrigin), planeNormal)
line.SetNthControlPointPositionWorld(1, *(point-planeNormal*distanceFromPlane))

image

You can add an observer to the plane and line and make the line’s endpoint update automatically if the line’s starting point or the plane is adjusted (see this example).

I will try this. Thank you!