standarddeviationcalculator.net SD Calculator

Line calculator: intersection, angle and distance between lines

Share this page

Favorites

    No favorites yet. Press Favorite on any page to keep it here.

    Methodology

    Type two straight lines in any linear form, such as y = 2x + 1 or 3x − 4y = 5, and the calculator tells you how they relate, where they cross and at what angle, or how far apart they are if they are parallel. Add a point to get its perpendicular distance to each line.

    Any linear form: y = 2x + 1, 3x − 4y = 5, x = 2.

    Point of intersection (1, 3)
    RelationshipIntersecting (not perpendicular)
    Angle between the lines71.565°
    tan θ3
    Distance from P to L12√5/5 ≈ 0.894427
    Distance from P to L22√2 ≈ 2.82843
    -4-2024680123456 (1, 3)P(3, 5) x y

    ━ L₁: 2x − y + 1 = 0   ━ L₂: x + y − 4 = 0

    Show the working, step by step
    1. Write both lines in the general form ax + by + c = 0 and read off the slopes m = −a/b.

      L₁: 2x − y + 1 = 0, m₁ = 2 L₂: x + y − 4 = 0, m₂ = −1

    2. Compare the coefficients: a₁b₂ − a₂b₁ = 0 means parallel. A₁a₂ + b₁b₂ = 0 means perpendicular.

      a₁b₂ − a₂b₁ = 2·1 − 1·(−1) = 3 a₁a₂ + b₁b₂ = 2·1 + (−1)·1 = 1

    3. Solve the two equations together (Cramer’s rule).

      x = (b₁c₂ − b₂c₁) ÷ (a₁b₂ − a₂b₁) = ((−1)·(−4) − 1·1) ÷ 3 = 1 y = (c₁a₂ − c₂a₁) ÷ (a₁b₂ − a₂b₁) = (1·1 − (−4)·2) ÷ 3 = 3 intersection = (1, 3)

    4. Angle between the lines. tan θ = |(m₁ − m₂) ÷ (1 + m₁m₂)|.

      tan θ = |(2 − (−1)) ÷ (1 + 2·(−1))| = 3 θ = arctan(3) = 71.565°

    5. Distance from P(3, 5) to L1: d = |ax₀ + by₀ + c| ÷ √(a² + b²).

      d = |2·3 + (−1)·5 + 1| ÷ √5 = 2 ÷ √5 = 2√5/5 ≈ 0.894427 foot of the perpendicular: (11/5, 27/5)

    6. Distance from P(3, 5) to L2: d = |ax₀ + by₀ + c| ÷ √(a² + b²).

      d = |1·3 + 1·5 + (−4)| ÷ √2 = 4 ÷ √2 = 2√2 ≈ 2.82843 foot of the perpendicular: (1, 3)

    Line formulas

    With the lines written as a₁x + b₁y + c₁ = 0 and a₂x + b₂y + c₂ = 0, and slopes m = −a/b:

    Intersection: x = (b₁c₂ − b₂c₁)/(a₁b₂ − a₂b₁), y = (c₁a₂ − c₂a₁)/(a₁b₂ − a₂b₁) Angle: tan θ = | (m₁ − m₂) / (1 + m₁m₂) | Parallel lines ax + by + c₁ = 0, ax + by + c₂ = 0: d = |c₁ − c₂| / √(a² + b²) Point (x₀, y₀) to ax + by + c = 0: d = |ax₀ + by₀ + c| / √(a² + b²)

    If a₁b₂ − a₂b₁ = 0 the intersection formula divides by zero. The lines are parallel or the same line, and the calculator switches to the distance between them.

    Line: a worked example

    The defaults are L₁. 2x − y + 1 = 0, L₂: x + y − 4 = 0 and P(3, 5).

    1. Slopes: m₁ = 2 and m₂ = −1. They are not equal, and m₁m₂ = −2 ≠ −1, so the lines intersect but are not perpendicular.
    2. Intersection: a₁b₂ − a₂b₁ = 2 × 1 − 1 × (−1) = 3. Then x = ((−1)(−4) − 1 × 1) ÷ 3 = 1 and y = (1 × 1 − (−4) × 2) ÷ 3 = 3, so they meet at (1, 3).
    3. Angle: tan θ = |(2 − (−1)) ÷ (1 + 2 × (−1))| = |3 ÷ (−1)| = 3, so θ = arctan 3 = 71.565°.
    4. Distance from P(3, 5) to L₁. |2 × 3 − 5 + 1| ÷ √(4 + 1) = 2 ÷ √5 = 2√5/5 ≈ 0.894.
    5. Distance from P to L₂. |3 + 5 − 4| ÷ √2 = 4 ÷ √2 = 2√2 ≈ 2.828. The foot of that perpendicular is (1, 3), which happens to be the point where the two lines cross.

    Reading the answer

    ResultTest in general formWhat you get
    Intersectinga₁b₂ − a₂b₁ ≠ 0One point and an acute angle between 0° and 90°
    Perpendiculara₁a₂ + b₁b₂ = 0One point and an angle of 90°
    Parallela₁b₂ − a₂b₁ = 0, constants not in the same ratioNo point. A fixed distance apart
    CoincidentAll three coefficients in the same ratioThe same line. Distance 0

    Common mistakes

    • Using the point-to-line formula on y = mx + c. Move every term to one side first. y = 2x + 1 becomes 2x − y + 1 = 0, so a = 2, b = −1, c = 1.
    • Forgetting the absolute value. Without it the angle formula can give the obtuse angle’s tangent as a negative number, and the distance formula can give a negative distance.
    • Dividing by 1 + m₁m₂ when it is zero. That case is not an error. It means the lines are perpendicular.

    To build a line from points or a slope, use the straight line equation calculator.

    Line calculator: the worked example on this page, with its result and chart
    Line calculator: the worked example above, at a glance.

    Common questions

    How do I tell whether two lines are parallel or perpendicular?

    Compare slopes. Parallel lines have equal slopes (m₁ = m₂). Perpendicular lines have slopes whose product is −1 (m₁m₂ = −1). In general form a₁x + b₁y + c₁ = 0 and a₂x + b₂y + c₂ = 0 the tests are a₁b₂ − a₂b₁ = 0 for parallel and a₁a₂ + b₁b₂ = 0 for perpendicular. These versions also cover vertical lines, which have no slope.

    How do you find the angle between two lines?

    Use tan θ = |(m₁ − m₂) ÷ (1 + m₁m₂)|, which gives the acute angle. For slopes 2 and −1, tan θ = |3 ÷ (−1)| = 3, so θ = 71.565°. The obtuse angle between the same lines is 180° − 71.565° = 108.435°. If 1 + m₁m₂ = 0 the lines are perpendicular and θ = 90°.

    What is the formula for the distance from a point to a line?

    For the point (x₀, y₀) and the line ax + by + c = 0, d = |ax₀ + by₀ + c| ÷ √(a² + b²). The line must be in general form first. For (3, 5) and 2x − y + 1 = 0: |6 − 5 + 1| ÷ √5 = 2/√5 = 2√5/5 ≈ 0.894.

    How do you find the distance between two parallel lines?

    Write both lines with the same x and y coefficients, ax + by + c₁ = 0 and ax + by + c₂ = 0, then d = |c₁ − c₂| ÷ √(a² + b²). For 3x + 4y − 10 = 0 and 6x + 8y + 5 = 0, halve the second to 3x + 4y + 5/2 = 0. The distance is |−10 − 5/2| ÷ 5 = 5/2. Skipping the rescaling is the usual mistake.

    What does it mean if the lines are coincident?

    The two equations describe the same line, one a multiple of the other (for example y = 2x + 1 and 4x − 2y + 2 = 0). Every point of one is on the other, so there is no single intersection point and the distance between them is 0.