# Rectangle Calculator

> Computes the area, perimeter and diagonal of a rectangle from its length and width. Lengths are unit-agnostic; the area is in the square of the input unit.

- Calculator id: `rectangle` · Category: Geometry (`geometry`) · Tool name: `calculate_rectangle_properties`
- Canonical page: https://tttkmbb.com/geometry/rectangle · This document: https://tttkmbb.com/geometry/rectangle.md · JSON definition: https://tttkmbb.com/geometry/rectangle.json

## Purpose

Computes the area, perimeter and diagonal of a rectangle from its length and width. Lengths are unit-agnostic; the area is in the square of the input unit.

**Use when:** You need the area, perimeter or diagonal of a rectangle or square (enter equal length and width).

**Do not use when:** The shape is a box with depth (use rectangular-prism) or a slanted quadrilateral (use parallelogram or trapezoid).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `length` | number | units | required | Length of the rectangle. (> 0) |
| `width` | number | units | required | Width of the rectangle. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `area` | number | units² | length × width. |
| `perimeter` | number | units | 2 × (length + width). |
| `diagonal` | number | units | √(length² + width²). |
| `diagonal_angle_deg` | number | degrees | Angle between the diagonal and the length side = atan(width / length). |

## Formula

`area = length × width; perimeter = 2 × (length + width); diagonal = √(length² + width²); diagonal_angle_deg = atan(width / length)`

## Data Sources

- Wikipedia – Rectangle — https://en.wikipedia.org/wiki/Rectangle (reference, retrieved 2026-09-23)
- Wolfram MathWorld – Rectangle — https://mathworld.wolfram.com/Rectangle.html (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/rectangle?length=…&width=…`
- `POST https://tttkmbb.com/api/v1/calculate/rectangle` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/rectangle · OpenAPI operationId `calculate_rectangle_properties` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "rectangle", "inputs": {…}}`

## Example

- 5 by 3: inputs `{"length":5,"width":3}` → `{"area":15,"perimeter":16,"diagonal":5.831,"diagonal_angle_deg":30.9638}`
- 12 by 5: inputs `{"length":12,"width":5}` → `{"area":60,"perimeter":34,"diagonal":13,"diagonal_angle_deg":22.6199}`

```
GET https://tttkmbb.com/api/v1/calculate/rectangle?length=5&width=3
```

## Limitations

The shape is a box with depth (use rectangular-prism) or a slanted quadrilateral (use parallelogram or trapezoid). All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Does it matter which side is the length?**

No for area, perimeter and diagonal. Only diagonal_angle_deg is measured from the side entered as length.

**How do I use it for a square?**

Enter the same value for length and width; the diagonal is then side × √2 and the diagonal angle is 45°.

## Related

- [Rectangular Prism Calculator](https://tttkmbb.com/geometry/rectangular-prism.md) — Add a height to get a box's volume and surface area.
- [Parallelogram Calculator](https://tttkmbb.com/geometry/parallelogram.md) — Quadrilateral with slanted sides.
- [Flooring Calculator](https://tttkmbb.com/construction/flooring.md) — Estimate flooring material for a rectangular room.
