A diagonal connects two corners of a shape that aren't already joined by an edge. This calculator handles three common versions of that idea: the flat diagonal of a rectangle or square, the space diagonal that cuts through the interior of a box, and the total number of diagonals inside a polygon.
How the Diagonal Calculator works
The rectangle and square diagonals are both direct applications of the Pythagorean theorem: treat the diagonal as the hypotenuse of a right triangle formed by two adjacent sides. A box's space diagonal extends the same idea into three dimensions by applying the theorem twice — first across the base, then up to the opposite top corner — giving d = √(l² + w² + h²). The polygon diagonal count is a different kind of formula entirely: it's a combinatorial count of line segments, not a distance, derived from the fact that each of a polygon's n vertices can connect diagonally to n − 3 other vertices (every vertex except itself and its two neighbors), then divided by 2 to avoid counting each diagonal twice.
Inputs and what they mean
For the Rectangle/Square tab, length and width (or a single side for a square) can be any consistent linear unit — inches, feet, centimeters, or meters — and the diagonal comes back in that same unit. The Box tab works the same way with a third dimension added. The Polygon Diagonals tab takes a single whole number, n, representing the number of sides (equivalently, vertices) of a simple polygon; the diagonal count is unitless since it's a count of segments, not a length.
Limits and edge cases
The rectangle, square, and box formulas assume perfect right angles at every corner — they won't give an accurate answer for a parallelogram, a rhombus, or a box with beveled edges (use the dedicated Parallelogram Calculator for those). All side lengths must be positive numbers; zero or negative values describe a degenerate shape with no defined diagonal. The polygon formula requires n ≥ 3, since a triangle is the simplest polygon and has zero diagonals by definition — every pair of its vertices is already connected by an edge. Entering n = 1 or n = 2 has no geometric meaning and the calculator will flag it as invalid rather than return a number.