• Main Page
  • Packages
  • Classes
  • Files
  • File List

C:/Doug/CSharp/XnaCollisionLib/XnaCollisionLib/CollisionHelper.cs

Go to the documentation of this file.
00001 using System;
00002 using Microsoft.Xna.Framework;
00003 
00004 namespace XnaCollisionLib
00005 {
00006     public class CollisionHelper
00007     {
00008         public static void AddToBox(ref BoundingBox box, Vector3 point)
00009         {
00010             if (point.X < box.Min.X)
00011                 box.Min.X = point.X;
00012             if (point.X > box.Max.X)
00013                 box.Max.X = point.X;
00014 
00015             if (point.Y < box.Min.Y)
00016                 box.Min.Y = point.Y;
00017             if (point.Y > box.Max.Y)
00018                 box.Max.Y = point.Y;
00019 
00020             if (point.Z < box.Min.Z)
00021                 box.Min.Z = point.Z;
00022             if (point.Z > box.Max.Z)
00023                 box.Max.Z = point.Z;
00024         }
00025 
00026         public static bool IsZero(float value)
00027         {
00028             return Math.Abs(value) < 0.000001f;
00029         }
00030 
00031         public static float Reciprocal(float value)
00032         {
00033             return 1.0f / value;
00034         }
00035 
00036         public static float Clamp(float value, float low, float high)
00037         {
00038             if (value < low)
00039                 value = low;
00040             if (value > high)
00041                 value = high;
00042             return value;
00043         }
00044 
00045         public static float DistanceTo(Plane plane, Vector3 point)
00046         {
00047             return Vector3.Dot(plane.Normal, point) + plane.D;
00048         }
00049 
00050         public static Plane CreatePlane(Vector3 normal, Vector3 origin)
00051         {
00052             return new Plane(normal, -Vector3.Dot(normal, origin));
00053         }
00054     }
00055 }

Generated on Thu Jul 15 2010 19:56:39 for XnaCollisionLib by  doxygen 1.7.0