Ejemplo n.º 1
0
 // Token: 0x06000122 RID: 290 RVA: 0x00005400 File Offset: 0x00003600
 internal static void AssertUnitVector(Vector3 v)
 {
     if (!MathBase.IsUnitVector(v))
     {
         throw new ArgumentException("must be unit vector");
     }
 }
Ejemplo n.º 2
0
 // Token: 0x060001C7 RID: 455 RVA: 0x0000A0C3 File Offset: 0x000082C3
 public Segment2(Vector2 origin, UnitVector2 direction, double extent)
 {
     this = default(Segment2);
     MathBase.AssertValid(extent);
     this.Origin    = origin;
     this.Direction = direction;
     this.Extent    = extent;
 }
Ejemplo n.º 3
0
        // Token: 0x060004A0 RID: 1184 RVA: 0x000175AE File Offset: 0x000157AE
        public static Polynomial1 operator -(Polynomial1 poly, double scalar)
        {
            MathBase.Assert(poly.degree >= 0, "Polynomial1 operator -(Polynomial1, double): invalid degree");
            Polynomial1 polynomial = new Polynomial1(poly.Coeff);

            polynomial.Coeff[0] -= scalar;
            return(polynomial);
        }
Ejemplo n.º 4
0
 // Token: 0x06000471 RID: 1137 RVA: 0x00015AFC File Offset: 0x00013CFC
 public Intersector1(double u0, double u1, double v0, double v1)
 {
     MathBase.Assert(u0 <= u1 && v0 <= v1, "Intersector1(): bad arguments");
     this.u0       = u0;
     this.u1       = u1;
     this.v0       = v0;
     this.v1       = v1;
     this.Quantity = 0;
 }
Ejemplo n.º 5
0
 // Token: 0x060004E2 RID: 1250 RVA: 0x00019729 File Offset: 0x00017929
 public double GetRoot(int i)
 {
     MathBase.Assert(0 <= i && i < this.Count, "PolynomialRoots.GetRoot(): invalid argument");
     if (0 <= i && i < this.Count)
     {
         return(this.Roots[i]);
     }
     return(double.MaxValue);
 }
Ejemplo n.º 6
0
 // Token: 0x060004DD RID: 1245 RVA: 0x000196B4 File Offset: 0x000178B4
 public PolynomialRoots(double epsilon)
 {
     this = default(PolynomialRoots);
     MathBase.Assert(epsilon >= 0.0, "PolynomialRoots(): epsilon was < 0");
     this.epsilon = epsilon;
     this.Count   = 0;
     this.maxRoot = 4;
     this.Roots   = new double[this.maxRoot];
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 顶点坐标
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 public Vector3(double x, double y, double z)
 {
     MathBase.AssertValid(x);
     MathBase.AssertValid(y);
     MathBase.AssertValid(z);
     this.x = x;
     this.y = y;
     this.z = z;
 }
Ejemplo n.º 8
0
 // Token: 0x060001E4 RID: 484 RVA: 0x0000A668 File Offset: 0x00008868
 public AffineTransform3(UnitVector3 axisX, UnitVector3 axisY, UnitVector3 axisZ, Vector3 origin, double scale)
 {
     this = default(AffineTransform3);
     MathBase.Assert(Math.Abs(1.0 - axisX.Cross(axisY).Dot(axisZ)) < 1E-08, "AffineTransform3 constructor: axes must be perpendicular and right-handed.");
     this.AxisX  = axisX;
     this.AxisY  = axisY;
     this.AxisZ  = axisZ;
     this.Scale  = scale;
     this.Origin = origin;
 }
Ejemplo n.º 9
0
 // Token: 0x060001B3 RID: 435 RVA: 0x00009C98 File Offset: 0x00007E98
 public Rectangle3(Vector3 center, UnitVector3 axis0, UnitVector3 axis1, double extent0, double extent1)
 {
     this = default(Rectangle3);
     MathBase.Assert(Math.Abs(axis0.Dot(axis1)) < 1E-08, "Rectangle3 constructor: axes not perpendicular.");
     this.Axis0   = axis0;
     this.Axis1   = axis1;
     this.Extent0 = extent0;
     this.Extent1 = extent1;
     this.Center  = center;
 }
Ejemplo n.º 10
0
 // Token: 0x060000B3 RID: 179 RVA: 0x00003FF8 File Offset: 0x000021F8
 public Circle3(Vector3 center, UnitVector3 unitU, UnitVector3 unitV, UnitVector3 normal, double radius)
 {
     this = default(Circle3);
     MathBase.Assert(Math.Abs(1.0 - unitU.Cross(unitV).Dot(normal)) < 1E-08, "Circle3 constructor: axes must be perpendicular and right-handed.");
     this.Center = center;
     this.UnitU  = unitU;
     this.UnitV  = unitV;
     this.Normal = normal;
     this.Radius = radius;
 }
Ejemplo n.º 11
0
        // Token: 0x060004A1 RID: 1185 RVA: 0x000175E4 File Offset: 0x000157E4
        public static Polynomial1 operator *(Polynomial1 poly, double scalar)
        {
            MathBase.Assert(poly.degree >= 0, "Polynomial1 operator *(Polynomial1, double): invalid degree");
            Polynomial1 polynomial = new Polynomial1(poly.degree);

            for (int i = 0; i <= poly.degree; i++)
            {
                polynomial.Coeff[i] = scalar * poly.Coeff[i];
            }
            return(polynomial);
        }
Ejemplo n.º 12
0
        // Token: 0x060004A4 RID: 1188 RVA: 0x0001771C File Offset: 0x0001591C
        public static Polynomial1 operator -(Polynomial1 poly)
        {
            MathBase.Assert(poly.degree >= 0, "Polynomial1 operator -(Polynomial1): invalid degree");
            Polynomial1 polynomial = new Polynomial1(poly.degree);

            for (int i = 0; i <= poly.degree; i++)
            {
                polynomial.Coeff[i] = -poly.Coeff[i];
            }
            return(polynomial);
        }
Ejemplo n.º 13
0
		/// <summary>
		/// 构造函数,初始化当前的四维向量
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="z"></param>
		/// <param name="w"></param>
		public Vector4(double x, double y, double z, double w)
		{
			MathBase.AssertValid(x);
			MathBase.AssertValid(y);
			MathBase.AssertValid(z);
			MathBase.AssertValid(w);
			this.x = x;
			this.y = y;
			this.z = z;
			this.w = w;
		}
Ejemplo n.º 14
0
 // Token: 0x06000090 RID: 144 RVA: 0x00003908 File Offset: 0x00001B08
 public Box3(Vector3 center, UnitVector3 axis0, UnitVector3 axis1, UnitVector3 axis2, double extent0, double extent1, double extent2)
 {
     this = default(Box3);
     MathBase.Assert(Math.Abs(1.0 - axis0.Cross(axis1).Dot(axis2)) < 1E-08, "Box3 constructor: axes must be perpendicular and right-handed.");
     this.Center  = center;
     this.Axis0   = axis0;
     this.Axis1   = axis1;
     this.Axis2   = axis2;
     this.Extent0 = extent0;
     this.Extent1 = extent1;
     this.Extent2 = extent2;
 }
Ejemplo n.º 15
0
        // Token: 0x06000360 RID: 864 RVA: 0x0000E774 File Offset: 0x0000C974
        internal static void GetInterval(Vector2 origin, UnitVector2 direction, Triangle2 triangle, double[] dist, int[] sign, ref double[] param)
        {
            double[] array = new double[3];
            for (int i = 0; i < 3; i++)
            {
                Vector2 vector = triangle[i] - origin;
                array[i] = direction.Dot(vector);
            }
            int num  = 0;
            int num2 = 2;
            int j    = 0;

            while (j < 3)
            {
                if (sign[num2] * sign[j] < 0)
                {
                    MathBase.Assert(num < 2, "Line2Triangle2.GetInterval(): iQuantity < 2 failed");
                    double num3 = dist[num2] * array[j] - dist[j] * array[num2];
                    double num4 = dist[num2] - dist[j];
                    param[num++] = num3 / num4;
                }
                num2 = j++;
            }
            if (num < 2)
            {
                int k = 0;
                while (k < 3)
                {
                    if (sign[k] == 0)
                    {
                        MathBase.Assert(num < 2, "Line2Triangle2.GetInterval(): iQuantity < 2 failed");
                        param[num++] = array[k];
                    }
                    int num5 = k++;
                }
            }
            MathBase.Assert(num >= 1, "Line2Triangle2.GetInterval(): iQuantity >= 1 failed");
            if (num == 2)
            {
                if (param[0] > param[1])
                {
                    double num6 = param[0];
                    param[0] = param[1];
                    param[1] = num6;
                    return;
                }
            }
            else
            {
                param[1] = param[0];
            }
        }
Ejemplo n.º 16
0
 // Token: 0x060001B2 RID: 434 RVA: 0x00009C0C File Offset: 0x00007E0C
 public Rectangle3(Vector3 center, UnitVector3[] axis, double[] extent)
 {
     this = default(Rectangle3);
     if (axis.Length != 2 || extent.Length != 2)
     {
         throw new ArgumentException("Rectangle3 needs 2 axises and 2 extents");
     }
     MathBase.Assert(Math.Abs(axis[0].Dot(axis[1])) < 1E-08, "Rectangle3 constructor: axes not perpendicular.");
     this.Center  = center;
     this.Axis0   = axis[0];
     this.Axis1   = axis[1];
     this.Extent0 = extent[0];
     this.Extent1 = extent[1];
 }
Ejemplo n.º 17
0
        // Token: 0x0600049E RID: 1182 RVA: 0x000174F0 File Offset: 0x000156F0
        public static Polynomial1 operator *(Polynomial1 left, Polynomial1 right)
        {
            MathBase.Assert(left.degree >= 0 && right.degree >= 0, "Polynomial1.operator*(Polynomial1, Polynomial1): invalid degree");
            Polynomial1 polynomial = new Polynomial1(left.degree + right.degree);

            for (int i = 0; i <= left.degree; i++)
            {
                for (int j = 0; j <= right.degree; j++)
                {
                    int num = i + j;
                    polynomial.Coeff[num] += left.Coeff[i] * right.Coeff[j];
                }
            }
            return(polynomial);
        }
Ejemplo n.º 18
0
 // Token: 0x0600008F RID: 143 RVA: 0x0000384C File Offset: 0x00001A4C
 public Box3(Vector3 center, UnitVector3[] axis, double[] extent)
 {
     this = default(Box3);
     if (axis.Length != 3 || extent.Length != 3)
     {
         throw new ArgumentException("Box3 needs 3 axises and 3 extents");
     }
     MathBase.Assert(Math.Abs(1.0 - axis[0].Cross(axis[1]).Dot(axis[2])) < 1E-08, "Box3 constructor: axes must be perpendicular and right-handed.");
     this.Center  = center;
     this.Axis0   = axis[0];
     this.Axis1   = axis[1];
     this.Axis2   = axis[2];
     this.Extent0 = extent[0];
     this.Extent1 = extent[1];
     this.Extent2 = extent[2];
 }
Ejemplo n.º 19
0
 public AffineTransform2(UnitVector2 axisX, UnitVector2 axisY, Vector2 origin, double scale)
 {
     this = default(AffineTransform2);
     MathBase.Assert(Math.Abs(axisX.Dot(axisY)) < 1E-08, "AffineTransform2 constructor: axes not perpendicular.");
     if (axisX.Dot(UnitVector2.UnitX) >= 0.0)
     {
         MathBase.Assert(axisY.Dot(UnitVector2.UnitY) >= 0.0, "AffineTransform2 constructor: axes not right-handed.");
     }
     else
     {
         MathBase.Assert(axisY.Dot(UnitVector2.UnitY) < 0.0, "AffineTransform2 constructor: axes not right-handed.");
     }
     this.AxisX  = axisX;
     this.AxisY  = axisY;
     this.Scale  = scale;
     this.Origin = origin;
 }
Ejemplo n.º 20
0
 // Token: 0x0600007F RID: 127 RVA: 0x00003480 File Offset: 0x00001680
 public Box2(Vector2 center, UnitVector2 axis0, UnitVector2 axis1, double extent0, double extent1)
 {
     this = default(Box2);
     MathBase.Assert(Math.Abs(axis0.Dot(axis1)) < 1E-08, "Box2 constructor: axes not perpendicular.");
     if (axis0.Dot(UnitVector2.UnitX) >= 0.0)
     {
         MathBase.Assert(axis1.Dot(UnitVector2.UnitY) >= 0.0, "Box2 constructor: axes not right-handed.");
     }
     else
     {
         MathBase.Assert(axis1.Dot(UnitVector2.UnitY) < 0.0, "Box2 constructor: axes not right-handed.");
     }
     this.Center  = center;
     this.Axis0   = axis0;
     this.Axis1   = axis1;
     this.Extent0 = extent0;
     this.Extent1 = extent1;
 }
Ejemplo n.º 21
0
        internal static Segment3?DoClipping(double fT0, double fT1, Vector3 origin, UnitVector3 direction, Box3 box)
        {
            MathBase.Assert(fT0 < fT1, "Intersection.DoClipping(): invalid arguments");
            Vector3 vector  = origin - box.Center;
            Vector3 vector2 = new Vector3(vector.Dot(box.Axis0), vector.Dot(box.Axis1), vector.Dot(box.Axis2));
            Vector3 vector3 = new Vector3(direction.Dot(box.Axis0), direction.Dot(box.Axis1), direction.Dot(box.Axis2));

            if (!Intersection.Clip(vector3.X, -vector2.X - box.Extent0, ref fT0, ref fT1) || !Intersection.Clip(-vector3.X, vector2.X - box.Extent0, ref fT0, ref fT1) || !Intersection.Clip(vector3.Y, -vector2.Y - box.Extent1, ref fT0, ref fT1) || !Intersection.Clip(-vector3.Y, vector2.Y - box.Extent1, ref fT0, ref fT1) || !Intersection.Clip(vector3.Z, -vector2.Z - box.Extent2, ref fT0, ref fT1) || !Intersection.Clip(-vector3.Z, vector2.Z - box.Extent2, ref fT0, ref fT1))
            {
                return(null);
            }
            if (fT1 > fT0)
            {
                Vector3 left    = origin + fT0 * direction;
                Vector3 right   = origin + fT1 * direction;
                Vector3 origin2 = (left + right) * 0.5;
                double  extent  = (left - right).Length * 0.5;
                return(new Segment3?(new Segment3(origin2, direction, extent)));
            }
            return(new Segment3?(new Segment3(origin + fT0 * direction, direction, 0.0)));
        }
Ejemplo n.º 22
0
 // Token: 0x0600007E RID: 126 RVA: 0x00003388 File Offset: 0x00001588
 public Box2(Vector2 center, UnitVector2[] axis, double[] extent)
 {
     this = default(Box2);
     if (axis.Length != 2 || extent.Length != 2)
     {
         throw new ArgumentException("Box2 needs 2 axises and 2 extents");
     }
     MathBase.Assert(Math.Abs(axis[0].Dot(axis[1])) < 1E-08, "Box2 constructor: axes not perpendicular.");
     if (axis[0].Dot(UnitVector2.UnitX) >= 0.0)
     {
         MathBase.Assert(axis[1].Dot(UnitVector2.UnitY) >= 0.0, "Box2 constructor: axes not right-handed.");
     }
     else
     {
         MathBase.Assert(axis[1].Dot(UnitVector2.UnitY) < 0.0, "Box2 constructor: axes not right-handed.");
     }
     this.Center  = center;
     this.Axis0   = axis[0];
     this.Axis1   = axis[1];
     this.Extent0 = extent[0];
     this.Extent1 = extent[1];
 }
Ejemplo n.º 23
0
        // Token: 0x060004A3 RID: 1187 RVA: 0x0001768C File Offset: 0x0001588C
        public static Polynomial1 operator /(Polynomial1 poly, double scalar)
        {
            MathBase.Assert(poly.degree >= 0, "Polynomial1 operator /(Polynomial1, double): invalid degree");
            Polynomial1 polynomial = new Polynomial1(poly.degree);

            if (scalar != 0.0)
            {
                double num = 1.0 / scalar;
                for (int i = 0; i <= poly.degree; i++)
                {
                    polynomial.Coeff[i] = num * poly.Coeff[i];
                }
            }
            else
            {
                for (int i = 0; i <= poly.degree; i++)
                {
                    polynomial.Coeff[i] = double.MaxValue;
                }
            }
            return(polynomial);
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
 // Token: 0x060004F5 RID: 1269 RVA: 0x0001A7F9 File Offset: 0x000189F9
 public Query2(int quantity, Vector2[] vertices)
 {
     MathBase.Assert(quantity > 0 && vertices != null, "Triangle3Triangle3.Query2(): invalid params in constructor");
     this.Quantity = quantity;
     this.Vertices = vertices;
 }
Ejemplo n.º 27
0
        // Token: 0x0600037A RID: 890 RVA: 0x0000F064 File Offset: 0x0000D264
        internal static int Find(Vector3 origin, UnitVector3 dir, Cylinder3 cylinder, double[] t)
        {
            UnitVector3 direction = cylinder.Axis.Direction;
            UnitVector3 unitVector;
            UnitVector3 unitVector2;

            Vector3Factory.GenerateComplementBasis(out unitVector, out unitVector2, direction);
            double  num     = 0.5 * cylinder.Height;
            double  num2    = cylinder.Radius * cylinder.Radius;
            Vector3 vector  = origin - cylinder.Axis.Origin;
            Vector3 vector2 = new Vector3(unitVector.Dot(vector), unitVector2.Dot(vector), direction.Dot(vector));
            double  num3    = direction.Dot(dir);

            if (Math.Abs(num3) >= 0.99999999)
            {
                if (num2 - vector2.X * vector2.X - vector2.Y * vector2.Y < 0.0)
                {
                    return(0);
                }
                if (num3 > 0.0)
                {
                    t[0] = -vector2.Z - num;
                    t[1] = -vector2.Z + num;
                }
                else
                {
                    t[0] = vector2.Z - num;
                    t[1] = vector2.Z + num;
                }
                return(2);
            }
            else
            {
                Vector3 vector3 = new Vector3(unitVector.Dot(dir), unitVector2.Dot(dir), num3);
                if (Math.Abs(vector3.Z) <= 1E-08)
                {
                    if (Math.Abs(vector2.Z) > num)
                    {
                        return(0);
                    }
                    double num4 = vector2.X * vector2.X + vector2.Y * vector2.Y - num2;
                    double num5 = vector2.X * vector3.X + vector2.Y * vector3.Y;
                    double num6 = vector3.X * vector3.X + vector3.Y * vector3.Y;
                    double num7 = num5;
                    double num8 = num7 * num7 - num4 * num6;
                    if (num8 < -1E-08)
                    {
                        return(0);
                    }
                    if (num8 > 1E-08)
                    {
                        double num9  = Math.Sqrt(num8);
                        double num10 = 1.0 / num6;
                        t[0] = (-num5 - num9) * num10;
                        t[1] = (-num5 + num9) * num10;
                        return(2);
                    }
                    t[0] = -num5 / num6;
                    return(1);
                }
                else
                {
                    int    num11 = 0;
                    double num10 = 1.0 / vector3.Z;
                    double num12 = (-num - vector2.Z) * num10;
                    double num13 = vector2.X + num12 * vector3.X;
                    double num14 = vector2.Y + num12 * vector3.Y;
                    double num15 = num13 * num13;
                    double num16 = num14;
                    if (num15 + num16 * num16 <= num2)
                    {
                        t[num11++] = num12;
                    }
                    double num17 = (num - vector2.Z) * num10;
                    double num18 = vector2.X + num17 * vector3.X;
                    num14 = vector2.Y + num17 * vector3.Y;
                    double num19 = num18 * num18;
                    double num20 = num14;
                    if (num19 + num20 * num20 <= num2)
                    {
                        t[num11++] = num17;
                    }
                    if (num11 == 2)
                    {
                        if (t[0] > t[1])
                        {
                            double num21 = t[0];
                            t[0] = t[1];
                            t[1] = num21;
                        }
                        return(2);
                    }
                    double num4  = vector2.X * vector2.X + vector2.Y * vector2.Y - num2;
                    double num5  = vector2.X * vector3.X + vector2.Y * vector3.Y;
                    double num6  = vector3.X * vector3.X + vector3.Y * vector3.Y;
                    double num22 = num5;
                    double num8  = num22 * num22 - num4 * num6;
                    if (num8 < -1E-08)
                    {
                        MathBase.Assert(num11 == 0, "IntersectionLine3Cylinder3: Unexpected condition\n");
                        return(0);
                    }
                    if (num8 > 1E-08)
                    {
                        double num9 = Math.Sqrt(num8);
                        num10 = 1.0 / num6;
                        double num23 = (-num5 - num9) * num10;
                        if (num11 != 1 || Math.Abs(t[0] - num23) >= 1E-08)
                        {
                            if (num12 <= num17)
                            {
                                if (num12 <= num23 && num23 <= num17)
                                {
                                    t[num11++] = num23;
                                }
                            }
                            else if (num17 <= num23 && num23 <= num12)
                            {
                                t[num11++] = num23;
                            }
                        }
                        if (num11 == 2)
                        {
                            if (t[0] > t[1])
                            {
                                double num24 = t[0];
                                t[0] = t[1];
                                t[1] = num24;
                            }
                            return(2);
                        }
                        num23 = (-num5 + num9) * num10;
                        if (num12 <= num17)
                        {
                            if (num12 <= num23 && num23 <= num17)
                            {
                                t[num11++] = num23;
                            }
                        }
                        else if (num17 <= num23 && num23 <= num12)
                        {
                            t[num11++] = num23;
                        }
                    }
                    else
                    {
                        double num23 = -num5 / num6;
                        if (num12 <= num17)
                        {
                            if (num12 <= num23 && num23 <= num17)
                            {
                                t[num11++] = num23;
                            }
                        }
                        else if (num17 <= num23 && num23 <= num12)
                        {
                            t[num11++] = num23;
                        }
                    }
                    if (num11 == 2 && t[0] > t[1])
                    {
                        double num25 = t[0];
                        t[0] = t[1];
                        t[1] = num25;
                    }
                    return(num11);
                }
            }
        }
Ejemplo n.º 28
0
 // Token: 0x06000211 RID: 529 RVA: 0x0000AEE3 File Offset: 0x000090E3
 public UnitVector2(Vector2 v)
 {
     MathBase.AssertUnitVector(v);
     this.v = v;
 }