// 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);
        }
Пример #2
0
        // Token: 0x06000289 RID: 649 RVA: 0x0000AA74 File Offset: 0x00008C74
        public bool Find()
        {
            this.Quantity = 0;
            IntersectionLine2Arc2 intersectionLine2Arc = new IntersectionLine2Arc2(new Line2(this.ray.Origin, this.ray.Direction), this.arc);

            if (intersectionLine2Arc.Find())
            {
                if (intersectionLine2Arc.Quantity == 2)
                {
                    if (intersectionLine2Arc.Parameter0 >= 0.0 && intersectionLine2Arc.Parameter1 >= 0.0)
                    {
                        this.Point0   = intersectionLine2Arc.Point0;
                        this.Point1   = intersectionLine2Arc.Point1;
                        this.Quantity = 2;
                    }
                    else if (intersectionLine2Arc.Parameter0 < 0.0 && intersectionLine2Arc.Parameter1 >= 0.0)
                    {
                        this.Point0   = intersectionLine2Arc.Point1;
                        this.Quantity = 1;
                    }
                }
                else if (intersectionLine2Arc.Parameter0 >= 0.0)
                {
                    this.Point0   = intersectionLine2Arc.Point0;
                    this.Quantity = 1;
                }
            }
            this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #3
0
 /// <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);
 }
Пример #4
0
        // Token: 0x060003DB RID: 987 RVA: 0x00011638 File Offset: 0x0000F838
        public bool Find()
        {
            Line3 line = new Line3(this.ray.Origin, this.ray.Direction);
            IntersectionLine3Plane3 intersectionLine3Plane = new IntersectionLine3Plane3(line, this.plane);

            if (intersectionLine3Plane.Find())
            {
                this.IntersectionType = intersectionLine3Plane.IntersectionType;
                this.RayParameter     = intersectionLine3Plane.LineParameter;
                return(this.RayParameter >= 0.0);
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }
        // Token: 0x06000426 RID: 1062 RVA: 0x00012C9C File Offset: 0x00010E9C
        public bool Find()
        {
            Line3 line = new Line3(this.segment.Origin, this.segment.Direction);
            IntersectionLine3Plane3 intersectionLine3Plane = new IntersectionLine3Plane3(line, this.plane);

            if (intersectionLine3Plane.Find())
            {
                this.IntersectionType = intersectionLine3Plane.IntersectionType;
                this.SegmentParameter = intersectionLine3Plane.LineParameter;
                return(Math.Abs(this.SegmentParameter) < this.segment.Extent + 1E-08);
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }
Пример #6
0
 // Token: 0x06000380 RID: 896 RVA: 0x0000F560 File Offset: 0x0000D760
 public bool Test()
 {
     if (Math.Abs(this.line.Direction.Dot(this.plane.Normal)) > 1E-08)
     {
         this.IntersectionType = Intersection.Type.IT_POINT;
         return(true);
     }
     if (Math.Abs(this.plane.Normal.Dot(this.line.Origin) - this.plane.Constant) <= 1E-08)
     {
         this.IntersectionType = Intersection.Type.IT_LINE;
         return(true);
     }
     this.IntersectionType = Intersection.Type.IT_EMPTY;
     return(false);
 }
Пример #7
0
        // Token: 0x06000433 RID: 1075 RVA: 0x00012F24 File Offset: 0x00011124
        public bool Find()
        {
            Vector3 vector  = this.segment.Origin - this.triangle.V0;
            Vector3 vector2 = this.triangle.V1 - this.triangle.V0;
            Vector3 vector3 = this.triangle.V2 - this.triangle.V0;
            Vector3 vector4 = vector2.Cross(vector3);
            double  num     = this.segment.Direction.Dot(vector4);
            double  num2;

            if (num > 1E-08)
            {
                num2 = 1.0;
            }
            else
            {
                if (num >= -1E-08)
                {
                    this.IntersectionType = Intersection.Type.IT_EMPTY;
                    return(false);
                }
                num2 = -1.0;
                num  = -num;
            }
            double num3 = num2 * this.segment.Direction.Dot(vector.Cross(vector3));

            if (num3 >= 0.0)
            {
                double num4 = num2 * this.segment.Direction.Dot(vector2.Cross(vector));
                if (num4 >= 0.0 && num3 + num4 <= num)
                {
                    double num5 = -num2 *vector.Dot(vector4);

                    double num6 = this.segment.Extent * num;
                    if (-num6 <= num5 && num5 <= num6)
                    {
                        double num7 = 1.0 / num;
                        this.SegmentParameter = num5 * num7;
                        this.TriB1            = num3 * num7;
                        this.TriB2            = num4 * num7;
                        this.TriB0            = 1.0 - this.TriB1 - this.TriB2;
                        this.IntersectionType = Intersection.Type.IT_POINT;
                        return(true);
                    }
                }
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }
Пример #8
0
        // Token: 0x0600041F RID: 1055 RVA: 0x00012980 File Offset: 0x00010B80
        public bool Find()
        {
            double[] array = new double[2];
            int      num   = IntersectionLine3Cylinder3.Find(this.segment.Origin, this.segment.Direction, this.cylinder, array);
            double   num2  = this.segment.Extent + 1E-08;

            if (num == 2)
            {
                if (Math.Abs(array[0]) < num2 && Math.Abs(array[1]) < num2)
                {
                    this.Point0           = this.segment.Origin + array[0] * this.segment.Direction;
                    this.Point1           = this.segment.Origin + array[1] * this.segment.Direction;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
                else if (Math.Abs(array[0]) < num2)
                {
                    this.Point0           = this.segment.Origin + array[0] * this.segment.Direction;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else if (Math.Abs(array[1]) < num2)
                {
                    this.Point0           = this.segment.Origin + array[1] * this.segment.Direction;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else
                {
                    this.IntersectionType = Intersection.Type.IT_EMPTY;
                }
            }
            else if (num == 1)
            {
                if (Math.Abs(array[0]) < num2)
                {
                    this.Point0           = this.segment.Origin + array[0] * this.segment.Direction;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else
                {
                    this.IntersectionType = Intersection.Type.IT_EMPTY;
                }
            }
            else
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
            }
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #9
0
        // Token: 0x060003FD RID: 1021 RVA: 0x00011EC8 File Offset: 0x000100C8
        public bool Find()
        {
            double  t      = -this.segment.Extent;
            double  extent = this.segment.Extent;
            int     quantity;
            Vector2 point;
            Vector2 point2;

            Intersection.Type intersectionType;
            bool result = Intersection.DoClipping(t, extent, this.segment.Origin, this.segment.Direction, this.box, this.solid, out quantity, out point, out point2, out intersectionType);

            this.Quantity         = quantity;
            this.Point0           = point;
            this.Point1           = point2;
            this.IntersectionType = intersectionType;
            return(result);
        }
Пример #10
0
        // Token: 0x06000353 RID: 851 RVA: 0x0000E360 File Offset: 0x0000C560
        public bool Find()
        {
            double  minValue = double.MinValue;
            double  maxValue = double.MaxValue;
            int     quantity;
            Vector2 point;
            Vector2 point2;

            Intersection.Type intersectionType;
            bool result = Intersection.DoClipping(minValue, maxValue, this.line.Origin, this.line.Direction, this.box, true, out quantity, out point, out point2, out intersectionType);

            this.Quantity         = quantity;
            this.Point0           = point;
            this.Point1           = point2;
            this.IntersectionType = intersectionType;
            return(result);
        }
Пример #11
0
        // Token: 0x060002B8 RID: 696 RVA: 0x0000B2BC File Offset: 0x000094BC
        public bool Find()
        {
            int quantity;

            double[] roots = IntersectionLine3Torus3.GetRoots(this.line, this.torus, out quantity);
            this.Quantity = quantity;
            Vector3[] array = new Vector3[4];
            for (int i = 0; i < this.Quantity; i++)
            {
                array[i] = this.line.Origin + roots[i] * this.line.Direction;
            }
            this.Point0           = array[0];
            this.Point1           = array[1];
            this.Point2           = array[2];
            this.Point3           = array[3];
            this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #12
0
        // Token: 0x06000381 RID: 897 RVA: 0x0000F600 File Offset: 0x0000D800
        public bool Find()
        {
            double num  = this.line.Direction.Dot(this.plane.Normal);
            double num2 = this.plane.Normal.Dot(this.line.Origin) - this.plane.Constant;

            if (Math.Abs(num) > 1E-08)
            {
                this.LineParameter    = -num2 / num;
                this.IntersectionType = Intersection.Type.IT_POINT;
                return(true);
            }
            if (Math.Abs(num2) <= 1E-08)
            {
                this.LineParameter    = 0.0;
                this.IntersectionType = Intersection.Type.IT_LINE;
                return(true);
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }
Пример #13
0
        // Token: 0x060003D4 RID: 980 RVA: 0x00011478 File Offset: 0x0000F678
        public bool Find()
        {
            double[] array = new double[2];
            int      num   = IntersectionLine3Cylinder3.Find(this.ray.Origin, this.ray.Direction, this.cylinder, array);

            if (num == 2)
            {
                if (array[0] >= 0.0 && array[1] >= 0.0)
                {
                    this.Point0           = this.ray.Origin + array[0] * this.ray.Direction;
                    this.Point1           = this.ray.Origin + array[1] * this.ray.Direction;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
                else if (array[1] >= 0.0)
                {
                    this.Point0           = this.ray.Origin + array[1] * this.ray.Direction;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else
                {
                    this.IntersectionType = Intersection.Type.IT_EMPTY;
                }
            }
            else if (num == 1)
            {
                if (array[0] >= 0.0)
                {
                    this.Point0           = this.ray.Origin + array[0] * this.ray.Direction;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else
                {
                    this.IntersectionType = Intersection.Type.IT_EMPTY;
                }
            }
            else
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
            }
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #14
0
 // 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);
 }
Пример #15
0
        // Token: 0x060002F2 RID: 754 RVA: 0x0000BC68 File Offset: 0x00009E68
        public bool Find()
        {
            int quantity;

            double[] array;
            bool     flag = IntersectionLine2Circle2.Find(this.line.Origin, this.line.Direction, this.circle.Center, this.circle.Radius, out quantity, out array);

            this.Quantity = quantity;
            if (flag)
            {
                this.Point0     = this.line.Origin + array[0] * this.line.Direction;
                this.Parameter0 = array[0];
                if (this.Quantity == 2)
                {
                    this.Point1     = this.line.Origin + array[1] * this.line.Direction;
                    this.Parameter1 = array[1];
                }
            }
            this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #16
0
        // Token: 0x060002C2 RID: 706 RVA: 0x0000B3DC File Offset: 0x000095DC
        public bool Find()
        {
            this.Quantity = 0;
            IntersectionCircle2Circle2 intersectionCircle2Circle = new IntersectionCircle2Circle2(this.circle, this.arc.Circle);

            if (!intersectionCircle2Circle.Find())
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
                return(false);
            }
            if (intersectionCircle2Circle.IntersectionType == Intersection.Type.IT_OTHER)
            {
                this.IntersectionType = Intersection.Type.IT_OTHER;
                return(true);
            }
            Vector2[] array = new Vector2[]
            {
                intersectionCircle2Circle.Point0,
                intersectionCircle2Circle.Point1
            };
            for (int i = 0; i < intersectionCircle2Circle.Quantity; i++)
            {
                if (IntersectionArc2Arc2.Contains(this.arc, array[i]))
                {
                    int quantity = this.Quantity;
                    this.Quantity = quantity + 1;
                    if (quantity == 0)
                    {
                        this.Point0 = array[i];
                    }
                    else
                    {
                        this.Point1 = array[i];
                    }
                }
            }
            this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #17
0
        // 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);
        }
Пример #18
0
        // Token: 0x060002DD RID: 733 RVA: 0x0000B900 File Offset: 0x00009B00
        public bool Find()
        {
            int num;

            double[] array;
            bool     flag = IntersectionLine2Circle2.Find(this.line.Origin, this.line.Direction, this.arc.Circle.Center, this.arc.Circle.Radius, out num, out array);

            this.Quantity = 0;
            if (flag)
            {
                Vector2 vector  = this.line.Origin + this.line.Direction * array[0];
                Vector2 vector2 = this.line.Origin + this.line.Direction * array[1];
                if (IntersectionArc2Arc2.Contains(this.arc, vector))
                {
                    this.Point0     = vector;
                    this.Parameter0 = array[0];
                    int quantity = this.Quantity;
                    this.Quantity = quantity + 1;
                    if (num == 2 && IntersectionArc2Arc2.Contains(this.arc, vector2))
                    {
                        this.Point1     = vector2;
                        this.Parameter1 = array[1];
                        quantity        = this.Quantity;
                        this.Quantity   = quantity + 1;
                    }
                }
                else if (num == 2 && IntersectionArc2Arc2.Contains(this.arc, vector2))
                {
                    this.Point0     = vector2;
                    this.Parameter0 = array[1];
                    int quantity = this.Quantity;
                    this.Quantity = quantity + 1;
                }
            }
            this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #19
0
        // Token: 0x060003AD RID: 941 RVA: 0x00010014 File Offset: 0x0000E214
        public bool Find()
        {
            double num = this.plane0.Normal.Dot(this.plane1.Normal);

            if (Math.Abs(num) < 0.99999999)
            {
                double num2    = 1.0;
                double num3    = 1.0;
                double num4    = num;
                double num5    = num2 / (num3 - num4 * num4);
                double scalar  = (this.plane0.Constant - num * this.plane1.Constant) * num5;
                double scalar2 = (this.plane1.Constant - num * this.plane0.Constant) * num5;
                this.IntersectionType = Intersection.Type.IT_LINE;
                Vector3     origin    = scalar * this.plane0.Normal + scalar2 * this.plane1.Normal;
                UnitVector3 direction = this.plane0.Normal.UnitCross(this.plane1.Normal);
                this.IntersectionLine = new Line3(origin, direction);
                return(true);
            }
            double value;

            if (num >= 0.0)
            {
                value = this.plane0.Constant - this.plane1.Constant;
            }
            else
            {
                value = this.plane0.Constant + this.plane1.Constant;
            }
            if (Math.Abs(value) < 1E-08)
            {
                this.IntersectionType  = Intersection.Type.IT_PLANE;
                this.IntersectionPlane = this.plane0;
                return(true);
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }
Пример #20
0
        // Token: 0x0600038D RID: 909 RVA: 0x0000F72C File Offset: 0x0000D92C
        public bool Test()
        {
            Vector3 vector  = this.line.Origin - this.triangle.V0;
            Vector3 vector2 = this.triangle.V1 - this.triangle.V0;
            Vector3 vector3 = this.triangle.V2 - this.triangle.V0;
            Vector3 vector4 = vector2.Cross(vector3);
            double  num     = this.line.Direction.Dot(vector4);
            double  num2;

            if (num > 1E-08)
            {
                num2 = 1.0;
            }
            else
            {
                if (num >= -1E-08)
                {
                    this.IntersectionType = Intersection.Type.IT_EMPTY;
                    return(false);
                }
                num2 = -1.0;
                num  = -num;
            }
            double num3 = num2 * this.line.Direction.Dot(vector.Cross(vector3));

            if (num3 >= 0.0)
            {
                double num4 = num2 * this.line.Direction.Dot(vector2.Cross(vector));
                if (num4 >= 0.0 && num3 + num4 <= num)
                {
                    this.IntersectionType = Intersection.Type.IT_POINT;
                    return(true);
                }
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }
        // Token: 0x06000425 RID: 1061 RVA: 0x00012B88 File Offset: 0x00010D88
        public bool Test()
        {
            Vector3 negativeEnd = this.segment.NegativeEnd;
            double  num         = this.plane.Normal.Dot(negativeEnd) - this.plane.Constant;

            if (Math.Abs(num) <= 1E-08)
            {
                num = 0.0;
            }
            Vector3 positiveEnd = this.segment.PositiveEnd;
            double  num2        = this.plane.Normal.Dot(positiveEnd) - this.plane.Constant;

            if (Math.Abs(num2) <= 1E-08)
            {
                num2 = 0.0;
            }
            double num3 = num * num2;

            if (num3 < 0.0)
            {
                this.IntersectionType = Intersection.Type.IT_POINT;
                return(true);
            }
            if (num3 > 0.0)
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
                return(false);
            }
            if (num != 0.0 || num2 != 0.0)
            {
                this.IntersectionType = Intersection.Type.IT_POINT;
                return(true);
            }
            this.IntersectionType = Intersection.Type.IT_SEGMENT;
            return(true);
        }
Пример #22
0
        // Token: 0x060002A9 RID: 681 RVA: 0x0000AFE0 File Offset: 0x000091E0
        public bool Find()
        {
            int num;

            double[] roots = IntersectionLine3Torus3.GetRoots(new Line3(this.ray.Origin, this.ray.Direction), this.torus, out num);
            this.Quantity = 0;
            Vector3[] array = new Vector3[4];
            for (int i = 0; i < num; i++)
            {
                if (roots[i] >= 0.0)
                {
                    Vector3[] array2   = array;
                    int       quantity = this.Quantity;
                    this.Quantity    = quantity + 1;
                    array2[quantity] = this.ray.Origin + roots[i] * this.ray.Direction;
                }
            }
            this.Point0           = array[0];
            this.Point1           = array[1];
            this.Point2           = array[2];
            this.Point3           = array[3];
            this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #23
0
        // Token: 0x06000465 RID: 1125 RVA: 0x000142D4 File Offset: 0x000124D4
        public bool Find()
        {
            Vector3[] array = new Vector3[]
            {
                this.triangle0.V1 - this.triangle0.V0,
                this.triangle0.V2 - this.triangle0.V1,
                this.triangle0.V0 - this.triangle0.V2
            };
            UnitVector3 unitVector;

            if (!array[0].TryGetUnitCross(array[1], out unitVector))
            {
                int      num     = IntersectionUtility3.MaxIndex(array[0].SquaredLength, array[1].SquaredLength, array[2].SquaredLength);
                Segment3 segment = new Segment3(this.triangle0[num], this.triangle0[(num + 1) % 3]);
                IntersectionSegment3Triangle3 intersectionSegment3Triangle = new IntersectionSegment3Triangle3(segment, this.triangle1);
                bool result = intersectionSegment3Triangle.Find();
                if (intersectionSegment3Triangle.IntersectionType == Intersection.Type.IT_POINT)
                {
                    this.Points[0]        = segment.Origin + intersectionSegment3Triangle.SegmentParameter * segment.Direction;
                    this.Quantity         = 1;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                return(result);
            }
            Plane3 plane = new Plane3(this.triangle0.V0, this.triangle0.V1, this.triangle0.V2);

            int[]    array2 = new int[3];
            double[] array3 = new double[3];
            int      num2;
            int      num3;
            int      num4;

            IntersectionTriangle3Triangle3.TrianglePlaneRelations(this.triangle1, plane, ref array3, ref array2, out num2, out num3, out num4);
            if (num2 == 3 || num3 == 3)
            {
                return(false);
            }
            if (num4 == 3)
            {
                return(this.ReportCoplanarIntersections && this.GetCoplanarIntersection(plane, this.triangle0, this.triangle1));
            }
            if (num2 == 0 || num3 == 0)
            {
                if (num4 == 2)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (array2[i] != 0)
                        {
                            int num5 = (i + 2) % 3;
                            int num6 = (i + 1) % 3;
                            return(this.IntersectsSegment(plane, this.triangle0, this.triangle1[num5], this.triangle1[num6]));
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (array2[i] == 0)
                        {
                            return(this.ContainsPoint(this.triangle0, plane, this.triangle1[i]));
                        }
                    }
                }
            }
            if (num4 == 0)
            {
                int num7 = (num2 == 1) ? 1 : -1;
                for (int i = 0; i < 3; i++)
                {
                    if (array2[i] == num7)
                    {
                        int     num5   = (i + 2) % 3;
                        int     num6   = (i + 1) % 3;
                        double  scalar = array3[i] / (array3[i] - array3[num5]);
                        Vector3 vector = this.triangle1[i] + scalar * (this.triangle1[num5] - this.triangle1[i]);
                        scalar = array3[i] / (array3[i] - array3[num6]);
                        Vector3 end = this.triangle1[i] + scalar * (this.triangle1[num6] - this.triangle1[i]);
                        return(this.IntersectsSegment(plane, this.triangle0, vector, end));
                    }
                }
            }
            for (int i = 0; i < 3; i++)
            {
                if (array2[i] == 0)
                {
                    int     num5   = (i + 2) % 3;
                    int     num6   = (i + 1) % 3;
                    double  scalar = array3[num5] / (array3[num5] - array3[num6]);
                    Vector3 vector = this.triangle1[num5] + scalar * (this.triangle1[num6] - this.triangle1[num5]);
                    return(this.IntersectsSegment(plane, this.triangle0, this.triangle1[i], vector));
                }
            }
            MathBase.Assert(false, "Triangle3Triangle3.Find(): should not be here");
            return(false);
        }
Пример #24
0
        // Token: 0x06000469 RID: 1129 RVA: 0x000148E0 File Offset: 0x00012AE0
        private bool IntersectsSegment(Plane3 plane, Triangle3 triangle, Vector3 end0, Vector3 end1)
        {
            int    num  = 0;
            double num2 = Math.Abs(plane.Normal.X);
            double num3 = Math.Abs(plane.Normal.Y);

            if (num3 > num2)
            {
                num  = 1;
                num2 = num3;
            }
            num3 = Math.Abs(plane.Normal.Z);
            if (num3 > num2)
            {
                num = 2;
            }
            Triangle2 triangle2;
            Vector2   end2;
            Vector2   end3;

            if (num == 0)
            {
                triangle2 = new Triangle2(new Vector2(triangle.V0.Y, triangle.V0.Z), new Vector2(triangle.V1.Y, triangle.V1.Z), new Vector2(triangle.V2.Y, triangle.V2.Z));
                end2      = new Vector2(end0.Y, end0.Z);
                end3      = new Vector2(end1.Y, end1.Z);
            }
            else if (num == 1)
            {
                triangle2 = new Triangle2(new Vector2(triangle.V0.X, triangle.V0.Z), new Vector2(triangle.V1.X, triangle.V1.Z), new Vector2(triangle.V2.X, triangle.V2.Z));
                end2      = new Vector2(end0.X, end0.Z);
                end3      = new Vector2(end1.X, end1.Z);
            }
            else
            {
                triangle2 = new Triangle2(new Vector2(triangle.V0.X, triangle.V0.Y), new Vector2(triangle.V1.X, triangle.V1.Y), new Vector2(triangle.V2.X, triangle.V2.Y));
                end2      = new Vector2(end0.X, end0.Y);
                end3      = new Vector2(end1.X, end1.Y);
            }
            Segment2 segment = new Segment2(end2, end3);
            IntersectionSegment2Triangle2 intersectionSegment2Triangle = new IntersectionSegment2Triangle2(segment, triangle2);

            if (!intersectionSegment2Triangle.Find())
            {
                return(false);
            }
            Vector2[] array = new Vector2[2];
            if (intersectionSegment2Triangle.IntersectionType == Intersection.Type.IT_SEGMENT)
            {
                this.IntersectionType = Intersection.Type.IT_SEGMENT;
                this.Quantity         = 2;
                array[0] = intersectionSegment2Triangle.Point0;
                array[1] = intersectionSegment2Triangle.Point1;
            }
            else
            {
                MathBase.Assert(intersectionSegment2Triangle.IntersectionType == Intersection.Type.IT_POINT, "Triangle3Triangle3.IntersectsSegment(): intersection type is not point");
                this.IntersectionType = Intersection.Type.IT_POINT;
                this.Quantity         = 1;
                array[0] = intersectionSegment2Triangle.Point0;
            }
            if (num == 0)
            {
                double num4 = 1.0 / plane.Normal.X;
                for (int i = 0; i < this.Quantity; i++)
                {
                    this.Points[i].Y = array[i].X;
                    this.Points[i].Z = array[i].Y;
                    this.Points[i].X = num4 * (plane.Constant - plane.Normal.Y * this.Points[i].Y - plane.Normal.Z * this.Points[i].Z);
                }
            }
            else if (num == 1)
            {
                double num5 = 1.0 / plane.Normal.Y;
                for (int i = 0; i < this.Quantity; i++)
                {
                    this.Points[i].X = array[i].X;
                    this.Points[i].Z = array[i].Y;
                    this.Points[i].Y = num5 * (plane.Constant - plane.Normal.X * this.Points[i].X - plane.Normal.Z * this.Points[i].Z);
                }
            }
            else
            {
                double num6 = 1.0 / plane.Normal.Z;
                for (int i = 0; i < this.Quantity; i++)
                {
                    this.Points[i].X = array[i].X;
                    this.Points[i].Y = array[i].Y;
                    this.Points[i].Z = num6 * (plane.Constant - plane.Normal.X * this.Points[i].X - plane.Normal.Y * this.Points[i].Y);
                }
            }
            return(true);
        }
Пример #25
0
        internal static bool DoClipping(double t0, double t1, Vector2 origin, UnitVector2 direction, Box2 box, bool solid, out int quantity, out Vector2 point0, out Vector2 point1, out Intersection.Type intrType)
        {
            Vector2 vector  = origin - box.Center;
            Vector2 vector2 = new Vector2(vector.Dot(box.Axis0), vector.Dot(box.Axis1));
            Vector2 vector3 = new Vector2(direction.Dot(box.Axis0), direction.Dot(box.Axis1));
            double  num     = t0;
            double  num2    = t1;
            bool    flag    = Intersection.Clip(vector3.X, -vector2.X - box.Extent0, ref t0, ref t1) && Intersection.Clip(-vector3.X, vector2.X - box.Extent0, ref t0, ref t1) && Intersection.Clip(vector3.Y, -vector2.Y - box.Extent1, ref t0, ref t1) && Intersection.Clip(-vector3.Y, vector2.Y - box.Extent1, ref t0, ref t1);

            point0 = Vector2.Zero;
            point1 = Vector2.Zero;
            if (flag && (solid || t0 != num || t1 != num2))
            {
                if (t1 > t0)
                {
                    intrType = Intersection.Type.IT_SEGMENT;
                    quantity = 2;
                    point0   = origin + t0 * direction;
                    point1   = origin + t1 * direction;
                }
                else
                {
                    intrType = Intersection.Type.IT_POINT;
                    quantity = 1;
                    point0   = origin + t0 * direction;
                }
            }
            else
            {
                intrType = Intersection.Type.IT_EMPTY;
                quantity = 0;
            }
            return(intrType > Intersection.Type.IT_EMPTY);
        }
Пример #26
0
        // Token: 0x060002FD RID: 765 RVA: 0x0000BE38 File Offset: 0x0000A038
        public bool Find()
        {
            Vector2 vector        = this.circle1.Center - this.circle0.Center;
            double  squaredLength = vector.SquaredLength;
            double  radius        = this.circle0.Radius;
            double  radius2       = this.circle1.Radius;
            double  num           = radius - radius2;

            if (squaredLength < 1E-08 && Math.Abs(num) < 1E-08)
            {
                this.IntersectionType = Intersection.Type.IT_OTHER;
                this.Quantity         = 0;
                return(true);
            }
            double num2 = num;
            double num3 = num2 * num2;

            if (squaredLength < num3)
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
                this.Quantity         = 0;
                return(false);
            }
            double num4 = radius + radius2;
            double num5 = num4;
            double num6 = num5 * num5;

            if (squaredLength > num6)
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
                this.Quantity         = 0;
                return(false);
            }
            if (squaredLength < num6)
            {
                if (num3 < squaredLength)
                {
                    double  num7  = 1.0 / squaredLength;
                    double  num8  = 0.5;
                    double  num9  = radius;
                    double  num10 = num9 * num9;
                    double  num11 = radius2;
                    double  num12 = num8 * ((num10 - num11 * num11) * num7 + 1.0);
                    Vector2 left  = this.circle0.Center + num12 * vector;
                    double  num13 = radius;
                    double  num14 = num13 * num13 * num7;
                    double  num15 = num12;
                    double  num16 = num14 - num15 * num15;
                    if (num16 < 0.0)
                    {
                        num16 = 0.0;
                    }
                    double  scalar  = Math.Sqrt(num16);
                    Vector2 vector2 = new Vector2(vector.Y, -vector.X);
                    this.Point0   = left - scalar * vector2;
                    this.Point1   = left + scalar * vector2;
                    this.Quantity = 2;
                }
                else
                {
                    this.Point0   = this.circle0.Center + radius / num * vector;
                    this.Quantity = 1;
                }
            }
            else
            {
                this.Quantity = 1;
                this.Point0   = this.circle0.Center + radius / num4 * vector;
            }
            this.IntersectionType = Intersection.Type.IT_POINT;
            return(true);
        }
Пример #27
0
        // Token: 0x060003BA RID: 954 RVA: 0x00010384 File Offset: 0x0000E584
        public bool Find()
        {
            double num = this.plane.Normal.Dot(this.triangle.V0) - this.plane.Constant;

            if (Math.Abs(num) <= this.epsilon)
            {
                num = 0.0;
            }
            double num2 = this.plane.Normal.Dot(this.triangle.V1) - this.plane.Constant;

            if (Math.Abs(num2) <= this.epsilon)
            {
                num2 = 0.0;
            }
            double num3 = this.plane.Normal.Dot(this.triangle.V2) - this.plane.Constant;

            if (Math.Abs(num3) <= this.epsilon)
            {
                num3 = 0.0;
            }
            Vector3 v  = this.triangle.V0;
            Vector3 v2 = this.triangle.V1;
            Vector3 v3 = this.triangle.V2;

            if (num > 0.0)
            {
                if (num2 > 0.0)
                {
                    if (num3 > 0.0)
                    {
                        this.Quantity         = 0;
                        this.IntersectionType = Intersection.Type.IT_EMPTY;
                    }
                    else if (num3 < 0.0)
                    {
                        this.Quantity = 2;
                        Vector3 left = v;
                        double  num4 = num;
                        this.Point0 = left + num4 / (num4 - num3) * (v3 - v);
                        Vector3 left2 = v2;
                        double  num5  = num2;
                        this.Point1           = left2 + num5 / (num5 - num3) * (v3 - v2);
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                    else
                    {
                        this.Quantity         = 1;
                        this.Point0           = v3;
                        this.IntersectionType = Intersection.Type.IT_POINT;
                    }
                }
                else if (num2 < 0.0)
                {
                    if (num3 > 0.0)
                    {
                        this.Quantity = 2;
                        Vector3 left3 = v;
                        double  num6  = num;
                        this.Point0 = left3 + num6 / (num6 - num2) * (v2 - v);
                        Vector3 left4 = v2;
                        double  num7  = num2;
                        this.Point1           = left4 + num7 / (num7 - num3) * (v3 - v2);
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                    else if (num3 < 0.0)
                    {
                        this.Quantity = 2;
                        Vector3 left5 = v;
                        double  num8  = num;
                        this.Point0 = left5 + num8 / (num8 - num2) * (v2 - v);
                        Vector3 left6 = v;
                        double  num9  = num;
                        this.Point1           = left6 + num9 / (num9 - num3) * (v3 - v);
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                    else
                    {
                        this.Quantity = 2;
                        Vector3 left7 = v;
                        double  num10 = num;
                        this.Point0           = left7 + num10 / (num10 - num2) * (v2 - v);
                        this.Point1           = v3;
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                }
                else if (num3 > 0.0)
                {
                    this.Quantity         = 1;
                    this.Point0           = v2;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else if (num3 < 0.0)
                {
                    this.Quantity = 2;
                    Vector3 left8 = v;
                    double  num11 = num;
                    this.Point0           = left8 + num11 / (num11 - num3) * (v3 - v);
                    this.Point1           = v2;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
                else
                {
                    this.Quantity         = 2;
                    this.Point0           = v2;
                    this.Point1           = v3;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
            }
            else if (num < 0.0)
            {
                if (num2 > 0.0)
                {
                    if (num3 > 0.0)
                    {
                        this.Quantity = 2;
                        Vector3 left9 = v;
                        double  num12 = num;
                        this.Point0 = left9 + num12 / (num12 - num2) * (v2 - v);
                        Vector3 left10 = v;
                        double  num13  = num;
                        this.Point1           = left10 + num13 / (num13 - num3) * (v3 - v);
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                    else if (num3 < 0.0)
                    {
                        this.Quantity = 2;
                        Vector3 left11 = v;
                        double  num14  = num;
                        this.Point0 = left11 + num14 / (num14 - num2) * (v2 - v);
                        Vector3 left12 = v2;
                        double  num15  = num2;
                        this.Point1           = left12 + num15 / (num15 - num3) * (v3 - v2);
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                    else
                    {
                        this.Quantity = 2;
                        Vector3 left13 = v;
                        double  num16  = num;
                        this.Point0           = left13 + num16 / (num16 - num2) * (v2 - v);
                        this.Point1           = v3;
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                }
                else if (num2 < 0.0)
                {
                    if (num3 > 0.0)
                    {
                        this.Quantity = 2;
                        Vector3 left14 = v;
                        double  num17  = num;
                        this.Point0 = left14 + num17 / (num17 - num3) * (v3 - v);
                        Vector3 left15 = v2;
                        double  num18  = num2;
                        this.Point1           = left15 + num18 / (num18 - num3) * (v3 - v2);
                        this.IntersectionType = Intersection.Type.IT_SEGMENT;
                    }
                    else if (num3 < 0.0)
                    {
                        this.Quantity         = 0;
                        this.IntersectionType = Intersection.Type.IT_EMPTY;
                    }
                    else
                    {
                        this.Quantity         = 1;
                        this.Point0           = this.triangle.V2;
                        this.IntersectionType = Intersection.Type.IT_POINT;
                    }
                }
                else if (num3 > 0.0)
                {
                    this.Quantity = 2;
                    Vector3 left16 = v;
                    double  num19  = num;
                    this.Point0           = left16 + num19 / (num19 - num3) * (v3 - v);
                    this.Point1           = v2;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
                else if (num3 < 0.0)
                {
                    this.Quantity         = 1;
                    this.Point0           = v2;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else
                {
                    this.Quantity         = 2;
                    this.Point0           = v2;
                    this.Point1           = v3;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
            }
            else if (num2 > 0.0)
            {
                if (num3 > 0.0)
                {
                    this.Quantity         = 1;
                    this.Point0           = v;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else if (num3 < 0.0)
                {
                    this.Quantity = 2;
                    Vector3 left17 = v2;
                    double  num20  = num2;
                    this.Point0           = left17 + num20 / (num20 - num3) * (v3 - v2);
                    this.Point1           = v;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
                else
                {
                    this.Quantity         = 2;
                    this.Point0           = v;
                    this.Point1           = v3;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
            }
            else if (num2 < 0.0)
            {
                if (num3 > 0.0)
                {
                    this.Quantity = 2;
                    Vector3 left18 = v2;
                    double  num21  = num2;
                    this.Point0           = left18 + num21 / (num21 - num3) * (v3 - v2);
                    this.Point1           = v;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
                else if (num3 < 0.0)
                {
                    this.Quantity         = 1;
                    this.Point0           = v;
                    this.IntersectionType = Intersection.Type.IT_POINT;
                }
                else
                {
                    this.Quantity         = 2;
                    this.Point0           = v;
                    this.Point1           = v3;
                    this.IntersectionType = Intersection.Type.IT_SEGMENT;
                }
            }
            else if (num3 > 0.0)
            {
                this.Quantity         = 2;
                this.Point0           = v;
                this.Point1           = v2;
                this.IntersectionType = Intersection.Type.IT_SEGMENT;
            }
            else if (num3 < 0.0)
            {
                this.Quantity         = 2;
                this.Point0           = v;
                this.Point1           = v2;
                this.IntersectionType = Intersection.Type.IT_SEGMENT;
            }
            else
            {
                this.Quantity         = 3;
                this.Point0           = v;
                this.Point1           = v2;
                this.Point2           = v3;
                this.IntersectionType = Intersection.Type.IT_POLYGON;
            }
            return(this.IntersectionType > Intersection.Type.IT_EMPTY);
        }
Пример #28
0
        // Token: 0x060002CE RID: 718 RVA: 0x0000B534 File Offset: 0x00009734
        public bool Find()
        {
            this.Quantity = 0;
            Circle2 circle  = this.arc0.Circle;
            Circle2 circle2 = this.arc1.Circle;
            IntersectionCircle2Circle2 intersectionCircle2Circle = new IntersectionCircle2Circle2(circle, circle2);

            if (!intersectionCircle2Circle.Find())
            {
                this.IntersectionType = Intersection.Type.IT_EMPTY;
                return(false);
            }
            if (intersectionCircle2Circle.IntersectionType != Intersection.Type.IT_OTHER)
            {
                Vector2[] array = new Vector2[]
                {
                    intersectionCircle2Circle.Point0,
                    intersectionCircle2Circle.Point1
                };
                for (int i = 0; i < intersectionCircle2Circle.Quantity; i++)
                {
                    if (IntersectionArc2Arc2.Contains(this.arc0, array[i]) && IntersectionArc2Arc2.Contains(this.arc1, array[i]))
                    {
                        int quantity = this.Quantity;
                        this.Quantity = quantity + 1;
                        if (quantity == 0)
                        {
                            this.Point0 = array[i];
                        }
                        else
                        {
                            this.Point1 = array[i];
                        }
                    }
                }
                this.IntersectionType = ((this.Quantity > 0) ? Intersection.Type.IT_POINT : Intersection.Type.IT_EMPTY);
                return(this.IntersectionType > Intersection.Type.IT_EMPTY);
            }
            if (IntersectionArc2Arc2.Contains(this.arc1, this.arc0.StartPoint))
            {
                if (IntersectionArc2Arc2.Contains(this.arc1, this.arc0.EndPoint))
                {
                    this.IntersectionType = Intersection.Type.IT_OTHER;
                    this.IntersectionArc  = this.arc0;
                }
                else if (!this.arc0.StartPoint.Equals(this.arc1.EndPoint))
                {
                    this.IntersectionType = Intersection.Type.IT_OTHER;
                    this.IntersectionArc  = new Arc2(this.arc0.Circle, this.arc0.StartAngle, this.arc1.StartAngle + this.arc1.DeltaAngle - this.arc0.StartAngle);
                }
                else
                {
                    this.IntersectionType = Intersection.Type.IT_POINT;
                    this.Quantity         = 1;
                    this.Point0           = this.arc0.StartPoint;
                }
                return(true);
            }
            if (IntersectionArc2Arc2.Contains(this.arc1, this.arc0.EndPoint))
            {
                if (!this.arc0.EndPoint.Equals(this.arc1.StartPoint))
                {
                    this.IntersectionType = Intersection.Type.IT_OTHER;
                    this.IntersectionArc  = new Arc2(this.arc0.Circle, this.arc1.StartAngle, this.arc0.StartAngle + this.arc0.DeltaAngle - this.arc1.StartAngle);
                }
                else
                {
                    this.IntersectionType = Intersection.Type.IT_POINT;
                    this.Quantity         = 1;
                    this.Point0           = this.arc1.StartPoint;
                }
                return(true);
            }
            if (IntersectionArc2Arc2.Contains(this.arc0, this.arc1.StartPoint))
            {
                this.IntersectionType = Intersection.Type.IT_OTHER;
                this.IntersectionArc  = this.arc1;
                return(true);
            }
            this.IntersectionType = Intersection.Type.IT_EMPTY;
            return(false);
        }