public bool Intersects(BoundingSphere sphere) { float val = Vector3Extensions.Distance(sphere.Center, Center); if (val > sphere.Radius + Radius) { return(false); } return(true); }
public static BoundingSphere CreateFromBoundingBox(BoundingBox box) { // Find the center of the box. Vector3 center = new Vector3((box.Min.X + box.Max.X) / 2.0f, (box.Min.Y + box.Max.Y) / 2.0f, (box.Min.Z + box.Max.Z) / 2.0f); // Find the distance between the center and one of the corners of the box. float radius = Vector3Extensions.Distance(center, box.Max); return(new BoundingSphere(center, radius)); }
public ContainmentType Contains(Vector3 point) { float distance = Vector3Extensions.Distance(point, Center); if (distance > this.Radius) { return(ContainmentType.Disjoint); } else if (distance < this.Radius) { return(ContainmentType.Contains); } return(ContainmentType.Intersects); }
public ContainmentType Contains(BoundingSphere sphere) { float val = Vector3Extensions.Distance(sphere.Center, Center); if (val > sphere.Radius + Radius) { return(ContainmentType.Disjoint); } else if (val <= Radius - sphere.Radius) { return(ContainmentType.Contains); } else { return(ContainmentType.Intersects); } }