# Check if Polygon is flat on a Plane

On 28/06/2018 at 14:14, xxxxxxxx wrote:

I want to check if a Polygon is flat and 100% on a Plane that is defined by another Objects XY-Axis.
How can I do that? I am stuck here.

On 28/06/2018 at 23:01, xxxxxxxx wrote:

Not sure if this is the most technically and/or mathematically correct solution, but I would check each polygon's vertex normal (=cross product of the vertex with next and previous vertex). If all normals are equal then I would assume the polygon to be flat.
Additionally, when all these normals are equal to the Z axis (= cross product of X and Y axis) of your reference object, then I would assume the polygon AND flat AND 100% on the XY plane of that object.

On 29/06/2018 at 03:24, xxxxxxxx wrote:

Hi Holgar, thanks for writing us.

With regard to your question, and following C4DS hints, I recommend, given the four points arranged in such a fashion:
A---B
| \   |
|  \  |
D---C
and that to run the following steps:

1. check that the dot product between vectorAB and vectorZ is 0
2. check that the dot product between vectorBC and vectorZ is 0
3. check that the dot product between vectorAD and vectorZ is 0
4. check that the Z-value of point A matches the Z-value of your XY-aligned plane

Hope these few hints can help you to sort it out.

Cheers, Riccardo