Hi @siaeleni -
You’ll find the formulas for this in computer graphics textbooks and presentations (this one for example looks right). The basic idea is to make a vtkMatrix4x4 for a linear transform node that is the concatenation of several operations. First translates one point of the line to the origin, then rotate the line to so it is on one of the main axes, then rotate around that axis and then apply the inverse rotations and translation. This should just be a series of matrix multiplies.
-Steve