Example #1
0
        // Token: 0x06000209 RID: 521 RVA: 0x000092B0 File Offset: 0x000074B0
        public static Segment3 ShortestSegmentTo(this Vector3 vector3, Segment3 segment3)
        {
            DistanceVector3Segment3 distanceVector3Segment = new DistanceVector3Segment3(vector3, segment3);

            return(new Segment3(distanceVector3Segment.ClosestPointOnVector, distanceVector3Segment.ClosestPointOnSegment));
        }
Example #2
0
        // Token: 0x06000252 RID: 594 RVA: 0x00009AC4 File Offset: 0x00007CC4
        private void CalcSquared(ref Vector3 vector, ref Triangle3 triangle)
        {
            Vector3 vector2        = triangle.V0 - vector;
            Vector3 vector3        = triangle.V1 - triangle.V0;
            Vector3 vector4        = triangle.V2 - triangle.V0;
            double  squaredLength  = vector3.SquaredLength;
            double  num            = vector3.Dot(vector4);
            double  squaredLength2 = vector4.SquaredLength;
            double  num2           = vector2.Dot(vector3);
            double  num3           = vector2.Dot(vector4);
            double  squaredLength3 = vector2.SquaredLength;
            double  num4           = squaredLength * squaredLength2;
            double  num5           = num;
            double  num6           = Math.Abs(num4 - num5 * num5);
            double  num7           = num * num3 - squaredLength2 * num2;
            double  num8           = num * num2 - squaredLength * num3;
            double  num9;

            if (num7 + num8 <= num6)
            {
                if (num7 < 0.0)
                {
                    if (num8 < 0.0)
                    {
                        if (num2 < 0.0)
                        {
                            num8 = 0.0;
                            if (-num2 >= squaredLength)
                            {
                                num7 = 1.0;
                                num9 = squaredLength + 2.0 * num2 + squaredLength3;
                            }
                            else
                            {
                                num7 = -num2 / squaredLength;
                                num9 = num2 * num7 + squaredLength3;
                            }
                        }
                        else
                        {
                            num7 = 0.0;
                            if (num3 >= 0.0)
                            {
                                num8 = 0.0;
                                num9 = squaredLength3;
                            }
                            else if (-num3 >= squaredLength2)
                            {
                                num8 = 1.0;
                                num9 = squaredLength2 + 2.0 * num3 + squaredLength3;
                            }
                            else
                            {
                                num8 = -num3 / squaredLength2;
                                num9 = num3 * num8 + squaredLength3;
                            }
                        }
                    }
                    else
                    {
                        num7 = 0.0;
                        if (num3 >= 0.0)
                        {
                            num8 = 0.0;
                            num9 = squaredLength3;
                        }
                        else if (-num3 >= squaredLength2)
                        {
                            num8 = 1.0;
                            num9 = squaredLength2 + 2.0 * num3 + squaredLength3;
                        }
                        else
                        {
                            num8 = -num3 / squaredLength2;
                            num9 = num3 * num8 + squaredLength3;
                        }
                    }
                }
                else if (num8 < 0.0)
                {
                    num8 = 0.0;
                    if (num2 >= 0.0)
                    {
                        num7 = 0.0;
                        num9 = squaredLength3;
                    }
                    else if (-num2 >= squaredLength)
                    {
                        num7 = 1.0;
                        num9 = squaredLength + 2.0 * num2 + squaredLength3;
                    }
                    else
                    {
                        num7 = -num2 / squaredLength;
                        num9 = num2 * num7 + squaredLength3;
                    }
                }
                else
                {
                    if (num6 == 0.0)
                    {
                        Vector3[] array = new Vector3[]
                        {
                            triangle.V1 - triangle.V0,
                            triangle.V2 - triangle.V1,
                            triangle.V0 - triangle.V2
                        };
                        int      num10   = IntersectionUtility3.MaxIndex(array[0].SquaredLength, array[1].SquaredLength, array[2].SquaredLength);
                        Segment3 segment = new Segment3(triangle[num10], triangle[(num10 + 1) % 3]);
                        DistanceVector3Segment3 distanceVector3Segment = new DistanceVector3Segment3(vector, segment);
                        this.ClosestPointOnVector   = vector;
                        this.ClosestPointOnTriangle = distanceVector3Segment.ClosestPointOnSegment;
                        this.SquaredDistance        = distanceVector3Segment.SquaredDistance;
                        return;
                    }
                    double num11 = 1.0 / num6;
                    num7 *= num11;
                    num8 *= num11;
                    num9  = num7 * (squaredLength * num7 + num * num8 + 2.0 * num2) + num8 * (num * num7 + squaredLength2 * num8 + 2.0 * num3) + squaredLength3;
                }
            }
            else if (num7 < 0.0)
            {
                double num12 = num + num2;
                double num13 = squaredLength2 + num3;
                if (num13 > num12)
                {
                    double num14 = num13 - num12;
                    double num15 = squaredLength - 2.0 * num + squaredLength2;
                    if (num14 >= num15)
                    {
                        num7 = 1.0;
                        num8 = 0.0;
                        num9 = squaredLength + 2.0 * num2 + squaredLength3;
                    }
                    else
                    {
                        num7 = num14 / num15;
                        num8 = 1.0 - num7;
                        num9 = num7 * (squaredLength * num7 + num * num8 + 2.0 * num2) + num8 * (num * num7 + squaredLength2 * num8 + 2.0 * num3) + squaredLength3;
                    }
                }
                else
                {
                    num7 = 0.0;
                    if (num13 <= 0.0)
                    {
                        num8 = 1.0;
                        num9 = squaredLength2 + 2.0 * num3 + squaredLength3;
                    }
                    else if (num3 >= 0.0)
                    {
                        num8 = 0.0;
                        num9 = squaredLength3;
                    }
                    else
                    {
                        num8 = -num3 / squaredLength2;
                        num9 = num3 * num8 + squaredLength3;
                    }
                }
            }
            else if (num8 < 0.0)
            {
                double num16 = num + num3;
                double num17 = squaredLength + num2;
                if (num17 > num16)
                {
                    double num14 = num17 - num16;
                    double num15 = squaredLength - 2.0 * num + squaredLength2;
                    if (num14 >= num15)
                    {
                        num8 = 1.0;
                        num7 = 0.0;
                        num9 = squaredLength2 + 2.0 * num3 + squaredLength3;
                    }
                    else
                    {
                        num8 = num14 / num15;
                        num7 = 1.0 - num8;
                        num9 = num7 * (squaredLength * num7 + num * num8 + 2.0 * num2) + num8 * (num * num7 + squaredLength2 * num8 + 2.0 * num3) + squaredLength3;
                    }
                }
                else
                {
                    num8 = 0.0;
                    if (num17 <= 0.0)
                    {
                        num7 = 1.0;
                        num9 = squaredLength + 2.0 * num2 + squaredLength3;
                    }
                    else if (num2 >= 0.0)
                    {
                        num7 = 0.0;
                        num9 = squaredLength3;
                    }
                    else
                    {
                        num7 = -num2 / squaredLength;
                        num9 = num2 * num7 + squaredLength3;
                    }
                }
            }
            else
            {
                double num14 = squaredLength2 + num3 - num - num2;
                if (num14 <= 0.0)
                {
                    num7 = 0.0;
                    num8 = 1.0;
                    num9 = squaredLength2 + 2.0 * num3 + squaredLength3;
                }
                else
                {
                    double num15 = squaredLength - 2.0 * num + squaredLength2;
                    if (num14 >= num15)
                    {
                        num7 = 1.0;
                        num8 = 0.0;
                        num9 = squaredLength + 2.0 * num2 + squaredLength3;
                    }
                    else
                    {
                        num7 = num14 / num15;
                        num8 = 1.0 - num7;
                        num9 = num7 * (squaredLength * num7 + num * num8 + 2.0 * num2) + num8 * (num * num7 + squaredLength2 * num8 + 2.0 * num3) + squaredLength3;
                    }
                }
            }
            if (num9 < 0.0)
            {
                num9 = 0.0;
            }
            this.ClosestPointOnVector   = vector;
            this.ClosestPointOnTriangle = triangle.V0 + num7 * vector3 + num8 * vector4;
            this.TriangleBary1          = num7;
            this.TriangleBary2          = num8;
            this.TriangleBary0          = 1.0 - num7 - num8;
            this.SquaredDistance        = num9;
        }
Example #3
0
        // Token: 0x06000208 RID: 520 RVA: 0x00009290 File Offset: 0x00007490
        public static double DistanceTo(this Vector3 vector3, Segment3 segment3)
        {
            DistanceVector3Segment3 distanceVector3Segment = new DistanceVector3Segment3(vector3, segment3);

            return(distanceVector3Segment.Distance);
        }
Example #4
0
        // Token: 0x0600018C RID: 396 RVA: 0x00007700 File Offset: 0x00005900
        public static Vector3 ClosestPointTo(this Segment3 segment3, Vector3 vector3)
        {
            DistanceVector3Segment3 distanceVector3Segment = new DistanceVector3Segment3(vector3, segment3);

            return(distanceVector3Segment.ClosestPointOnSegment);
        }