Your Equation

Library / Geometry, coordinates, surveying and trigonometry / GEO-30

Geometry, coordinates, surveying and trigonometry

Angle between two straight lines

The smaller angle between two lines from their direction vectors u and v, between 0° and 90°.

Ref
GEO-30
Rev
v1
Field
Geometry, coordinates, surveying and trigonometry
Result
α [°]

The angle between two lines with direction vectors u and v follows from their cross and dot products: tan α = |u × v| / |u · v|. The two-argument arctangent takes this correctly even when u · v is zero, which is a right angle, or when a line is vertical. The result is the smaller angle, between 0° and 90°, and is the same whichever way the vectors point.

The smaller angle between two lines from their direction vectors u and v, between 0° and 90°. The two-argument arctangent is used, so perpendicular and vertical lines work.

Calculator

Solve for
°
−55
−55
−55
−55
  • Dot product u · v0
  • Cross product u × v5
  • Angle in radians1.571 rad

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Angle between the lines (°) current value 90 °
uxDirection u, xKey driver
0
vyDirection v, y
0
uyDirection u, y
7.13
vxDirection v, x
7.13
  • Lines along (1, 2) and (−2, 1) meet at 90°, a right angle, because the dot product is zero.
  • The result is always between 0° and 90°, so 100° between directions is reported as 80°, the angle between the lines themselves.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing (°)Local stepChange in result
ux Direction u, x−5 to 5 09090+0.2 −4.4 °
vy Direction v, y−5 to 5 09090+0.2 −4.4 °
uy Direction u, y−5 to 5 7.1259082.87+0.2 −2.12 °
vx Direction v, x−5 to 5 7.1259082.87+0.2 −2.49 °

Sweep of Direction u, x

Direction u, xAngle between the lines (°)
−54.764
−3.751.507
−2.512.09
−1.2531.43
063.43
1.2584.56
2.565.22
3.7554.64
548.37

Sweep one variable

Angle between the lines (°)Hover, touch, or use the arrow keys on the chart
020406080 −4−2024 Direction u, x now 90

Variables and how each one contributes

α

Angle between the lines

Result · °

What the equation gives you. Everything else feeds it.

ux

Direction u, x

· typical −5 to 5

The x-component of the direction vector of the first line, a plain number. Turns the first line and so changes the angle. Raising it by 0.5 (to 1.5) moves the result by −11.4 %, from 90 to 79.7 °.

uy

Direction u, y

· typical −5 to 5

The y-component of the direction vector of the first line, a plain number. Turns the first line and so changes the angle. Raising it by 0.5 (to 2.5) moves the result by −5.29 %, from 90 to 85.24 °.

vx

Direction v, x

· typical −5 to 5

The x-component of the direction vector of the second line, a plain number. Turns the second line and so changes the angle. Raising it by 0.5 (to −1.5) moves the result by −7.92 %, from 90 to 82.87 °.

vy

Direction v, y

· typical −5 to 5

The y-component of the direction vector of the second line, a plain number. Turns the second line and so changes the angle. Raising it by 0.5 (to 1.5) moves the result by −11.4 %, from 90 to 79.7 °.

Worked example with the values above

  1. Cross product: 1 × 1 − 2 × −2 = 5.
  2. Dot product: 1 × −2 + 2 × 1 = 0.
  3. α = atan2(|5|, |0|) = 90°.

Assumptions and limits

  • Plane (two-dimensional) Cartesian coordinates in one consistent unit.
  • The two points or the two direction vectors are not the same, and neither vector has zero length.

Common mistakes

  • Using the angle of each line with the x-axis and forgetting to take the smaller angle.
  • Using a gradient formula when one line is vertical.
  • Taking the direction vectors from the wrong ends, which only changes signs and not the angle.

Statistics and uncertainty

These are exact algebraic results from the coordinates, so the uncertainty comes from the inputs. Near-parallel lines and nearly collinear points are the cases where small input errors give large changes in angles or areas.

Where it is used

  • Clearances, offsets and angles between members in drawings, CAD and surveying.
  • Areas of plots, plates and polygon pieces from corner coordinates.

Maths you need

  • Gradient: rise over run of a line
  • Vector: direction and length written as (x, y)
  • Dot product: the sum of products of components

Related formulas

Practise this formula