Calculation of triangle types.