Exemplo n.º 1
0
        /// <summary>
        /// Test whether a <see cref="OBBd"/> intersects this plane.
        /// See: Ericson 2005, Real Time Collision Detection, p. 161 - 164
        /// </summary>
        /// <param name="obb">The axis aligned bounding box.</param>
        public bool Intersects(OBBd obb)
        {
            var r = BoxExtendInNormalDirection(obb);
            var s = SignedDistanceFromPoint(obb.Center);

            return(System.Math.Abs(s) <= r);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the projection interval radius of obb onto line L(t) = aabb.Center + t * plane.Normal (extend (radius) in direction of the plane normal).
        /// <param name="obb">The object oriented bounding box.</param>
        ///</summary>
        private double BoxExtendInNormalDirection(OBBd obb)
        {
            var transformationMat = obb.Rotation * double4x4.CreateTranslation(obb.Translation); //without scale!

            var xAxis = (double3.UnitX * transformationMat).Normalize();
            var yAxis = (double3.UnitY * transformationMat).Normalize();
            var zAxis = (double3.UnitZ * transformationMat).Normalize();

            var boxExtend = obb.Size * 0.5f;

            return(boxExtend.x * System.Math.Abs(double3.Dot(Normal, xAxis)) +
                   boxExtend.y * System.Math.Abs(double3.Dot(Normal, yAxis)) +
                   boxExtend.z * System.Math.Abs(double3.Dot(Normal, zAxis)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Test whether a <see cref="OBBd"/> intersects this plane.
        /// See: Ericson 2005, Real Time Collision Detection, p. 161 - 164
        /// CAREFUL: the definition whats completely inside and outside is flipped in comparison to Ericson,
        /// because FUSEE defines a point with a negative signed distance to be inside.
        /// </summary>
        /// <param name="obb">The object oriented bounding box.</param>
        public bool InsideOrIntersecting(OBBd obb)
        {
            var r = BoxExtendInNormalDirection(obb);
            //Distance from obb center to plane
            var s = SignedDistanceFromPoint(obb.Center);

            //Completely outside
            if (s <= -r)
            {
                return(true);
            }
            //Completely inside
            else if (r <= s)
            {
                return(false);
            }
            //else intersecting
            return(true);
        }