Esempio n. 1
0
        // Token: 0x0600009A RID: 154 RVA: 0x00003AFC File Offset: 0x00001CFC
        public static Segment3 ShortestSegmentTo(this Line3 line3, Segment3 segment3)
        {
            DistanceLine3Segment3 distanceLine3Segment = new DistanceLine3Segment3(line3, segment3);

            return(new Segment3(distanceLine3Segment.ClosestPointOnLine, distanceLine3Segment.ClosestPointOnSegment));
        }
Esempio n. 2
0
        // Token: 0x06000099 RID: 153 RVA: 0x00003ADC File Offset: 0x00001CDC
        public static Vector3 ClosestPointTo(this Line3 line3, Segment3 segment3)
        {
            DistanceLine3Segment3 distanceLine3Segment = new DistanceLine3Segment3(line3, segment3);

            return(distanceLine3Segment.ClosestPointOnLine);
        }
        // Token: 0x060000D9 RID: 217 RVA: 0x000052B4 File Offset: 0x000034B4
        public DistanceLine3Rectangle3(Line3 line, Rectangle3 rectangle)
        {
            this = default(DistanceLine3Rectangle3);
            if (Math.Abs(rectangle.Axis0.Cross(rectangle.Axis1).Dot(line.Direction)) > 1E-08)
            {
                Vector3          vector          = line.Origin - rectangle.Center;
                UnitVector3      direction       = line.Direction;
                AffineTransform3 affineTransform = Transform3Factory.CreateOrthonormalBasis(direction);
                double           num             = affineTransform.AxisX.Dot(rectangle.Axis0);
                double           num2            = affineTransform.AxisX.Dot(rectangle.Axis1);
                double           num3            = affineTransform.AxisX.Dot(vector);
                double           num4            = affineTransform.AxisY.Dot(rectangle.Axis0);
                double           num5            = affineTransform.AxisY.Dot(rectangle.Axis1);
                double           num6            = affineTransform.AxisY.Dot(vector);
                double           num7            = 1.0 / (num * num5 - num2 * num4);
                double           num8            = (num5 * num3 - num2 * num6) * num7;
                double           num9            = (num * num6 - num4 * num3) * num7;
                if (Math.Abs(num8) <= rectangle.Extent0 && Math.Abs(num9) <= rectangle.Extent1)
                {
                    double num10 = direction.Dot(rectangle.Axis0);
                    double num11 = direction.Dot(rectangle.Axis1);
                    double num12 = line.Direction.Dot(vector);
                    this.LineParameter           = num8 * num10 + num9 * num11 - num12;
                    this.RectCoord0              = num8;
                    this.RectCoord1              = num9;
                    this.ClosestPointOnLine      = line.Origin + this.LineParameter * line.Direction;
                    this.ClosestPointOnRectangle = rectangle.Center + num8 * rectangle.Axis0 + num9 * rectangle.Axis1;
                    this.SquaredDistance         = 0.0;
                    return;
                }
            }
            double num13 = double.MaxValue;

            Vector3[] array = new Vector3[]
            {
                rectangle.Extent0 *rectangle.Axis0,
                rectangle.Extent1 *rectangle.Axis1
            };
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Vector3               origin               = rectangle.Center + (double)(2 * j - 1) * array[i];
                    UnitVector3           direction2           = (i == 0) ? rectangle.Axis1 : rectangle.Axis0;
                    double                extent               = (i == 0) ? rectangle.Extent1 : rectangle.Extent0;
                    Segment3              segment              = new Segment3(origin, direction2, extent);
                    DistanceLine3Segment3 distanceLine3Segment = new DistanceLine3Segment3(line, segment);
                    double                squaredDistance      = distanceLine3Segment.SquaredDistance;
                    if (squaredDistance < num13)
                    {
                        this.ClosestPointOnLine      = distanceLine3Segment.ClosestPointOnLine;
                        this.ClosestPointOnRectangle = distanceLine3Segment.ClosestPointOnSegment;
                        num13 = squaredDistance;
                        this.LineParameter = distanceLine3Segment.LineParameter;
                        double num14 = distanceLine3Segment.SegmentParameter / segment.Extent;
                        this.RectCoord0 = rectangle.Extent0 * ((double)((1 - i) * (2 * j - 1)) + (double)i * num14);
                        this.RectCoord1 = rectangle.Extent1 * ((double)((1 - j) * (2 * i - 1)) + (double)j * num14);
                    }
                }
            }
            this.SquaredDistance = num13;
        }
Esempio n. 4
0
        // Token: 0x06000098 RID: 152 RVA: 0x00003ABC File Offset: 0x00001CBC
        public static double DistanceTo(this Line3 line3, Segment3 segment3)
        {
            DistanceLine3Segment3 distanceLine3Segment = new DistanceLine3Segment3(line3, segment3);

            return(distanceLine3Segment.Distance);
        }
Esempio n. 5
0
        // Token: 0x060000F3 RID: 243 RVA: 0x000058E0 File Offset: 0x00003AE0
        public DistanceLine3Triangle3(Line3 line, Triangle3 triangle)
        {
            this = default(DistanceLine3Triangle3);
            Vector3     vector  = triangle.V1 - triangle.V0;
            Vector3     vector2 = triangle.V2 - triangle.V0;
            UnitVector3 unitVector;

            if (vector.TryGetUnitCross(vector2, out unitVector) && Math.Abs(unitVector.Dot(line.Direction)) > 1E-08)
            {
                Vector3          vector3         = line.Origin - triangle.V0;
                UnitVector3      direction       = line.Direction;
                AffineTransform3 affineTransform = Transform3Factory.CreateOrthonormalBasis(direction);
                double           num             = affineTransform.AxisX.Dot(vector);
                double           num2            = affineTransform.AxisX.Dot(vector2);
                double           num3            = affineTransform.AxisX.Dot(vector3);
                double           num4            = affineTransform.AxisY.Dot(vector);
                double           num5            = affineTransform.AxisY.Dot(vector2);
                double           num6            = affineTransform.AxisY.Dot(vector3);
                double           num7            = 1.0 / (num * num5 - num2 * num4);
                double           num8            = (num5 * num3 - num2 * num6) * num7;
                double           num9            = (num * num6 - num4 * num3) * num7;
                double           num10           = 1.0 - num8 - num9;
                if (num10 >= 0.0 && num8 >= 0.0 && num9 >= 0.0)
                {
                    double num11 = direction.Dot(vector);
                    double num12 = direction.Dot(vector2);
                    double num13 = line.Direction.Dot(vector3);
                    this.LineParameter          = num8 * num11 + num9 * num12 - num13;
                    this.TriangleBary0          = num10;
                    this.TriangleBary1          = num8;
                    this.TriangleBary2          = num9;
                    this.ClosestPointOnLine     = line.Origin + this.LineParameter * line.Direction;
                    this.ClosestPointOnTriangle = triangle.V0 + num8 * vector + num9 * vector2;
                    this.SquaredDistance        = 0.0;
                    return;
                }
            }
            Segment3 segment = new Segment3(triangle.V2, triangle.V0);
            DistanceLine3Segment3 distanceLine3Segment = new DistanceLine3Segment3(line, segment);

            this.ClosestPointOnLine     = distanceLine3Segment.ClosestPointOnLine;
            this.ClosestPointOnTriangle = distanceLine3Segment.ClosestPointOnSegment;
            this.SquaredDistance        = distanceLine3Segment.SquaredDistance;
            this.LineParameter          = distanceLine3Segment.LineParameter;
            this.TriangleBary2          = 0.5 * (1.0 - distanceLine3Segment.SegmentParameter / segment.Extent);
            this.TriangleBary0          = 1.0 - this.TriangleBary2;
            this.TriangleBary1          = 0.0;
            Segment3 segment2 = new Segment3(triangle.V0, triangle.V1);
            DistanceLine3Segment3 distanceLine3Segment2 = new DistanceLine3Segment3(line, segment2);

            if (distanceLine3Segment2.SquaredDistance < this.SquaredDistance)
            {
                this.ClosestPointOnLine     = distanceLine3Segment2.ClosestPointOnLine;
                this.ClosestPointOnTriangle = distanceLine3Segment2.ClosestPointOnSegment;
                this.SquaredDistance        = distanceLine3Segment2.SquaredDistance;
                this.LineParameter          = distanceLine3Segment2.LineParameter;
                this.TriangleBary0          = 0.5 * (1.0 - distanceLine3Segment2.SegmentParameter / segment2.Extent);
                this.TriangleBary1          = 1.0 - this.TriangleBary0;
                this.TriangleBary2          = 0.0;
            }
            Segment3 segment3 = new Segment3(triangle.V1, triangle.V2);
            DistanceLine3Segment3 distanceLine3Segment3 = new DistanceLine3Segment3(line, segment3);

            if (distanceLine3Segment3.SquaredDistance < this.SquaredDistance)
            {
                this.ClosestPointOnLine     = distanceLine3Segment3.ClosestPointOnLine;
                this.ClosestPointOnTriangle = distanceLine3Segment3.ClosestPointOnSegment;
                this.SquaredDistance        = distanceLine3Segment3.SquaredDistance;
                this.LineParameter          = distanceLine3Segment3.LineParameter;
                this.TriangleBary1          = 0.5 * (1.0 - distanceLine3Segment3.SegmentParameter / segment3.Extent);
                this.TriangleBary2          = 1.0 - this.TriangleBary1;
                this.TriangleBary0          = 0.0;
            }
        }