L
L
l2p2014-03-13 20:31:38
C++ / C#
l2p, 2014-03-13 20:31:38

How to find the intersection of shapes?

I have panel1.

g.DrawEllipse(aquaPen, e.X - 50, e.Y - 50, 100, 100);

- I draw a circle
Also I draw the second figure. How can I determine if they intersect or not?
PS. The task is written circle + triangle. Am I doing it right, or do I still need to fill the figure?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Morozov, 2014-03-13
@morozovdenis

to find out whether the circle and the triangle intersect or not, you need to solve 3 systems of equations: the
first:
(x-x0)^2+(y-y0)^2=R^2
(y-Ay)/(By-Ay)=(x -Ax)/(Bx-Ax)
second:
(x-x0)^2+(y-y0)^2=R^2
(y-Cy)/(By-Cy)=(x-Cx)/(Bx -Cx)
third:
(x-x0)^2+(y-y0)^2=R^2
(y-Cy)/(Ay-Cy)=(x-Cx)/(Ax-Cx)
where x0, y0 the center of the circle
A, B and C are the coordinates of the vertices of the triangle
, and if at least one has a solution, then they intersect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question