///Returns whether a point lies in a circle (excludes being on the perimeter) public static bool PointInCircle(Vector2 p, Circle c) { //if the distance from p and the center of the circle is less than the radius then p is within the circle return(Vector2.Distance(p, c.WorldCenter) < c.GetRadius()); }
///Returns whether a point lies on the perimeter of a circle public static bool PointOnCirclePerimeter(Vector2 p, Circle c) { //if the distance from p and the center of the circle is equal to the circle's radius then p is on the perimeter return(Mathf.Approximately(Vector2.Distance(p, c.WorldCenter), c.GetRadius())); }
/* Circle methods */ #region ///Returns whether two circles intersect public static bool CircleIntersectsCircle(Circle c1, Circle c2) { //if the distance between the center of each circle adds up to less than the sum of the radii then they intersect return(Vector2.Distance(c1.WorldCenter, c2.WorldCenter) < c1.GetRadius() + c2.GetRadius()); }