handle triangles calculation math