// Token: 0x06000407 RID: 1031 RVA: 0x00011FA8 File Offset: 0x000101A8 public bool Test() { double[] dist = new double[3]; int[] sign = new int[3]; int num; int num2; int num3; IntersectionLine2Triangle2.TriangleLineRelations(this.segment.Origin, this.segment.Direction, this.triangle, ref dist, ref sign, out num, out num2, out num3); if (num == 3 || num2 == 3) { this.IntersectionType = Intersection.Type.IT_EMPTY; } else { double[] array = new double[2]; IntersectionLine2Triangle2.GetInterval(this.segment.Origin, this.segment.Direction, this.triangle, dist, sign, ref array); Intersector1 intersector = new Intersector1(array[0], array[1], -this.segment.Extent, this.segment.Extent); intersector.Find(); this.Quantity = intersector.Quantity; if (this.Quantity == 2) { this.IntersectionType = Intersection.Type.IT_SEGMENT; } else if (this.Quantity == 1) { this.IntersectionType = Intersection.Type.IT_POINT; } else { this.IntersectionType = Intersection.Type.IT_EMPTY; } } return(this.IntersectionType > Intersection.Type.IT_EMPTY); }
/// <summary> /// 线和三角形相交 /// </summary> /// <param name="line"></param> /// <param name="triangle"></param> /// <returns></returns> public static Segment2?IntersectionWith(this Line2 line, Triangle2 triangle) { IntersectionLine2Triangle2 intersectionLine2Triangle = new IntersectionLine2Triangle2(line, triangle); bool flag = intersectionLine2Triangle.Find(); if (flag && intersectionLine2Triangle.IntersectionType == Intersection.Type.IT_SEGMENT) { return(new Segment2?(new Segment2(intersectionLine2Triangle.Point0, intersectionLine2Triangle.Point1))); } if (flag && intersectionLine2Triangle.IntersectionType == Intersection.Type.IT_POINT) { return(new Segment2?(new Segment2(intersectionLine2Triangle.Point0, line.Direction, 0.0))); } return(null); }
/// <summary> /// /// </summary> /// <param name="line"></param> /// <param name="triangle"></param> /// <returns></returns> public static ICollection <Vector2> IntersectionPointsWith(this Line2 line, Triangle2 triangle) { IntersectionLine2Triangle2 intersectionLine2Triangle = new IntersectionLine2Triangle2(line, triangle); intersectionLine2Triangle.Find(); List <Vector2> list = new List <Vector2>(); Vector2[] array = new Vector2[] { intersectionLine2Triangle.Point0, intersectionLine2Triangle.Point1 }; for (int i = 0; i < intersectionLine2Triangle.Quantity; i++) { list.Add(array[i]); } return(list); }
// Token: 0x0600035E RID: 862 RVA: 0x0000E530 File Offset: 0x0000C730 public bool Find() { double[] dist = new double[3]; int[] sign = new int[3]; int num; int num2; int num3; IntersectionLine2Triangle2.TriangleLineRelations(this.line.Origin, this.line.Direction, this.triangle, ref dist, ref sign, out num, out num2, out num3); if (num == 3 || num2 == 3) { this.Quantity = 0; this.IntersectionType = Intersection.Type.IT_EMPTY; } else { double[] array = new double[2]; IntersectionLine2Triangle2.GetInterval(this.line.Origin, this.line.Direction, this.triangle, dist, sign, ref array); Intersector1 intersector = new Intersector1(array[0], array[1], double.MinValue, double.MaxValue); intersector.Find(); this.Quantity = intersector.Quantity; if (this.Quantity == 2) { this.IntersectionType = Intersection.Type.IT_SEGMENT; this.Point0 = this.line.Origin + intersector.Overlap0 * this.line.Direction; this.Point1 = this.line.Origin + intersector.Overlap1 * this.line.Direction; } else if (this.Quantity == 1) { this.IntersectionType = Intersection.Type.IT_POINT; this.Point0 = this.line.Origin + intersector.Overlap0 * this.line.Direction; } else { this.IntersectionType = Intersection.Type.IT_EMPTY; } } return(this.IntersectionType > Intersection.Type.IT_EMPTY); }
public static bool Intersects(this Line2 line, Triangle2 triangle) { IntersectionLine2Triangle2 intersectionLine2Triangle = new IntersectionLine2Triangle2(line, triangle); return(intersectionLine2Triangle.Test()); }