perimeterRatio method

double perimeterRatio()

Calculates the ratio of the perimeter to twice the diagonal of the rectangle.

This method provides a way to measure how close the rectangle is to being a square. A square has a perimeter to diagonal ratio of 2, while other rectangles will have a ratio greater than 2.

Implementation

double perimeterRatio() {
  return perimeter() / (2 * diagonal());
}