/// <summary>
 /// Tests for intersection between a <see cref="Sphere"/> and an <see cref="OrientedBox"/> .
 /// </summary>
 /// <param name="sphere">A <see cref="Sphere"/> instance.</param>
 /// <param name="box">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>An <see cref="IntersectionType"/> value.</returns>
 public static IntersectionType Intersects(Sphere sphere, OrientedBox box)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
 /// <summary>
 /// Tests for intersection between a <see cref="Ray"/> and an <see cref="OrientedBox">oriented box</see>.
 /// </summary>
 /// <param name="ray">A <see cref="Ray"/> instance.</param>
 /// <param name="obb">A <see cref="OrientedBox"/> instance.</param>
 /// <returns>An <see cref="IntersectionPair"/> instance containing the intersection information.</returns>
 public static IntersectionPair Intersects(Ray ray, OrientedBox obb)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
 /// <summary>
 /// Tests for intersection between an <see cref="AxisAlignedBox"/> and an <see cref="OrientedBox"/> .
 /// </summary>
 /// <param name="box1">An <see cref="AxisAlignedBox"/> instance.</param>
 /// <param name="box2">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>An <see cref="IntersectionType"/> value.</returns>
 public static IntersectionType Intersects(AxisAlignedBox box1, OrientedBox box2)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
 /// <summary>
 /// Calculates the distance between a point and a solid oriented box.
 /// </summary>
 /// <param name="point">A <see cref="Vector3F"/> instance.</param>
 /// <param name="obb">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>The distance between a point and a solid oriented box.</returns>
 /// <remarks>
 /// Treating the oriented box as solid means that any point inside the box has
 /// distance zero from the box.
 /// </remarks>
 public static float Distance(Vector3F point, OrientedBox obb)
 {
     return (float)System.Math.Sqrt(SquaredDistance(point, obb));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OrientedBox"/> class using given values from another box instance.
        /// </summary>
        /// <param name="box">A <see cref="OrientedBox"/> instance to take values from.</param>
        public OrientedBox(OrientedBox box)
        {
            _center = box.Center;

            _axis1 = box.Axis1;
            _axis2 = box.Axis2;
            _axis3 = box.Axis3;

            _extent1 = box.Extent1;
            _extent2 = box.Extent2;
            _extent3 = box.Extent3;
        }
 /// <summary>
 /// Calculates the squared distance between a point and a solid oriented box.
 /// </summary>
 /// <param name="point">A <see cref="Vector3F"/> instance.</param>
 /// <param name="obb">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>The squared distance between a point and a solid oriented box.</returns>
 /// <remarks>
 /// Treating the oriented box as solid means that any point inside the box has
 /// distance zero from the box.
 /// </remarks>
 public static float SquaredDistance(Vector3F point, OrientedBox obb)
 {
     Vector3F temp;
     return SquaredDistancePointSolidOrientedBox(point, obb, out temp);
 }
        /// <summary>
        /// Calculates the squared distance between a point and a solid oriented box.
        /// </summary>
        /// <param name="point">A <see cref="Vector3F"/> instance.</param>
        /// <param name="obb">An <see cref="OrientedBox"/> instance.</param>
        /// <param name="closestPoint">The closest point in box coordinates.</param>
        /// <returns>The squared distance between a point and a solid oriented box.</returns>
        /// <remarks>
        /// Treating the oriented box as solid means that any point inside the box has
        /// distance zero from the box.
        /// </remarks>
        public static float SquaredDistancePointSolidOrientedBox(Vector3F point, OrientedBox obb, out Vector3F closestPoint)
        {
            Vector3F diff = point - obb.Center;
            Vector3F closest = new Vector3F(
                Vector3F.Dot(diff, obb.Axis1),
                Vector3F.Dot(diff, obb.Axis2),
                Vector3F.Dot(diff, obb.Axis3));

            float sqrDist = 0.0f;
            float delta	  = 0.0f;

            if (closest.X < -obb.Extent1)
            {
                delta = closest.X + obb.Extent1;
                sqrDist += delta*delta;
                closest.X = -obb.Extent1;
            }
            else if (closest.X > obb.Extent1)
            {
                delta = closest.X - obb.Extent1;
                sqrDist += delta*delta;
                closest.X = obb.Extent1;
            }

            if (closest.Y < -obb.Extent2)
            {
                delta = closest.Y + obb.Extent2;
                sqrDist += delta*delta;
                closest.Y = -obb.Extent2;
            }
            else if (closest.Y > obb.Extent2)
            {
                delta = closest.Y - obb.Extent2;
                sqrDist += delta*delta;
                closest.Y = obb.Extent2;
            }

            if (closest.Z < -obb.Extent3)
            {
                delta = closest.Z + obb.Extent3;
                sqrDist += delta*delta;
                closest.Z = -obb.Extent3;
            }
            else if (closest.Z > obb.Extent3)
            {
                delta = closest.Z - obb.Extent3;
                sqrDist += delta*delta;
                closest.Z = obb.Extent3;
            }

            closestPoint = closest;

            return sqrDist;
        }
Example #8
0
 /// <summary>
 /// Tests for intersection between a <see cref="Sphere"/> and an <see cref="OrientedBox"/> .
 /// </summary>
 /// <param name="sphere">A <see cref="Sphere"/> instance.</param>
 /// <param name="box">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>An <see cref="IntersectionType"/> value.</returns>
 public static IntersectionType Intersects(Sphere sphere, OrientedBox box)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
Example #9
0
 /// <summary>
 /// Tests for intersection between an <see cref="AxisAlignedBox"/> and an <see cref="OrientedBox"/> .
 /// </summary>
 /// <param name="box1">An <see cref="AxisAlignedBox"/> instance.</param>
 /// <param name="box2">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>An <see cref="IntersectionType"/> value.</returns>
 public static IntersectionType Intersects(AxisAlignedBox box1, OrientedBox box2)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
Example #10
0
 /// <summary>
 /// Tests for intersection between a <see cref="Ray"/> and an <see cref="OrientedBox">oriented box</see>.
 /// </summary>
 /// <param name="ray">A <see cref="Ray"/> instance.</param>
 /// <param name="obb">A <see cref="OrientedBox"/> instance.</param>
 /// <returns>An <see cref="IntersectionPair"/> instance containing the intersection information.</returns>
 public static IntersectionPair Intersects(Ray ray, OrientedBox obb)
 {
     // TODO: Implement this.
     throw new NotImplementedException();
 }
Example #11
0
 /// <summary>
 /// Calculates the distance between a point and a solid oriented box.
 /// </summary>
 /// <param name="point">A <see cref="Vector3F"/> instance.</param>
 /// <param name="obb">An <see cref="OrientedBox"/> instance.</param>
 /// <returns>The distance between a point and a solid oriented box.</returns>
 /// <remarks>
 /// Treating the oriented box as solid means that any point inside the box has
 /// distance zero from the box.
 /// </remarks>
 public static float Distance(Vector3F point, OrientedBox obb)
 {
     return((float)System.Math.Sqrt(SquaredDistance(point, obb)));
 }
Example #12
0
        /// <summary>
        /// Calculates the squared distance between a point and a solid oriented box.
        /// </summary>
        /// <param name="point">A <see cref="Vector3F"/> instance.</param>
        /// <param name="obb">An <see cref="OrientedBox"/> instance.</param>
        /// <returns>The squared distance between a point and a solid oriented box.</returns>
        /// <remarks>
        /// Treating the oriented box as solid means that any point inside the box has
        /// distance zero from the box.
        /// </remarks>
        public static float SquaredDistance(Vector3F point, OrientedBox obb)
        {
            Vector3F temp;

            return(SquaredDistancePointSolidOrientedBox(point, obb, out temp));
        }