In my opinion, i will sovle it in two ways. The first one is to iterate all points in 3D array and judge if the points is in the plane constructed by given 3 points, the second one is to use region-growth and line-segment affine to do that. However, both above are clumsy. Is there more efficient method? Better in package or library! Thanks!
Asked
Active
Viewed 74 times
-1
-
In general, very few points of a 3D grid fall exactly on a plane defined by three points (if you allow irrational points, in fact the plane will miss *all grid nodes*. – May 27 '22 at 06:49
-
1. If this is just PCL then you hjave to go through all point `p` which is `O(n)` and use perpendicular distance to plane like `fabs(dot(p-p0,normal))<=1e-6` where `p0` is any point on plane and `normal` is unit normal vector to plane. (the matrix version from the answer here is slower and overkill even if it in the end does the same). 2. If this is mesh and 3D then you have to iterate through all faces and test for intersection leading to 0,1,2...,n points from n-point face. – Spektre May 27 '22 at 08:16
-
If you want something better and preserve topology use 3D simplex (tetrahedronization) instead of triangulation of mesh covering volume instead of just surface. That would lead to correct 2D polygon result. See similar 4D QAs: [Calculate 3D cross section of 4D shape](https://stackoverflow.com/a/50016144/2521214) and [how should i handle (morphing) 4D objects in opengl?](https://stackoverflow.com/a/44970550/2521214) If you want just to render this fast use shaders See [How to Render Cross Section without Slicing the Mesh Geometry?](https://stackoverflow.com/a/42997147/2521214) – Spektre May 27 '22 at 08:23
-
My case is excuted on 3D mesh, could you please describe it in detail? What the "face" means? Could you provide some fake code? Very thanks! – 乔晓飞 May 30 '22 at 06:31
-
1. to notify someone you should add `@nick` to the comment and site will do the rest. 2. face in mesh is the polygonal planar primitive from which the mesh is consisted (triangle, quad, ...) you can find some example code and description in the links from my previous comment (its 4D but that does not matter much) 3. you should add more details as what is the wanted behavior so the mesh behave like a volume or just surface, wanted result is polygon without loss of precision or just rasterized image? Both of these information greatly impacts "ideal" solution – Spektre May 30 '22 at 06:58
-
Also the BR (boundary representation) mesh is triangulated or use different primitive or combines more primitives ? sample input or at least its image would be a good idea to share also how do you want to handle the inside after cutting? if a surface only mesh the result will be just few thin lines, and if volume it would be "single" polygon there are ways on enhancing that like using hatching, thick lines, or even technical standard projection like used in blue prints (but that si no longer cross section) image of wanted output would be also good idea – Spektre May 30 '22 at 07:03
-
However `[medical-imaging]` implies 3D Voxel image instead of mesh that is entirely different approach as mesh and instead of projection you can use ray casting like [SSS](https://stackoverflow.com/a/33581643/2521214) or just [Voxel Blending](https://stackoverflow.com/a/71635427/2521214) if just cross section then simple linear interpolation might do ... so please add needed info to your question and notify me by a comment without it I am afraid the reopen cycle will fail ... not even I will vote for reopen as Your question is too vague even inconsistent with what you really ask at this point – Spektre May 30 '22 at 07:08
-
@Spektre Actually, I am doing something about Medical Imaging process. The requirement is to extract any cross section of CT volume at any point on the skin and from any view. I have tried the vtk func named vtkImageReslice, but there is something wrong with that. Did you have used vtkImageReslice to carry out? – 乔晓飞 May 31 '22 at 05:15
-
I do not use VTK at all instead I have my own renderers based on VCL/GDI OpenGL and even SW for non GPU platforms. You still did not clear if your input is VOXELs PCL or mesh or their combination CT implies regular VOXEL 3D grid... also if you want just cross section and how to deal with inside or you need to see also the stuff before/after the cutting plane in some form ... – Spektre May 31 '22 at 06:07
1 Answers
1
If you want all the points on the plane constructed by given 3 points (v1, v2, v3) you can create a coordinate system with 3 axis:
x = (v2 - v1)
y = (v3 - v1)
z = x ^ y // cross product, gives a vector perpendicular to the two
From that you can construct the 3x3 matrix for the coordinate transformation into that coordinate system and then filter all points where (p * m).z == 0
. Or more likely abs(p * m) < epsilon
because close enough counts for more than horseshoes and handgranates.

Goswin von Brederlow
- 11,875
- 2
- 24
- 42
-
matrix is overkill you can do the same with plane normal and point like `fabs(dot(p-p0,normal))<=1e-6` from math aspect it does the same as yours however from performance aspect matrix multiplication is way slower as its 3 or 4 times `dot` instead of single one – Spektre May 27 '22 at 08:25
-
I assume the `x` and `y` coordinates in the plane will be needed as well. Note: normalize x and y at the start and then compute y' as `x ^ z` to get all vectors perpendicular. – Goswin von Brederlow May 27 '22 at 12:55
-
for PCL the point either is or is not in the plane so `x,y,z` will not change ... for meshes and polygons the `dot` result will also give parameter for parametric line equation which is also less operations than matrix transform ... Your case (from performance aspect) would be a good approach if (s)he want to transform the cooridnates into some local plane but that is not mentioned anywhere. – Spektre May 27 '22 at 18:35