vtkTransformPolyDataFilter? I don’t quite understand? I want to project an object (the yellow in the picture above👆🏻) to a specific plane (in green) instead of transform an object (in red) to a location.
@ lassoon. Do you mean that the projection task can be simply achieved using vtkTransformPolyDataFilter?
Projection to plane is a linear transform that can be described by a 4x4 homogenous matrix. You can construct it by concatenating 3 trivial transforms:
Transforms the point coordinates from world coordinate system into the plane’s coordinate system (it is the inverse of the third transform)
Apply projection transform (diag(1, 1, 0, 1))
Transforms the point coordinates from the plane’s coordinate system to the world’s coordinate system (it is very easy to construct this transform: the first 3 columns of the transformation matrix are the 3 plane axes, the fourth column is the plane position; the bottom row is [0, 0, 0, 1])
The entire implementation is just few ten lines of Python code, see for example here.
vtkProjectPointsToPlane was added relatively recently, so I did not have a chance to try it and also did not feel the need to use it because the more general vtkTransformPolyDataFilter was fast enough for me.
vtkProjectPointsToPlane is optimized for a single purpose and so it is (supposed to be) simpler to use and should be more efficient. So, even though its scope is very narrow it deserves to exist. Maybe it could be in a VTK remote module to keep VTK core leaner.