Axiom.Math.Plane.GetSide C# (CSharp) Méthode

GetSide() public méthode

Returns the side where the aligneBox is. the flag Both indicates an intersecting box. one corner ON the plane is sufficient to consider the box and the plane intersecting.
public GetSide ( AxisAlignedBox box ) : PlaneSide
box AxisAlignedBox
Résultat PlaneSide
		public PlaneSide GetSide( AxisAlignedBox box )
		{
			if ( box.IsNull )
			{
				return PlaneSide.None;
			}
			if ( box.IsInfinite )
			{
				return PlaneSide.Both;
			}

			return this.GetSide( box.Center, box.HalfSize );
		}

Same methods

Plane::GetSide ( Axiom.Math.Vector3 point ) : PlaneSide
Plane::GetSide ( Axiom.Math.Vector3 centre, Axiom.Math.Vector3 halfSize ) : PlaneSide

Usage Example

        /// <summary>
        ///		Intersection test with an <see cref="AxisAlignedBox"/>.
        /// </summary>
        /// <remarks>
        ///		May return false positives but will never miss an intersection.
        /// </remarks>
        /// <param name="box">Box to test.</param>
        /// <returns>True if interesecting, false otherwise.</returns>
        public bool Intersects(AxisAlignedBox box)
        {
            if (box.IsNull)
            {
                return(false);
            }

            if (box.IsInfinite)
            {
                return(true);
            }

            // Get centre of the box
            Vector3 center = box.Center;
            // Get the half-size of the box
            Vector3 halfSize = box.HalfSize;

            // If all Points are on outside of any plane, we fail
            Vector3[] points = box.Corners;

            for (int i = 0; i < planes.Count; i++)
            {
                Plane plane = (Plane)planes[i];

                PlaneSide side = plane.GetSide(center, halfSize);
                if (side == outside)
                {
                    // Found a splitting plane therefore return not intersecting
                    return(false);
                }
            }

            // couldn't find a splitting plane, assume intersecting
            return(true);
        }