Angle Between Two Lines Calculator

Describe each line by its slope, a direction vector, two points, or the coefficients of Ax + By + C = 0. Vertical lines are handled.

C does not affect the direction, so it is not needed.

Acute angle

8.1301°

Obtuse angle

171.8699°

Relationship

Intersecting

Slope of line 1

2

Slope of line 2

3

tan of the acute angle

0.1429

How it works

Two lines that cross make two pairs of equal angles, one acute and one obtuse, adding up to 180°. The angle between the lines usually means the acute one. For lines with slopes m₁ and m₂, the classic formula is tan θ = |(m₂ − m₁) ÷ (1 + m₁m₂)|: each slope is the tangent of the line's angle to the x-axis, and the tangent subtraction identity gives the tangent of the difference.

That formula breaks when 1 + m₁m₂ = 0, which is exactly the perpendicular case, and it cannot describe a vertical line at all. The calculator therefore works with direction vectors: a slope m becomes the vector (1, m), two points become their difference, and the equation Ax + By + C = 0 gives the direction (B, −A). The acute angle is then atan2(|u × v|, |u · v|), which handles a zero dot product (perpendicular) and a zero cross product (parallel) without dividing by anything.

Parallel and perpendicular are flagged when the cross or dot product is within rounding error of zero relative to the lengths of the vectors. The slopes of both lines are reported too; a vertical line's slope is shown as a dash because it is undefined.

Formula

tan θ = |(m₂ − m₁) ÷ (1 + m₁ · m₂)|                 (slopes; perpendicular when m₁ · m₂ = −1)
u = (1, m₁)   or   B − A   or   (B, −A) from Ax + By + C = 0
acute θ   = atan2(|u₁v₂ − u₂v₁|, |u₁v₁ + u₂v₂|)
obtuse    = 180° − θ
parallel if u₁v₂ − u₂v₁ = 0;   perpendicular if u₁v₁ + u₂v₂ = 0

Example

The lines y = 2x + 1 and y = 3x − 5 have slopes 2 and 3, so tan θ = |(3 − 2) ÷ (1 + 6)| = 1/7 and the acute angle is atan(1/7) ≈ 8.1301°; the obtuse angle is 171.8699°.

The direction vectors (1, 2) and (3, −1) have dot product 3 − 2 = 1 and cross product −1 − 6 = −7, so tan θ = 7 and the acute angle is ≈ 81.8699°. Slopes 2 and −1/2 multiply to −1, so those lines are perpendicular: 90° exactly.

Assumptions and limitations

  • Both lines lie in the same plane. For lines in three dimensions use the angle between their direction vectors from the vector calculator.
  • The acute angle is reported as the angle between the lines; the obtuse angle is its supplement. Parallel lines are reported as 0° and 180°.
  • Parallel and perpendicular are detected to a relative tolerance of 1e-9, so slopes typed as −0.3333 and 3 (89.998°) are not flagged perpendicular; −0.5 and 2, whose product is exactly −1, are.
  • Angles entered or shown in degrees use the exact factor π/180.

Frequently asked questions

Why does the slope formula fail for perpendicular lines?

Because 1 + m₁m₂ is zero there and the fraction is undefined; the tangent of 90° is infinite. The direction-vector form used by the calculator has no division, so it returns 90° cleanly, and the tan output shows a dash.

How do I enter a vertical line?

Use the direction vector (0, 1), two points with the same x, or the equation x − c = 0 with A = 1 and B = 0. A slope cannot represent it.