Diagonal of Rectangular Prism Calculator – Space Diagonal Explained
A rectangular prism (also called a cuboid or rectangular box) has three distinct edge lengths — length, width, and height. Its space diagonal is the longest straight line that fits inside it: a line connecting two opposite vertices that passes straight through the solid's interior. This calculator finds the space diagonal along with the three face diagonals from a prism's dimensions, and can also reverse the process to solve for a missing dimension when the diagonal is already known. It's useful in packaging design, shipping, architecture, and geometry education whenever you need to know the longest object that will fit inside — or diagonally through — a box-shaped space.
The Space Diagonal Formula
The space diagonal is derived by applying the Pythagorean theorem twice. First, the diagonal across the base (length × width) is found:
d_bottom = √(l² + w²)
That base diagonal then becomes one leg of a second right triangle, with the prism's height as the other leg and the space diagonal as the hypotenuse, which simplifies to the familiar 3D Pythagorean formula:
d = √(d_bottom² + h²) = √(l² + w² + h²)
For example, a prism with length 12 cm, width 8 cm, and height 6 cm has a space diagonal of √(144 + 64 + 36) = √244 ≈ 15.6205 cm. Only Math.sqrt() is needed — no external library is required.
Face Diagonals
Alongside the space diagonal, the calculator reports all three face diagonals — one for each pair of dimensions:
d_bottom = √(l² + w²) — diagonal of the length × width faced_front = √(l² + h²) — diagonal of the length × height faced_side = √(w² + h²) — diagonal of the width × height face
Each face diagonal only crosses one flat rectangular face, so all three are shorter than the space diagonal, which cuts through the prism's interior to reach the farthest possible vertex.
Solving for a Missing Dimension
If you already know the space diagonal and two of the three dimensions, you can rearrange the formula to solve for the missing one:
h = √(d² − l² − w²)
For example, if a box needs a space diagonal of at least 20 cm to fit a rod diagonally, and the base is fixed at 15 cm × 10 cm, the required height is √(400 − 225 − 100) = √75 ≈ 8.6603 cm. This reverse mode is particularly useful for fit-check problems — determining how tall, wide, or long a box must be to fit an object of a known length.
√(l² + w²) of the two known sides, there is no valid positive height that satisfies the equation — the calculator will show a validation error explaining that the diagonal is too short for those dimensions.Comparing Multiple Boxes
The comparison mode lets you enter two or more sets of dimensions and see their space diagonals side by side. This is helpful when choosing between several container or packaging options to fit the longest possible item, such as comparing a 10 × 8 × 6 box against a 12 × 5 × 5 box to see which one offers more diagonal clearance.
Unit Conversion
Enter dimensions in any supported unit — millimeters, centimeters, meters, inches, feet, or yards — and the calculator converts internally to a consistent base unit before computing the result, then displays the answer back in your chosen unit.
Common Applications
- Packaging and shipping — determining the longest item that can fit diagonally inside a rectangular box or shipping container
- Architecture and construction — checking clearances for rectangular rooms, ducts, or storage units
- Furniture and moving — verifying whether a large object can be tilted diagonally through a doorway or hallway
- 3D modeling and game design — computing bounding diagonals for collision detection and camera framing
- Geometry education — demonstrating how the Pythagorean theorem extends from two dimensions into three
Precision and Accuracy
All calculations use standard 64-bit floating-point arithmetic (IEEE 754), accurate to about 15 significant digits. Displayed values are rounded to your chosen precision, from 0 to 10 decimal places.