Determine coordinate of intersection between a line and a circle I'm putting together a simple script in processing to visualise layout possibilities within the fluid environment of a web page.
I need some help calculating a point on a circle:
The circle is as big as it can be, limited by the width or the visible height of the web browser viewport, whichever is less. A line intersects the circle through its centre from one corner of the viewport/rectangle to the opposite corner.
My question is how can I calculate the x & y coordinates of the line's intersections on the circle's circumference?
[edit]
Forgot the link: http://hascanvas.com/tschichold
 A: If the line and circle are specified in standard form $(x-a)^2+(y-b)^2=r^2$ and $y=mx+c$, you have two equations with two unknowns.  Just plug the expression for $y$ from the line into the circle equation and you have a quadratic in $x$ which will give the (up to) two solutions.  If your line and circle are specified differently, a similar technique will probably work, but you need to define how they are specified.
A: Call the center of the circle $(0,0)$ and the corner of the window, which the line passes through, $(a,b)$. Let $r$ be the radius of the circle. Then just multiply $a$ and $b$ by $\frac{r}{\sqrt{a^2+b^2}}$ and you have the coordinates on the circle.
A: here are some vb codes, given circle: (x-a)^2+(y-b)^2=r^2 and line y=mx+c
m = (y2-y1)/(x2-x1)
c = (-m * x1 + y1)

aprim = (1 + m ^ 2)
bprim = 2 * m * (c - b) - 2 * a
cprim = a ^ 2 + (c - b) ^ 2 - r ^ 2

delta = bprim ^ 2 - 4 * aprim * cprim

x1_e_intersection = (-bprim + Math.Sqrt(delta)) / (2 * aprim)
y1_e_intersection = m * x1_s_intersection + c

x2_e_intersection = (-bprim - Math.Sqrt(delta)) / (2 * aprim)
y2_e_intersection = m * x2_s_intersection + c

