I am trying to determine the point at which a line segment intersect a circle. For example, given any point between P0 and P3 (And also assuming that you know the radius), what is the easiest method to determine P3?
相关问题
- How to determine +/- sign when calculating diagona
- Union of many (more than two) polygons without hol
- Is there a way to rotate text around (or inside) a
- Filling rectangle with points pattern
- Unity Intersections Mask
相关文章
- Algorithm for partially filling a polygonal mesh
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- SVG circle starting point
- How to calculate end points of perpendicular line
- Calculate the eccentricity of ellipses
- Draw a rectangle arround a polygon when given in c
- How to determine a diagonal is in or out of a conc
Generally,
In pseudocode,
MATLAB CODE
function [ flag] = circleLineSegmentIntersection2(Ax, Ay, Bx, By, Cx, Cy, R)
end
From the center of the circle and the radius you can write the equation describing the circle. From the two points P0 and P1 you can write the equation describing the line.
So you have 2 equations in 2 unknowns, which you can solved through substitution.
The equation for the circle is:
The equation for the line is:
Plugging the 2nd equation into the first gives:
Similarly you can find that
The point (x,y) is the intersection point between the line and the circle, (x,y) is your answer.
Go for this code..its save the time
You have a system of equations. The circle is defined by:
x^2 + y^2 = r^2
. The line is defined byy = y0 + [(y1 - y0) / (x1 - x0)]·(x - x0)
. Substitute the second into the first, you getx^2 + (y0 + [(y1 - y0) / (x1 - x0)]·(x - x0))^2 = r^2
. Solve this and you'll get 0-2 values for x. Plug them back into either equation to get your values for y.