Example #1
0
 internal double DistanceAlongRay2(DmtxRay2 ray)
 {
     if (Math.Abs(1.0 - ray.V.Mag()) > DmtxConstants.DmtxAlmostZero)
     {
         throw new ArgumentException("DistanceAlongRay2: The ray's V vector must be a unit vector");
     }
     return((this - ray.P).Dot(ray.V));
 }
Example #2
0
        internal bool PointAlongRay2(DmtxRay2 ray, double t)
        {
            if (Math.Abs(1.0 - ray.V.Mag()) > DmtxConstants.DmtxAlmostZero)
            {
                throw new ArgumentException("PointAlongRay: The ray's V vector must be a unit vector");
            }
            DmtxVector2 tmp = new DmtxVector2(ray.V._x * t, ray.V._y * t);

            this._x = ray.P._x + tmp._x;
            this._y = ray.P._y + tmp._y;
            return(true);
        }
Example #3
0
        internal bool Intersect(DmtxRay2 p0, DmtxRay2 p1)
        {
            double denominator = p1.V.Cross(p0.V);

            if (Math.Abs(denominator) < DmtxConstants.DmtxAlmostZero)
            {
                return(false);
            }
            double numerator = p1.V.Cross(p1.P - p0.P);

            return(PointAlongRay2(p0, numerator / denominator));
        }
Example #4
0
 internal double DistanceFromRay2(DmtxRay2 ray)
 {
     if (Math.Abs(1.0 - ray.V.Mag()) > DmtxConstants.DmtxAlmostZero)
     {
         throw new ArgumentException("DistanceFromRay2: The ray's V vector must be a unit vector");
     }
     return ray.V.Cross(this - ray.P);
 }
Example #5
0
 internal bool PointAlongRay2(DmtxRay2 ray, double t)
 {
     if (Math.Abs(1.0 - ray.V.Mag()) > DmtxConstants.DmtxAlmostZero)
     {
         throw new ArgumentException("PointAlongRay: The ray's V vector must be a unit vector");
     }
     DmtxVector2 tmp = new DmtxVector2(ray.V._x * t, ray.V._y * t);
     this._x = ray.P._x + tmp._x;
     this._y = ray.P._y + tmp._y;
     return true;
 }
Example #6
0
 internal bool Intersect(DmtxRay2 p0, DmtxRay2 p1)
 {
     double denominator = p1.V.Cross(p0.V);
     if (Math.Abs(denominator) < DmtxConstants.DmtxAlmostZero)
     {
         return false;
     }
     double numerator = p1.V.Cross(p1.P - p0.P);
     return PointAlongRay2(p0, numerator / denominator);
 }