When screening large numbers of compounds, it might be required to quickly assess whether a molecule is planar. Since they can be arbitrarily rotated, it is not immediately obvious how to do that. One way however is to calculate the volume and surface area of the convex hull. From those information, the average “thickness” of the molecule can be assessed and provides a natural value to specify threshold. This way, the method scales to arbitrary molecule sizes (but may not work for very small molecules, because then the volume is small no matter what).
Luckily, this is easy in python/scipy:
import scipy.spatial as sps
hull = sps.ConvexHull(coordinates)
thickness = hull.volume/(hull.area/2.)
if thickness > 1.:
# not planar
You need to half the area, because a 3D object has the “top surface” and the “bottom surface”. If you reduce the threshold, the molecule needs to be more planar (a perfectly planar molecule has volume 0).
This is how it would look like in 2D for a somewhat planar molecule: