Calculation of perimeters