Given coordinates find triangle and circle intersections

For example we have a circle and triangle. We need to check if at given $(m, n)$ coordinate triangle is intersecting with circle (area).

Circle center is fixed at $(100, 100)$ with radius $R = 50$. Triangle corners coordinates vary: $$A(x_1, y_1)\quad B(x_2, y_2)\quad C(x_3, y_3).$$

Circle equation is: $(x - 100)^2 + (y - 100)^2 = 50^2$. If $(m - 100)^2 + (n - 100)^2 - 50^2$ is below or equal zero, it means that $(m, n)$ coordinate is inside circle.

Now I want to extend this to one/simple formula, which on a simple more/less/equal condition would evaluate if $(m, n)$ is inside both circle and triangle. Is this possible? What triangle formula should I use and what condition should I look for?

You might ask why I want to construct simple formula. Well, I am working on a problem, where I want to brutally scan certain coordinates region and to each coordinate assign number from which it would be obvious if this coordinate is both inside triangle and circle or not.

I have read (triangle case) that I should check barycentric coordinates for equality greater than zero. I did understand how it works, just not sure how could I simplify everything into one equation.

• Hint: a triangle is comprised of three piecewise lines. When you have a boundary that's piecewise, there's no easy way of simplifying - you're not doing a line integral, so I don't think Green's Theorem would be very helpful. Wrap equations with dollar signs to get math formatting. Edit: Are you asking for a way to see what points on the circle intersect with the triangle, a way of finding which segments of the triangle lie within the circle, or something else? – Eli Berkowitz Dec 10 '15 at 2:01

A "single equation" way to find if point $P=(m,n)$ lies inside triangle $ABC$ is the following: $$|(x_2 - x_1) (y_1 - n) - (x_1 - m) (y_2 - y_1)| +\\ |(x_3 - x_2) (y_2 - n) - (x_2 - m) (y_3 - y_2)| +\\ |(x_1 - x_3) (y_3 - n) - (x_3 - m) (y_1 - y_3)| =\\ |(x_1 - x_3) (y_3 - y_2) - (x_3 - x_2) (y_1 - y_3)|$$ The three expressions inside absolute value on the LHS are twice the areas of triangles $ABP$, $BCP$ and $CAP$. Their sum is equal to twice the area of $ABC$, which is on the RHS, if an only if $P$ is inside $ABC$, otherwise it is greater.