# Right Triangle Calculator

> Solves a right triangle from any two of its sides (two legs, or one leg and the hypotenuse) using the Pythagorean theorem, and returns all sides, the two acute angles in degrees, area, perimeter and the altitude to the hypotenuse.

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

## Purpose

Solves a right triangle from any two of its sides (two legs, or one leg and the hypotenuse) using the Pythagorean theorem, and returns all sides, the two acute angles in degrees, area, perimeter and the altitude to the hypotenuse.

**Use when:** You know two sides of a right-angled triangle and need the third side, the angles or the area.

**Do not use when:** The triangle has no right angle (use triangle-solver) or you only need the hypotenuse length (pythagorean gives just that).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `leg_a` | number | units | optional | First leg (side adjacent to the right angle). (> 0) |
| `leg_b` | number | units | optional | Second leg (side adjacent to the right angle). (> 0) |
| `hypotenuse` | number | units | optional | Side opposite the right angle; must be longer than either leg. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `leg_a` | number | units | First leg. |
| `leg_b` | number | units | Second leg. |
| `hypotenuse` | number | units | √(leg_a² + leg_b²). |
| `angle_a_deg` | number | degrees | Acute angle opposite leg_a = atan(leg_a / leg_b). |
| `angle_b_deg` | number | degrees | Acute angle opposite leg_b = 90 − angle_a_deg. |
| `area` | number | units² | leg_a × leg_b / 2. |
| `perimeter` | number | units | leg_a + leg_b + hypotenuse. |
| `altitude_to_hypotenuse` | number | units | Height from the right angle onto the hypotenuse = leg_a × leg_b / hypotenuse. |

## Formula

`hypotenuse² = leg_a² + leg_b²; angle_a_deg = atan(leg_a / leg_b); angle_b_deg = 90 − angle_a_deg; area = leg_a × leg_b / 2; altitude = leg_a × leg_b / hypotenuse`

## Data Sources

- Wikipedia – Right triangle — https://en.wikipedia.org/wiki/Right_triangle (reference, retrieved 2026-09-23)
- Wikipedia – Pythagorean theorem — https://en.wikipedia.org/wiki/Pythagorean_theorem (reference, retrieved 2026-09-23)
- Wolfram MathWorld – Right Triangle — https://mathworld.wolfram.com/RightTriangle.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/right-triangle?`
- `POST https://tttkmbb.com/api/v1/calculate/right-triangle` 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/right-triangle · OpenAPI operationId `solve_right_triangle` 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": "right-triangle", "inputs": {…}}`

## Example

- Legs 3 and 4: inputs `{"leg_a":3,"leg_b":4}` → `{"hypotenuse":5,"angle_a_deg":36.8699,"angle_b_deg":53.1301,"area":6,"perimeter":12,"altitude_to_hypotenuse":2.4}`
- Leg 5, hypotenuse 13: inputs `{"leg_a":5,"hypotenuse":13}` → `{"leg_b":12,"angle_a_deg":22.6199,"angle_b_deg":67.3801,"area":30,"perimeter":30}`

```
GET https://tttkmbb.com/api/v1/calculate/right-triangle?leg_a=3&leg_b=4
```

## Limitations

The triangle has no right angle (use triangle-solver) or you only need the hypotenuse length (pythagorean gives just that). All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Which angle is angle_a_deg?**

The angle opposite leg_a (at the vertex where leg_b meets the hypotenuse). The two acute angles always add up to 90°.

**What if I enter all three sides?**

They must satisfy leg_a² + leg_b² = hypotenuse² (to 0.01 %); otherwise an INVALID_PARAMETER error is returned. Give just two sides to avoid this.

## Related

- [Triangle Solver](https://tttkmbb.com/geometry/triangle-solver.md) — Solve triangles that are not right-angled.
- [Triangle Area Calculator](https://tttkmbb.com/geometry/triangle-area.md) — Area only, by any of three methods.
- [Pythagorean Theorem Calculator](https://tttkmbb.com/math/pythagorean.md) — Just the hypotenuse or a leg from the Pythagorean theorem.
