BEPUutilities.Toolbox.GetRayPlaneIntersection C# (CSharp) Метод

GetRayPlaneIntersection() публичный статический Метод

Finds the intersection between the given ray and the given plane.
public static GetRayPlaneIntersection ( BEPUutilities.Ray &ray, BEPUutilities.Plane &p, float &t, System.Vector3 &q ) : bool
ray BEPUutilities.Ray Ray to test against the plane.
p BEPUutilities.Plane Plane for comparison.
t float Interval along line to intersection (A + t * AB).
q System.Vector3 Intersection point.
Результат bool
        public static bool GetRayPlaneIntersection(ref Ray ray, ref Plane p, out float t, out Vector3 q)
        {
            float denominator;
            Vector3.Dot(ref p.Normal, ref ray.Direction, out denominator);
            if (denominator < Epsilon && denominator > -Epsilon)
            {
                //Surface of plane and line are parallel (or very close to it).
                q = new Vector3();
                t = float.MaxValue;
                return false;
            }
            float numerator;
            Vector3.Dot(ref p.Normal, ref ray.Position, out numerator);
            t = (p.D - numerator) / denominator;
            //Compute the intersection position.
            Vector3.Multiply(ref ray.Direction, t, out q);
            Vector3.Add(ref ray.Position, ref q, out q);
            return t >= 0;
        }