Angle between two lines calculator
Enter two slopes and get the acute angle between the lines: slopes 1 and 0 meet at 45°, while 2 and −1/2 are perpendicular at 90°. Parallel lines read 0°, and the result comes in degrees and radians. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- M1
- 1
- M2
- 0
- Angle deg
- 45
- Angle rad
- 0.7853981634
- Product m1 m2
- 0
The angle between two lines calculator finds the acute angle formed by a pair of straight lines when you already know their slopes. In coordinate geometry every non-vertical line has a slope m equal to rise over run, and the classic textbook identity tan of theta equals the absolute value of m2 minus m1 over one plus m1 times m2 turns those two numbers into a unique acute measure between zero and ninety degrees. Students, tutors, CAD helpers, and exam-prep tools need that result without reinventing floating-point edge cases for parallel and perpendicular pairs. This capability accepts finite slopes m1 and m2, applies the identity, folds the result into the acute range, and returns degrees, radians, product m1 times m2, and clear parallel or perpendicular flags.
The slope formula for the angle between two lines
In the Cartesian plane a non-vertical line through two points has slope m equal to the change in y divided by the change in x. That single number is the tangent of the inclination of the line measured from the positive x-axis. When two such lines meet, the angles they form come in a supplementary pair: if one angle is alpha the adjacent angle is one hundred eighty degrees minus alpha, so the geometrically useful summary is always the acute (or right) angle theta between zero and ninety degrees.
Analytic geometry proves that the tangent of that acute angle satisfies tan theta equals the absolute value of m2 minus m1 divided by one plus the product m1 times m2. The absolute value strips sign so the formula does not care which line you call first. When the denominator is zero the product of the slopes is negative one and the lines are perpendicular, so theta is exactly ninety degrees and the tangent identity would have divided by zero.
When the slopes are equal the numerator vanishes, the lines are parallel or coincident in direction, and theta is zero. This angle between two lines calculator implements exactly that identity with stable rounding so homework checks, LMS auto-graders, and production edge workers agree byte for byte on the same inputs. You do not pass intercepts or points: only the two slopes that already encode the directions of the lines.
Where the angle between two lines is useful
Classrooms and tutoring platforms use an angle between two lines calculator so learners can verify the acute measure for arbitrary textbook slopes without flipping the absolute-value step or forgetting to fold an obtuse supplementary angle back into the acute range. Exam-prep generators need a deterministic oracle that marks parallel pairs as zero degrees and perpendicular pairs as ninety degrees instead of relying on student-written scripts that diverge on floating-point noise.
Keep requests small, pin the rounded angles in tests, and you get reproducible geometry for homework, LMS plugins, and edge workers without standing up symbolic math infrastructure of your own.
What you can do with it
Classroom and homework checks
Let students submit two slopes and verify the acute angle, parallel flag, and perpendicular flag against the textbook tan formula.
Exam and LMS auto-grading
Mark coordinate-geometry items with a deterministic oracle that returns 0° for equal slopes and 90° when m1·m2 = −1.
CAD macros and path planners
Convert two direction slopes in a local chart into the meeting angle before applying a turn, fillet, or clearance rule.
FAQ
Is the angle always acute?
Yes. The formula with absolute value and the arctan range produce the acute (or right) angle between the lines, never the obtuse supplement.
What happens if the lines are parallel or perpendicular?
Equal slopes give 0°, because the lines run in the same direction. When the product of the slopes is −1, the lines are perpendicular and the angle is exactly 90°. Both cases are flagged in the result.
Can I enter a vertical line?
No. A vertical line has no defined slope, so it cannot be described by a finite number and is rejected. Use this calculator for lines you can describe with a slope, as rise over run.
Does it matter which slope I enter first?
No. The formula takes the absolute value of the difference between the slopes, so swapping them gives the same acute angle. You can call either line the first one.
How do I find a line's slope from two points?
Divide the change in y by the change in x between the two points, which is rise over run. That single number describes the line's direction and is all this calculator needs.
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/angle-between-lines \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"m1":1,"m2":0}'const res = await fetch("https://api.kit.forhosting.com/geom/angle-between-lines", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"m1": 1,
"m2": 0
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/angle-between-lines",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"m1": 1,
"m2": 0
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/angle-between-lines", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"m1":1,"m2":0}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"m1":1,"m2":0}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/angle-between-lines", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"m1": 1,
"m2": 0
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.angle_between_lines",
"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
Vertical lines have undefined slope and are rejected with invalid_input so callers never silently invent Infinity.
Input contract, vertical lines, and response fields
Vertical lines are outside this contract on purpose: a vertical line has undefined slope, so you cannot feed a finite m and still mean a vertical direction. Example: m1 equals one and m2 equals zero is a line at forty-five degrees against a horizontal line, so the acute angle is forty-five degrees. Example: m1 equals two and m2 equals negative one half yields product negative one, so the lines are perpendicular and the angle is ninety degrees. Failed validation is not billed. POST a JSON body with two required finite numbers: m1, the slope of the first line, and m2, the slope of the second line. Each field may arrive as a JSON number or as a numeric string; empty strings, missing fields, NaN, and Infinity all fail with invalid_input naming the field. On success the body echoes the rounded slopes, angle_deg and angle_rad for the acute angle, boolean is_parallel and is_perpendicular flags derived from the same tolerances used in the angle computation, product_m1_m2 for quick classroom checks of the perpendicular product rule, and a short formula string you can show next to the answer. Pair the numbers with your own diagram if you need a sketch; this endpoint returns only the metric and the flags.
Where an angle-between-lines API earns its keep
Surveying notes, simple CAD macros, and robotics path planners often reduce two direction vectors to slopes in a local chart and then need the meeting angle before deciding a turn or a fillet; calling a tiny parse API avoids pulling a full computational-geometry library for a two-number problem.
Technical questions
How do I find the angle between two lines from their slopes?
Send finite numbers m1 and m2. The API returns θ from tan θ = |(m2−m1)/(1+m1·m2)|, folded into the acute range [0°, 90°], with both degrees and radians.
What if the lines are parallel or perpendicular?
Equal slopes yield angle 0° and is_parallel true. When m1·m2 = −1 the angle is 90° and is_perpendicular true. Both flags appear in the success payload.
Can I enter a vertical line?
No. Vertical lines have undefined slope. This calculator requires finite m1 and m2; vertical or Infinity values fail with invalid_input and are not billed.
What does the angle between two lines calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.