Example #1
0
 /// <summary>
 /// Check for a collision between a LineSegmentCollider and a CircleCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(LineSegmentCollider self, CircleCollider other)
 {
     return(Collision(other, self));
 }
Example #2
0
 public static bool Collision(CircleCollider self, RayCollider other)
 {
     return(GeometryUtils.CircleToRayPOI(
                self.x, self.y, self.radius, other.x1, other.y1, other.x2, other.y2).Length > 0);
 }
Example #3
0
 /// <summary>
 /// Check for a collision between a RayCollider and a CircleCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(RayCollider self, CircleCollider other)
 {
     return(Collision(other, self));
 }
Example #4
0
 /// <summary>
 /// Check for a collision between a ParticleCollider and a CircleCollider.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static bool Collision(ParticleCollider self, CircleCollider other)
 {
     return Collision(other, self);
 }
Example #5
0
 public static bool Collision(CircleCollider self, CircleCollider other)
 {
     Vector2 center1 = new Vector2((float)self.x, (float)self.y);
     Vector2 center2 = new Vector2((float)other.x, (float)other.y);
     return Vector2.Distance(center1, center2) < self.radius + other.radius;
 }
Example #6
0
        public static bool Collision(CircleCollider self, RectCollider other)
        {
            double cx = self.x, cy = self.y, r = self.radius;
            double x = other.x, y = other.y, w = other.width, h = other.height;
            double rx = x + w / 2, ry = y + h / 2;
            double x_offset = Math.Abs(cx - rx);
            double y_offset = Math.Abs(cy - ry);
            double half_width = w / 2;
            double half_height = h / 2;

            if (x_offset > (half_width + r))
                return false;
            else if (y_offset > (half_height + r))
                return false;

            if (x_offset <= half_width)
                return true;
            else if (y_offset <= half_height)
                return true;

            double deltax = x_offset - half_width;
            double deltay = y_offset - half_height;
            double dist = Math.Pow(deltax, 2) + Math.Pow(deltay, 2);
            return dist <= r * r ? true : false;
        }
Example #7
0
 public static bool Collision(CircleCollider self, RayCollider other)
 {
     return GeometryUtils.CircleToRayPOI(
         self.x, self.y, self.radius, other.x1, other.y1, other.x2, other.y2).Length > 0;
 }
Example #8
0
 public static bool Collision(CircleCollider self, ParticleCollider other)
 {
     Vector2 center = new Vector2((float)self.x, (float)self.y);
     Vector2 particle = new Vector2((float)other.x, (float)other.y);
     return Vector2.Distance(center, particle) < self.radius;
 }