1

I have a circle formed with three given points. How can i know whether another given point is inside the circle formed by previous three points. Is it determinant i need to calculate? Then what are the cases i need to handle?

user1118321
  • 25,567
  • 4
  • 55
  • 86
u2425
  • 61
  • 9
  • the distance of the point to the center of the circle is not more than its radius? – cybye Feb 25 '13 at 07:27
  • Check this link http://stackoverflow.com/a/839931/67381 – Siddiqui Feb 25 '13 at 07:30
  • that has been discussed here already: http://stackoverflow.com/questions/481144/equation-for-testing-if-a-point-is-inside-a-circle – cweigel Feb 25 '13 at 07:30
  • I know that point of checking the radius and center but i need a better way than that. – u2425 Feb 25 '13 at 07:31
  • @u2425: There is no better way. It's about as simple as you can get. – Blender Feb 25 '13 at 07:31
  • @Blender Then can you point me to the source where i can find center and radius straight away without much calculations involved. I am trying to minimize my calculations in a implementation? – u2425 Feb 25 '13 at 07:41
  • @Blender Is the answer given by MBo down would be a better one than going through the center and radius kind of stuff?? – u2425 Feb 25 '13 at 20:35

2 Answers2

3

It seems you want to know an answer without calculation of circle parameters (radius, center). So you can use the equation for the circumcircle of the triangle (formula 2), substitute (x,y) with given point coordinates and calculate determinant (Det) sign.

Important: points x1, x2, x3 should be in counterclockwise order. Otherwise - change the sign

| x^2+y^2    x    y   1 |
| x1^2+y1^2  x1  y1   1 | = Det
| x2^2+y2^2  x2  y2   1 |
| x3^2+y3^2  x3  y3   1 |

To take mutual orientation of points into account:
Det = Det * ((x1-x3)*(y2-y3)-(y1-y3)*(x2-x3))

If Det = 0 then all four points are concyclic (given point lies at the circle border)
if Det < 0 then point is inside
otherwise it is outside the circle

But I suspect that this method may require more mathematical operations then calculation of radius and center point and estimating (x-x0)^2+(y-y0)^2 <= R^2

Addition: It seems that general approach to calculate 4th order determinant is not very effective here: instead use minors of 4th column (Laplace formula here) or one of "alternate forms" from WolphramAlpha output

MBo
  • 77,366
  • 5
  • 53
  • 86
1

If the radii of the inner circle is less then the radii of the outer circle, this means the inner circle is inside the outer circle (in case if you need to test if another circle is inside the outer one).

Here is the formula for the circle:

x = (Math.cos(angle * Math.PI / 180) * radius) + this.centerX;
y = (Math.sin(angle * Math.PI / 180) * radius) + this.centerY; // in radians

You can apply this formula to test if a point is inside of a circle.

To test if two circles intersects you have to see if, the distance between their centers is between the sum and the difference of their radii.

Endre Simo
  • 11,330
  • 2
  • 40
  • 49