Example #1
0
        /// <summary>
        /// Creates and initializes a new instance from the given Box and Sphere.
        /// </summary>
        /// <param name="box">The bounding box.</param>
        /// <param name="sphere">The bounding sphere.</param>
        public FBoxSphereBounds(FBox box, FSphere sphere)
        {
            box.GetCenterAndExtents(out Origin, out BoxExtent);
            SphereRadius = FMath.Min(BoxExtent.Size(), (sphere.Center - Origin).Size() + sphere.W);

            DiagnosticCheckNaN();
        }
Example #2
0
        /// <summary>
        /// Creates and initializes a new instance the given Box.
        ///
        /// The sphere radius is taken from the extent of the box.
        /// </summary>
        /// <param name="box">The bounding box.</param>
        public FBoxSphereBounds(FBox box)
        {
            box.GetCenterAndExtents(out Origin, out BoxExtent);
            SphereRadius = BoxExtent.Size();

            DiagnosticCheckNaN();
        }
Example #3
0
        /// <summary>
        /// Creates and initializes a new instance from the given set of points.
        ///
        /// The sphere radius is taken from the extent of the box.
        /// </summary>
        /// <param name="points">The points to be considered for the bounding box.</param>
        public FBoxSphereBounds(FVector[] points)
        {
            FBox boundingBox = new FBox();

            // find an axis aligned bounding box for the points.
            for (uint pointIndex = 0; pointIndex < points.Length; pointIndex++)
            {
                boundingBox += points[pointIndex];
            }

            boundingBox.GetCenterAndExtents(out Origin, out BoxExtent);

            // using the center of the bounding box as the origin of the sphere, find the radius of the bounding sphere.
            SphereRadius = 0.0f;

            for (uint pointIndex = 0; pointIndex < points.Length; pointIndex++)
            {
                SphereRadius = FMath.Max(SphereRadius, (points[pointIndex] - Origin).Size());
            }

            DiagnosticCheckNaN();
        }