Mxx = sum (x * x * I) / sum (I) Myy = sum (y * y * I) / sum (I) Mxy = sum (x * y * I) / sum (I) e = sqrt ((Mxx - Myy) ** 2 + (2 * Mxy) ** 2) / (Mxx + Myy) pa = 0.5 * atan (2 * Mxy / (Mxx - Myy))