Пример #1
0
        public static bool Overlap(LineF line, CircleF p)
        {
            var apX = p.Point.X - line.Start.X;
            var apY = p.Point.Y - line.Start.Y;
            var abX = line.End.X - line.Start.X;
            var abY = line.End.Y - line.Start.Y;

            var abLength = (abX * abX + abY * abY);

            var dot = apX * abX + apY * abY;

            var t = dot / abLength;

            if (t <= 0)
                return ((apX * apX) + (apY * apY) < p.Radius * p.Radius);
            else if (t >= 1)
                return ((line.End.X - p.Point.X) * (line.End.X - p.Point.X) + (line.End.Y - p.Point.Y) * (line.End.Y - p.Point.Y) < p.Radius * p.Radius);
            else
                return ((apX - abX * t) * (apX - abX * t) + (apY - abY * t) * (apY - abY * t) < p.Radius * p.Radius);
        }
Пример #2
0
 public bool Overlap(CircleF circle)
 {
     return Overlap(this, circle);
 }
Пример #3
0
 public bool Overlap(CircleF circle)
 {
     return(Overlap(this, circle.Point, circle.Radius));
 }
Пример #4
0
 public bool Overlap(CircleF circle)
 {
     return Overlap(this, circle.Point, circle.Radius);
 }
Пример #5
0
 public static bool Overlap(CircleF circle, Vector2 p, float raduis)
 {
     return Vector2.DistanceSquared(circle.Point, p) < (circle.Radius + raduis) * (circle.Radius + raduis);
 }
Пример #6
0
 public bool Overlap(CircleF circle)
 {
     return(Overlap(this, circle));
 }
Пример #7
0
 public static bool Overlap(CircleF circle, Vector2 p, float raduis)
 {
     return(Vector2.DistanceSquared(circle.Point, p) < (circle.Radius + raduis) * (circle.Radius + raduis));
 }