示例#1
0
        public void Intersects(ref BoundingCircle circle, out float?result)
        {
            Vector2 d = Direction;
            Vector2 f = Position - circle.Center;

            float a = Vector2.Dot(d, d);
            float b = Vector2.Dot(f, d) * 2;
            float c = Vector2.Dot(f, f) - circle.Radius * circle.Radius;

            float discriminant = b * b - 4 * a * c;

            if (discriminant < 0)
            {
                // No intersection.
                result = null;
            }
            else
            {
                // Ray didn't totally miss circle,
                // so there is a solution to
                // the equation.

                discriminant = (float)Math.Sqrt(discriminant);

                result = (-b - discriminant) / (2 * a);
            }
        }
示例#2
0
        public float?Intersects(BoundingCircle circle)
        {
            float?result;

            Intersects(ref circle, out result);
            return(result);
        }
示例#3
0
 public Vector2 Distance(BoundingCircle circle)
 {
     return(PointToLine(Min, Max, circle.Center));
 }
示例#4
0
        public bool Intersects(BoundingCircle circle)
        {
            float totalRadius = Radius + circle.Radius;

            return(Distance(circle).LengthSquared() < totalRadius * totalRadius);
        }
示例#5
0
        public bool Intersects(BoundingCircle value)
        {
            float totalRadius = value.Radius + Radius;

            return(Vector2.DistanceSquared(value.Center, Center) < totalRadius * totalRadius);
        }
示例#6
0
 public bool Intersects(BoundingCircle circle)
 {
     float totalRadius = Radius + circle.Radius;
     return Distance(circle).LengthSquared() < totalRadius * totalRadius;
 }
示例#7
0
 public Vector2 Distance(BoundingCircle circle)
 {
     return PointToLine(Min, Max, circle.Center);
 }
示例#8
0
 public bool Intersects(BoundingCircle value)
 {
     float totalRadius = value.Radius + Radius;
     return Vector2.DistanceSquared(value.Center, Center) < totalRadius * totalRadius;
 }