Пример #1
0
        public void BoundingBoxIntersectKeen()
        {
            var point  = new VRageMath.Vector3D(5d, 3.5d, 4d);
            var vector = new VRageMath.Vector3D(-0.03598167d, 0.0110336d, 0.9992915d);
            var box    = new VRageMath.BoundingBoxD(new VRageMath.Vector3D(3d, 3d, 2d), new VRageMath.Vector3D(7d, 4d, 6d));
            var ray    = new VRageMath.RayD(point, vector);

            double?f = box.Intersects(ray);

            Assert.AreEqual(0, f, "Should Equal");
        }
Пример #2
0
        /// <summary>
        /// Checks whether the current BoundingFrustumD contains the specified BoundingBoxD.
        /// </summary>
        /// <param name="box">The BoundingBoxD to check against the current BoundingFrustumD.</param>
        public ContainmentType Contains(BoundingBoxD box)
        {
            bool flag = false;

            foreach (PlaneD plane in this.planes)
            {
                switch (box.Intersects(plane))
                {
                case PlaneIntersectionType.Front:
                    return(ContainmentType.Disjoint);

                case PlaneIntersectionType.Intersecting:
                    flag = true;
                    break;
                }
            }
            return(!flag ? ContainmentType.Contains : ContainmentType.Intersects);
        }
Пример #3
0
        /// <summary>
        /// Checks whether the current BoundingFrustumD contains the specified BoundingBoxD.
        /// </summary>
        /// <param name="box">The BoundingBoxD to test for overlap.</param><param name="result">[OutAttribute] Enumeration indicating the extent of overlap.</param>
        public void Contains(ref BoundingBoxD box, out ContainmentType result)
        {
            bool flag = false;

            foreach (PlaneD plane in this.planes)
            {
                switch (box.Intersects(plane))
                {
                case PlaneIntersectionType.Front:
                    result = ContainmentType.Disjoint;
                    return;

                case PlaneIntersectionType.Intersecting:
                    flag = true;
                    break;
                }
            }
            result = flag ? ContainmentType.Intersects : ContainmentType.Contains;
        }
Пример #4
0
        /// <summary>
        /// Checks whether the current BoundingSphereD contains the specified BoundingBoxD.
        /// </summary>
        /// <param name="box">The BoundingBoxD to test for overlap.</param><param name="result">[OutAttribute] Enumeration indicating the extent of overlap.</param>
        public void Contains(ref BoundingBoxD box, out ContainmentType result)
        {
            bool result1;

            box.Intersects(ref this, out result1);
            if (!result1)
            {
                result = ContainmentType.Disjoint;
            }
            else
            {
                double num = this.Radius * this.Radius;
                result = ContainmentType.Intersects;
                Vector3D Vector3D;
                Vector3D.X = this.Center.X - box.Min.X;
                Vector3D.Y = this.Center.Y - box.Max.Y;
                Vector3D.Z = this.Center.Z - box.Max.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Max.X;
                Vector3D.Y = this.Center.Y - box.Max.Y;
                Vector3D.Z = this.Center.Z - box.Max.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Max.X;
                Vector3D.Y = this.Center.Y - box.Min.Y;
                Vector3D.Z = this.Center.Z - box.Max.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Min.X;
                Vector3D.Y = this.Center.Y - box.Min.Y;
                Vector3D.Z = this.Center.Z - box.Max.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Min.X;
                Vector3D.Y = this.Center.Y - box.Max.Y;
                Vector3D.Z = this.Center.Z - box.Min.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Max.X;
                Vector3D.Y = this.Center.Y - box.Max.Y;
                Vector3D.Z = this.Center.Z - box.Min.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Max.X;
                Vector3D.Y = this.Center.Y - box.Min.Y;
                Vector3D.Z = this.Center.Z - box.Min.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                Vector3D.X = this.Center.X - box.Min.X;
                Vector3D.Y = this.Center.Y - box.Min.Y;
                Vector3D.Z = this.Center.Z - box.Min.Z;
                if ((double)Vector3D.LengthSquared() > (double)num)
                {
                    return;
                }
                result = ContainmentType.Contains;
            }
        }
Пример #5
0
        /// <summary>
        /// Checks whether the current BoundingSphereD contains the specified BoundingBoxD.
        /// </summary>
        /// <param name="box">The BoundingBoxD to check against the current BoundingSphereD.</param>
        public ContainmentType Contains(BoundingBoxD box)
        {
            if (!box.Intersects(this))
            {
                return(ContainmentType.Disjoint);
            }
            double   num = this.Radius * this.Radius;
            Vector3D Vector3D;

            Vector3D.X = this.Center.X - box.Min.X;
            Vector3D.Y = this.Center.Y - box.Max.Y;
            Vector3D.Z = this.Center.Z - box.Max.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Max.X;
            Vector3D.Y = this.Center.Y - box.Max.Y;
            Vector3D.Z = this.Center.Z - box.Max.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Max.X;
            Vector3D.Y = this.Center.Y - box.Min.Y;
            Vector3D.Z = this.Center.Z - box.Max.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Min.X;
            Vector3D.Y = this.Center.Y - box.Min.Y;
            Vector3D.Z = this.Center.Z - box.Max.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Min.X;
            Vector3D.Y = this.Center.Y - box.Max.Y;
            Vector3D.Z = this.Center.Z - box.Min.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Max.X;
            Vector3D.Y = this.Center.Y - box.Max.Y;
            Vector3D.Z = this.Center.Z - box.Min.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Max.X;
            Vector3D.Y = this.Center.Y - box.Min.Y;
            Vector3D.Z = this.Center.Z - box.Min.Z;
            if ((double)Vector3D.LengthSquared() > (double)num)
            {
                return(ContainmentType.Intersects);
            }
            Vector3D.X = this.Center.X - box.Min.X;
            Vector3D.Y = this.Center.Y - box.Min.Y;
            Vector3D.Z = this.Center.Z - box.Min.Z;
            return((double)Vector3D.LengthSquared() > (double)num ? ContainmentType.Intersects : ContainmentType.Contains);
        }
Пример #6
0
        public void BoundingBoxIntersectKeen()
        {
            var point = new VRageMath.Vector3D(5d, 3.5d, 4d);
            var vector = new VRageMath.Vector3D(-0.03598167d, 0.0110336d, 0.9992915d);
            var box = new VRageMath.BoundingBoxD(new VRageMath.Vector3D(3d, 3d, 2d), new VRageMath.Vector3D(7d, 4d, 6d));
            var ray = new VRageMath.RayD(point, vector);

            double? f = box.Intersects(ray);

            Assert.AreEqual(0, f, "Should Equal");
        }
Пример #7
0
 /// <summary>
 /// Checks whether the current Ray intersects a BoundingBox.
 /// </summary>
 /// <param name="box">The BoundingBox to check for intersection with.</param><param name="result">[OutAttribute] Distance at which the ray intersects the BoundingBox or null if there is no intersection.</param>
 public void Intersects(ref BoundingBoxD box, out double?result)
 {
     box.Intersects(ref this, out result);
 }
Пример #8
0
 /// <summary>
 /// Checks whether the Ray intersects a specified BoundingBox.
 /// </summary>
 /// <param name="box">The BoundingBox to check for intersection with the Ray.</param>
 public double?Intersects(BoundingBoxD box)
 {
     return(box.Intersects(this));
 }
Пример #9
0
        public void Contains(ref BoundingBoxD box, out ContainmentType result)
        {
            bool flag;

            box.Intersects(ref this, out flag);
            if (!flag)
            {
                result = ContainmentType.Disjoint;
            }
            else
            {
                Vector3D vectord;
                double   num = this.Radius * this.Radius;
                result    = ContainmentType.Intersects;
                vectord.X = this.Center.X - box.Min.X;
                vectord.Y = this.Center.Y - box.Max.Y;
                vectord.Z = this.Center.Z - box.Max.Z;
                if (vectord.LengthSquared() <= num)
                {
                    vectord.X = this.Center.X - box.Max.X;
                    vectord.Y = this.Center.Y - box.Max.Y;
                    vectord.Z = this.Center.Z - box.Max.Z;
                    if (vectord.LengthSquared() <= num)
                    {
                        vectord.X = this.Center.X - box.Max.X;
                        vectord.Y = this.Center.Y - box.Min.Y;
                        vectord.Z = this.Center.Z - box.Max.Z;
                        if (vectord.LengthSquared() <= num)
                        {
                            vectord.X = this.Center.X - box.Min.X;
                            vectord.Y = this.Center.Y - box.Min.Y;
                            vectord.Z = this.Center.Z - box.Max.Z;
                            if (vectord.LengthSquared() <= num)
                            {
                                vectord.X = this.Center.X - box.Min.X;
                                vectord.Y = this.Center.Y - box.Max.Y;
                                vectord.Z = this.Center.Z - box.Min.Z;
                                if (vectord.LengthSquared() <= num)
                                {
                                    vectord.X = this.Center.X - box.Max.X;
                                    vectord.Y = this.Center.Y - box.Max.Y;
                                    vectord.Z = this.Center.Z - box.Min.Z;
                                    if (vectord.LengthSquared() <= num)
                                    {
                                        vectord.X = this.Center.X - box.Max.X;
                                        vectord.Y = this.Center.Y - box.Min.Y;
                                        vectord.Z = this.Center.Z - box.Min.Z;
                                        if (vectord.LengthSquared() <= num)
                                        {
                                            vectord.X = this.Center.X - box.Min.X;
                                            vectord.Y = this.Center.Y - box.Min.Y;
                                            vectord.Z = this.Center.Z - box.Min.Z;
                                            if (vectord.LengthSquared() <= num)
                                            {
                                                result = ContainmentType.Contains;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #10
0
        public ContainmentType Contains(BoundingBoxD box)
        {
            Vector3D vectord;

            if (!box.Intersects(this))
            {
                return(ContainmentType.Disjoint);
            }
            double num = this.Radius * this.Radius;

            vectord.X = this.Center.X - box.Min.X;
            vectord.Y = this.Center.Y - box.Max.Y;
            vectord.Z = this.Center.Z - box.Max.Z;
            if (vectord.LengthSquared() <= num)
            {
                vectord.X = this.Center.X - box.Max.X;
                vectord.Y = this.Center.Y - box.Max.Y;
                vectord.Z = this.Center.Z - box.Max.Z;
                if (vectord.LengthSquared() > num)
                {
                    return(ContainmentType.Intersects);
                }
                vectord.X = this.Center.X - box.Max.X;
                vectord.Y = this.Center.Y - box.Min.Y;
                vectord.Z = this.Center.Z - box.Max.Z;
                if (vectord.LengthSquared() > num)
                {
                    return(ContainmentType.Intersects);
                }
                vectord.X = this.Center.X - box.Min.X;
                vectord.Y = this.Center.Y - box.Min.Y;
                vectord.Z = this.Center.Z - box.Max.Z;
                if (vectord.LengthSquared() > num)
                {
                    return(ContainmentType.Intersects);
                }
                vectord.X = this.Center.X - box.Min.X;
                vectord.Y = this.Center.Y - box.Max.Y;
                vectord.Z = this.Center.Z - box.Min.Z;
                if (vectord.LengthSquared() > num)
                {
                    return(ContainmentType.Intersects);
                }
                vectord.X = this.Center.X - box.Max.X;
                vectord.Y = this.Center.Y - box.Max.Y;
                vectord.Z = this.Center.Z - box.Min.Z;
                if (vectord.LengthSquared() > num)
                {
                    return(ContainmentType.Intersects);
                }
                vectord.X = this.Center.X - box.Max.X;
                vectord.Y = this.Center.Y - box.Min.Y;
                vectord.Z = this.Center.Z - box.Min.Z;
                if (vectord.LengthSquared() > num)
                {
                    return(ContainmentType.Intersects);
                }
                vectord.X = this.Center.X - box.Min.X;
                vectord.Y = this.Center.Y - box.Min.Y;
                vectord.Z = this.Center.Z - box.Min.Z;
                if (vectord.LengthSquared() <= num)
                {
                    return(ContainmentType.Contains);
                }
            }
            return(ContainmentType.Intersects);
        }
Пример #11
0
 public double?Intersects(BoundingBoxD box) =>
 box.Intersects(this);