I have a lattice plane in 3 dimensional space. Now, I want to cut it in a unit cell, but I have to write some code the make things get easier. As you can see from my figure, I can know the four coordinates of the highlighted atoms which form the boundaries of the top plane. My problem is if the four coordinates are known, how could I eliminate the atoms outside the boundary, or how could I know the limitations of the coordinates ##(x_i,y_i,z_i)## of atoms inside the boundary. My idea is to use their slopes between each pair of highlighted atoms. Any advices would be very appreciated!