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); } }
public float?Intersects(BoundingCircle circle) { float?result; Intersects(ref circle, out result); return(result); }
public Vector2 Distance(BoundingCircle circle) { return(PointToLine(Min, Max, circle.Center)); }
public bool Intersects(BoundingCircle circle) { float totalRadius = Radius + circle.Radius; return(Distance(circle).LengthSquared() < totalRadius * totalRadius); }
public bool Intersects(BoundingCircle value) { float totalRadius = value.Radius + Radius; return(Vector2.DistanceSquared(value.Center, Center) < totalRadius * totalRadius); }
public bool Intersects(BoundingCircle circle) { float totalRadius = Radius + circle.Radius; return Distance(circle).LengthSquared() < totalRadius * totalRadius; }
public Vector2 Distance(BoundingCircle circle) { return PointToLine(Min, Max, circle.Center); }
public bool Intersects(BoundingCircle value) { float totalRadius = value.Radius + Radius; return Vector2.DistanceSquared(value.Center, Center) < totalRadius * totalRadius; }