Right triangle from two legs calculator
Two legs are all it takes: legs of 3 and 4 give a hypotenuse of 5, an area of 6 and the acute angle opposite each leg, in degrees. Only the sides that form the right angle go in. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Leg a
- 3
- Leg b
- 4
- Hypotenuse
- 5
- Angle a
- 36.8698976458
- Angle b
- 53.1301023542
- Angle right
- 90
When both legs of a right triangle are known—the two sides that meet at the right angle—the Pythagorean theorem and elementary trigonometry fix every remaining quantity: the hypotenuse, both acute angles, and the area. Students checking homework, carpenters laying out a square corner, and CAD or spreadsheet scripts all need the same deterministic answer from the same two positive lengths.
What two legs tell you about a right triangle
A right triangle has one angle of exactly 90 degrees, and the two sides that meet there are the legs. The side across from that corner is the hypotenuse, always the longest of the three. Once both legs are known, nothing else is left open: the Pythagorean theorem fixes the hypotenuse, the inverse tangent fixes each acute angle, and the area is half the product of the legs, because one leg works as the base and the other as the height. With legs of 3 and 4, the hypotenuse is 5 and the area is 6.
Common slips when working from the legs
The most frequent mistake is treating the hypotenuse as one of the two inputs, which quietly gives a wrong triangle. This calculator only takes the two sides that form the right angle, so that mix-up cannot happen. Another slip is pairing an angle with the wrong leg: each acute angle is the one opposite its leg, not the one beside it. Negative or zero lengths are refused instead of being turned into positive numbers, so a typing error never passes for a correct answer on a worksheet or a cut list.
Where solving from two legs helps
Classrooms and tutoring platforms use a right triangle from two legs calculator so learners can verify Pythagorean homework without mixing up which side is the hypotenuse. Construction and layout tools convert measured rise and run into diagonal length and corner angles before cutting stock. Game engines and physics sandboxes spawn right triangles from axis-aligned extents and need area plus orientation angles without pulling a full geometry library.
Exam generators and LMS plugins need a deterministic oracle that rejects negative legs instead of silently taking absolute values and marking wrong work as correct. Keep requests small, pin the rounded hypotenuse and angles in tests, and you get reproducible geometry for homework, edge workers, and design scripts without standing up symbolic math infrastructure of your own.
What you can do with it
Construction rise and run
Convert measured horizontal and vertical legs into diagonal cut length and corner angles before ordering or cutting material.
Games and layout scripts
Spawn right triangles from two axis-aligned extents and read area plus opposite angles without importing a full geometry CAS.
FAQ
What happens if a leg is negative?
Side lengths cannot be negative; zero is also rejected because it does not form a non-degenerate triangle. Invalid input is not billed.
Can I send only one leg or a known hypotenuse?
No. This landing requires both legs. For any-two-of-three sides (including recovering a missing leg from the hypotenuse), use the general right triangle calculator instead.
How do I find the hypotenuse from two legs?
Square each leg, add the two squares and take the positive square root of the sum. With legs of 3 and 4, that gives a hypotenuse of 5.
How are the two acute angles found?
Each one comes from the inverse tangent of the ratio between the legs, taking the leg opposite the angle over the other. Both are given in degrees, beside the fixed 90-degree right angle.
Can I use rise and run to size a diagonal cut?
Yes. Enter the horizontal and vertical measurements as the two legs: the hypotenuse is the diagonal cut length, and the corner angles come with it before you cut any material.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geom/right-triangle-legs \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"leg_a":3,"leg_b":4}'const res = await fetch("https://api.kit.forhosting.com/geom/right-triangle-legs", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"leg_a": 3,
"leg_b": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/right-triangle-legs",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"leg_a": 3,
"leg_b": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/right-triangle-legs", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"leg_a":3,"leg_b":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"leg_a":3,"leg_b":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/right-triangle-legs", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"leg_a": 3,
"leg_b": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.right_triangle_legs",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This right triangle from two legs calculator accepts leg_a and leg_b, computes the hypotenuse as the square root of the sum of squares, returns the area as half the product of the legs, and reports the acute angles opposite each leg in degrees with the right angle fixed at ninety. Negative or zero legs fail with invalid_input so invalid geometry never looks like a successful solve. The free browser path and the paid API share one pure parse module, so classroom demos and production automation never disagree on a 3-4-5 or any other pair of finite positive legs.
What two legs determine and how the formulas work
A right triangle has one interior angle of exactly ninety degrees. The two sides that form that right angle are the legs; the side opposite the right angle is the hypotenuse and is always the longest side. The area of a right triangle is simply half the product of the two legs, because one leg can serve as base and the other as height relative to the right angle. If you already know both leg lengths, the Pythagorean theorem states that the square of the hypotenuse equals the sum of the squares of the legs, so the hypotenuse is the positive square root of leg_a squared plus leg_b squared. Each acute angle is recovered with inverse tangent: the angle opposite leg_a is the arctangent of leg_a over leg_b, and the angle opposite leg_b is the arctangent of leg_b over leg_a; those two acute angles always sum to ninety degrees with the right angle. This capability encodes that closed-form solve end to end: it does not search, sample, or call an external solver.
Input contract, response shape, and error behaviour
Negative legs are rejected explicitly because a length cannot be negative in Euclidean geometry, and zero would collapse the triangle to a line segment. Lengths that are absurdly small or large for stable floating-point work are also rejected rather than returning nonsense angles. Failed validation is not billed. POST a JSON body with two required finite numbers: leg_a and leg_b, both strictly positive lengths in the same unit. Each field may arrive as a JSON number or as a numeric string; missing fields, empty strings, non-finite values, zero, and negative values fail with invalid_input naming the problem. On success the body echoes both legs, the computed hypotenuse, angle_a opposite leg_a, angle_b opposite leg_b, angle_right equal to ninety, area, angle_unit set to deg, and method set to right_triangle_legs so clients can distinguish this landing from other triangle solvers. Example: leg_a equals three and leg_b equals four yields hypotenuse five, area six, and acute angles about thirty-six point nine and fifty-three point one degrees. Pair the structured JSON with your own drawing code if you need a sketch; this endpoint returns numbers only and does not emit SVG, step-by-step prose beyond the field names, or unit conversion between metres and feet—you supply legs already in one consistent unit.
Integration use cases
Classroom Pythagorean checks
Students enter both legs and verify hypotenuse, area, and acute angles against textbook 3-4-5 style exercises with a deterministic API oracle.
Technical questions
How do I find the hypotenuse from two legs?
Send positive finite leg_a and leg_b. The API returns hypotenuse = √(leg_a² + leg_b²), area = (leg_a·leg_b)/2, and both acute angles in degrees.
Which angle is angle_a versus angle_b?
angle_a is the acute angle opposite leg_a; angle_b is opposite leg_b. They sum to 90° with the right angle reported as angle_right: 90.
What does the right triangle from two legs calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.