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
- 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.
- 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
| Variable | Typical range | Lowest result | Highest result | Swing () | Local step | Change in result |
|---|---|---|---|---|---|---|
| s Offset term (P₀ − C)·(P₀ − C) − r² | −10 to 8.5 cm² | −1.359 | 2.293 | 3.652 | +0.37 cm² | +9.47 % |
| p Direction-weighted offset (P₀ − C)·v | −6 to −2.5 cm² | 0.4322 | 1.382 | 0.9497 | +0.07 cm² | +3.66 % |
| q Direction length squared v·v | 0.2 to 1.7 cm² | 0.8579 | 1.349 | 0.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.563 | 0.2728 |
| 3.875 | 0.7362 |
| 6.188 | 1.323 |
| 8.5 | 2.293 |
Sweep one variable
Variables and how each one contributes
First intersection parameter
What the equation gives you. Everything else feeds it.
Direction-weighted offset (P₀ − C)·v
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.
Direction length squared v·v
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.
Offset term (P₀ − C)·(P₀ − C) − r²
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
- Discriminant: p² − q s = 9 − 1 × 5 = 4.
- Root: √4 = 2.
- 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