public static Sphere CreateFromPoints(Vector3[] points) { Sphere sphere = new Sphere(); AABB3D box = AABB3D.CreateFromPoints(points); sphere.Pos = box.Pos; float maxDist = float.MinValue; for (int i = 0; i < points.Length; i++) { if ((points[i] - sphere.Pos).LengthSquared() > maxDist) { maxDist = (points[i] - sphere.Pos).LengthSquared(); } } maxDist = (float)Math.Sqrt(maxDist); sphere.Radius = maxDist; return sphere; }
public static AABB3D CreateFromSphere(Sphere s) { return new AABB3D(s.Pos, new Vector3(s.Radius, s.Radius, s.Radius)); }