Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="line"></param>
        /// <param name="other"></param>
        /// <returns></returns>
        public static Vector2?IntersectionWith(this Line2 line, Line2 other)
        {
            IntersectionLine2Line2 intersectionLine2Line = new IntersectionLine2Line2(line, other);

            if (intersectionLine2Line.Find() && intersectionLine2Line.IntersectionType == Intersection.Type.IT_POINT)
            {
                return(new Vector2?(intersectionLine2Line.Point));
            }
            return(null);
        }
 /// <summary>
 /// 查找当前的信息
 /// </summary>
 /// <returns></returns>
 public bool Find()
 {
     double[] array = new double[2];
     this.IntersectionType = IntersectionLine2Line2.Classify(this.line0.Origin, this.line0.Direction, this.line1.Origin, this.line1.Direction, 1E-08, ref array);
     if (this.IntersectionType == Intersection.Type.IT_POINT)
     {
         this.Point = this.line0.Origin + array[0] * this.line0.Direction;
     }
     return(this.IntersectionType > Intersection.Type.IT_EMPTY);
 }
 // Token: 0x0600029B RID: 667 RVA: 0x0000AD58 File Offset: 0x00008F58
 public bool Find()
 {
     double[] array = new double[2];
     this.IntersectionType = IntersectionLine2Line2.Classify(this.ray.Origin, this.ray.Direction, this.segment.Origin, this.segment.Direction, 1E-08, ref array);
     if (this.IntersectionType == Intersection.Type.IT_POINT)
     {
         if (array[0] >= 0.0 && Math.Abs(array[1]) <= this.segment.Extent)
         {
             this.Point0 = this.ray.Origin + array[0] * this.ray.Direction;
         }
         else
         {
             this.IntersectionType = Intersection.Type.IT_EMPTY;
         }
     }
     else if (this.IntersectionType == Intersection.Type.IT_LINE)
     {
         double       num         = this.ray.Direction.Dot(this.segment.Origin - this.ray.Origin);
         double       v           = num - this.segment.Extent;
         double       v2          = num + this.segment.Extent;
         Intersector1 intersector = new Intersector1(0.0, double.MaxValue, v, v2);
         intersector.Find();
         int quantity = intersector.Quantity;
         if (quantity == 2)
         {
             this.IntersectionType = Intersection.Type.IT_SEGMENT;
             this.Point0           = this.ray.Origin + intersector.Overlap0 * this.ray.Direction;
             this.Point1           = this.ray.Origin + intersector.Overlap1 * this.ray.Direction;
         }
         else if (quantity == 1)
         {
             this.IntersectionType = Intersection.Type.IT_POINT;
             this.Point0           = this.ray.Origin;
         }
         else
         {
             this.IntersectionType = Intersection.Type.IT_EMPTY;
         }
     }
     return(this.IntersectionType > Intersection.Type.IT_EMPTY);
 }
Example #4
0
        /// <summary>
        /// 线和线相交
        /// </summary>
        /// <param name="line"></param>
        /// <param name="other"></param>
        /// <returns></returns>
        public static bool Intersects(this Line2 line, Line2 other)
        {
            IntersectionLine2Line2 intersectionLine2Line = new IntersectionLine2Line2(line, other);

            return(intersectionLine2Line.Find());
        }