I have a 3D numpy array, e.g. of shape (200,200,200)
.
I also have a 2D plane, which I can express either in the form
ax + by + cz + d = 0
or a (x,y,z)
point and a direction vector in terms of the three x,y,z
axes.
I want to "plot" this plane on the 3D numpy array, by essentially changing the value of all points that lie on this plane to a constant value.
Like this, but with only a single colour:
The most versatile solution to this (I think) is to get all the integer indices of points that lie along this line. I can then just use this to index the numpy array. However, if a library offered the ability to plot a plane directly, without providing the indices, then this would be fine.
I have seen problems on this site that seem superficially similar to my problem, such as approaches of finding the values that lie along an x,y,z
vector using scipy.ndimage.map_coordinates
, but of course I am dealing with a plane not a line (also this just returned the values, not the indices).
Another approach I considered, but seems difficult (and maybe slow) is something similar to this question where the reply shows how to draw a 2D triangle in a 3D space. I could instead draw a square in 3D space, but this shows that filling this square is not trivial, and also the square will only fill the entire plane if at least one axis is parallel to x, y or z (or a "corner" will remain unfilled).
Has anyone got any idea how I might achieve this?