コード例 #1
0
        public static BoundingBox CreateFromPoints(IEnumerable <Vector3> points)
        {
            if (points == null)
            {
                throw new ArgumentNullException();
            }

            // TODO: Just check that Count > 0
            bool    empty   = true;
            Vector3 vector2 = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            Vector3 vector1 = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            foreach (Vector3 vector3 in points)
            {
                vector2 = Vector3Extensions.Min(vector2, vector3);
                vector1 = Vector3Extensions.Max(vector1, vector3);
                empty   = false;
            }
            if (empty)
            {
                throw new ArgumentException();
            }

            return(new BoundingBox(vector2, vector1));
        }
コード例 #2
0
 public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional)
 {
     return(new BoundingBox(
                Vector3Extensions.Min(original.Min, additional.Min), Vector3Extensions.Max(original.Max, additional.Max)));
 }