Esempio n. 1
0
        /// <summary>
        /// Get intersection of segment with plane.
        /// Returns 'null' (no intersection) or object of type 'Point3d' or 'Segment3d'.
        /// </summary>
        public object IntersectionWith(Plane3d s)
        {
            object obj = this.ToRay.IntersectionWith(s);

            if (obj == null)
            {
                return(null);
            }
            else
            {
                if (object.ReferenceEquals(obj.GetType(), typeof(Ray3d)))
                {
                    return(this);
                }
                else
                {
                    Ray3d  r    = new Ray3d(this.P2, new Vector3d(this.P2, this.P1));
                    object obj2 = r.IntersectionWith(s);
                    if (obj2 == null)
                    {
                        return(null);
                    }
                    else
                    {
                        return((Point3d)obj2);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get intersection of ray with triangle.
        /// Returns 'null' (no intersection) or object of type 'Point3d' or 'Segment3d'.
        /// </summary>
        public object IntersectionWith(Ray3d r)
        {
            // Relative tolerance ================================
            if (!GeometRi3D.UseAbsoluteTolerance)
            {
                double tol = GeometRi3D.Tolerance;
                GeometRi3D.Tolerance            = tol * Max(AB, Max(BC, AC));
                GeometRi3D.UseAbsoluteTolerance = true;
                object result = this.IntersectionWith(r);
                GeometRi3D.UseAbsoluteTolerance = false;
                GeometRi3D.Tolerance            = tol;
                return(result);
            }
            //====================================================

            object obj = this.IntersectionWith(r.ToLine);

            if (obj == null)
            {
                return(null);
            }
            else if (obj.GetType() == typeof(Point3d))
            {
                Point3d p = (Point3d)obj;
                if (p.BelongsTo(r))
                {
                    return(p);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(r.IntersectionWith((Segment3d)obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Get intersection of segment with ray.
 /// Returns 'null' (no intersection) or object of type 'Point3d' or 'Segment3d'.
 /// </summary>
 public object IntersectionWith(Ray3d r)
 {
     return(r.IntersectionWith(this));
 }