Ejemplo n.º 1
0
        public V2d Intersect(V2d dirVector)
        {
            if (Origin.Abs().AllSmaller(Constant <double> .PositiveTinyValue))
            {
                return(Origin); // Early exit when rays have same origin
            }
            double cross = Direction.Dot270(dirVector);

            if (!Fun.IsTiny(cross)) // Rays not parallel
            {
                return(Origin + Direction * dirVector.Dot270(Origin) / cross);
            }
            else // Rays are parallel
            {
                return(V2d.NaN);
            }
        }
Ejemplo n.º 2
0
        public V2d Intersect(Ray2d r)
        {
            V2d a = r.Origin - Origin;

            if (a.Abs().AllSmaller(Constant <double> .PositiveTinyValue))
            {
                return(Origin); // Early exit when rays have same origin
            }
            double cross = Direction.Dot270(r.Direction);

            if (!Fun.IsTiny(cross)) // Rays not parallel
            {
                return(Origin + Direction * r.Direction.Dot90(a) / cross);
            }
            else // Rays are parallel
            {
                return(V2d.NaN);
            }
        }