Пример #1
0
        /// <summary>
        ///     Creates a new bounding boxes from two bounding boxes
        /// </summary>
        /// <param name="box"></param>
        /// <param name="box2"></param>
        /// <returns></returns>
        public static BBox Union(BBox box, BBox box2)
        {
            var ret = new BBox
            {
                PMin =
                {
                    X = Math.Min(box.PMin.X, box2.PMin.X),
                    Y = Math.Min(box.PMin.Y, box2.PMin.Y),
                    Z = Math.Min(box.PMin.Z, box2.PMin.Z)
                },
                PMax =
                {
                    X = Math.Max(box.PMax.X, box2.PMax.X),
                    Y = Math.Max(box.PMax.Y, box2.PMax.Y),
                    Z = Math.Max(box.PMax.Z, box2.PMax.Z)
                }
            };

            return(ret);
        }
Пример #2
0
        /// <summary>
        ///     Adds a point to the bounding box, recalculating it.
        /// </summary>
        /// <param name="box"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        public static BBox Union(BBox box, Vector3 point)
        {
            var ret = new BBox
            {
                PMin =
                {
                    X = Math.Min(box.PMin.X, point.X),
                    Y = Math.Min(box.PMin.Y, point.Y),
                    Z = Math.Min(box.PMin.Z, point.Z)
                },
                PMax =
                {
                    X = Math.Max(box.PMax.X, point.X),
                    Y = Math.Max(box.PMax.Y, point.Y),
                    Z = Math.Max(box.PMax.Z, point.Z)
                }
            };

            return(ret);
        }