/// <summary> /// Detects a collision between a circle and point /// </summary> /// <param name="c">the circle</param> /// <param name="p">the point</param> /// <returns>true on collision, false otherwise</returns> public static bool Collides(BoundingCircle c, BoundingPoint p) { return(Math.Pow(c.Radius, 2) >= Math.Pow(c.Center.X - p.X, 2) + Math.Pow(c.Center.Y - p.Y, 2)); }
/// <summary> /// Detects a collision between a rectangle and a point /// </summary> /// <param name="r">The rectangle</param> /// <param name="p">The point</param> /// <returns>true on collision, false otherwise</returns> public static bool Collides(BoundingRectangle r, BoundingPoint p) { return(p.X >= r.X && p.X <= r.X + r.Width && p.Y >= r.Y && p.Y <= r.Y + r.Height); }
/// <summary> /// Detects a collision between two points /// </summary> /// <param name="p1">the first point</param> /// <param name="p2">the second point</param> /// <returns>true when colliding, false otherwise</returns> public static bool Collides(BoundingPoint p1, BoundingPoint p2) { return(p1.X == p2.X && p1.Y == p2.Y); }