Your Equation

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

Geometry, coordinates, surveying and trigonometry

Intersection of a line with a circle

The smaller line parameter at which the line P₀ + tv meets a circle, with q = v·v, p = (P₀ − C)·v and s = (P₀ − C)·(P₀ − C) − r².

Ref
GEO-38
Rev
v1
Field
Geometry, coordinates, surveying and trigonometry
Result
t_-

A line P(t) = P₀ + t v meets a circle with centre C and radius r where |P₀ + t v − C|² = r². That is the quadratic q t² + 2p t + s = 0, with q = v·v, p = (P₀ − C)·v and s = |P₀ − C|² − r². The roots are t = (−p ± √(p² − q s))/q. A negative discriminant means the line misses the circle, and zero means it touches it once. This entry shows the smaller root.

The smaller line parameter at which the line P₀ + tv meets a circle, with q = v·v, p = (P₀ − C)·v and s = (P₀ − C)·(P₀ − C) − r². A negative discriminant gives no real hit and zero gives a single touching point. The other root is in the derived rows.

Calculator

Solve for
cm²
−6−2.5
Outside the valid range 1e-6 to 1 cm².
cm²
0.21.7
cm²
−108.5
  • Second intersection parameter, t₊5
  • Discriminant, p² − qs4 cm⁴
  • Chord length inside the circle, (t₊ − t₋)√q4 cm

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.

First intersection parameter () current value 1
sOffset term (P₀ − C)·(P₀ − C) − r²Key driver
−1.362.29
pDirection-weighted offset (P₀ − C)·v
0.4321.38
qDirection length squared v·v
0.8581.35
  • The line enters the circle at t = 1 and leaves it at t = 5, a path inside of length 4 cm.
  • With P₀ = (0, 0), v = (1, 0), C = (3, 0) and r = 2 the roots are t = 1 and t = 5, the points (1, 0) and (5, 0).
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing ()Local stepChange in result
s Offset term (P₀ − C)·(P₀ − C) − r²−10 to 8.5 cm²−1.3592.2933.652+0.37 cm²+9.47 %
p Direction-weighted offset (P₀ − C)·v−6 to −2.5 cm²0.43221.3820.9497+0.07 cm²+3.66 %
q Direction length squared v·v0.2 to 1.7 cm²0.85791.3490.4909+10%+2.65 %

Sweep of Offset term (P₀ − C)·(P₀ − C) − r²

Offset term (P₀ − C)·(P₀ − C) − r² (cm²)First intersection parameter
−10−1.359
−7.688−1.085
−5.375−0.7914
−3.063−0.4731
−0.75−0.1225
1.5630.2728
3.8750.7362
6.1881.323
8.52.293

Sweep one variable

First intersection parameter ()Hover, touch, or use the arrow keys on the chart
−1012 −10−505 Offset term (P₀ − C)·(P₀ − C) − r² (cm²) now 1

Variables and how each one contributes

t_-

First intersection parameter

Result ·

What the equation gives you. Everything else feeds it.

p

Direction-weighted offset (P₀ − C)·v

cm² · typical −6 to −2.5

The dot product of the offset from the centre to the start point with the direction vector, p = (P₀ − C)·v, in cm². Moves both roots: a more negative p means the line reaches the circle later along its direction. Raising it by 0.1 (to −2.9) moves the result by +5.34 %, from 1 to 1.053.

q

Direction length squared v·v

cm² · typical 0.2 to 1.7

The squared length of the direction vector, q = v·v, in cm². It must be positive. Scales the parameter t: a longer direction vector means fewer steps to reach the circle. Raising it by 0.1 (to 1.1) moves the result by +2.65 %, from 1 to 1.027.

s

Offset term (P₀ − C)·(P₀ − C) − r²

cm² · typical −10 to 8.5

The squared distance from the start point to the centre, less the squared radius, in cm². A larger value means the start is further outside the circle and the first hit comes later. Raising it by 0.5 (to 5.5) moves the result by +12.9 %, from 1 to 1.129.

Worked example with the values above

  1. Discriminant: p² − q s = 9 − 1 × 5 = 4.
  2. Root: √4 = 2.
  3. t₋ = (3 − 2) / 1 = 1.

Assumptions and limits

  • Plane Cartesian coordinates, and a circle of positive radius unless stated.
  • Angles in radians measured anticlockwise from the positive x-axis.

Common mistakes

  • Not checking the discriminant before taking the square root.
  • Using a direction vector that is not the one in q and p.
  • Forgetting that t is in steps of the vector v, not a length, unless v has length one.

Statistics and uncertainty

These are exact results from the circle and line equations, but they need a root of a difference. Where the radicand is close to zero, as near tangency, small input errors can change the answer a lot or change whether a solution exists at all.

Where it is used

  • Circle fitting, wheel and cam geometry, hole patterns and clearance checks.
  • Finding where a path, ray or cut meets a circular boundary.

Maths you need

  • Equation of a circle: (x − h)² + (y − k)² = r²
  • Quadratic discriminant: b² − 4ac decides the number of roots
  • Gradient of a normal: perpendicular to the tangent

Related formulas

Practise this formula