Пример #1
0
        public Edge method_6(Ellipse ellipse)
        {
            Vector3d nCF_normal          = this.NCF_normal;
            Vector3d semimajorAxisVector = ellipse.SemimajorAxisVector;
            Vector3d semiminorAxisVector = ellipse.SemiminorAxisVector;
            double   num  = nCF_normal * semimajorAxisVector;
            double   num2 = nCF_normal * semiminorAxisVector;
            double   num3 = this.NCF_d - nCF_normal * ellipse.Center.method_2();
            double   num4 = num * num + num2 * num2;
            double   num5 = num4 - num3 * num3;

            if (Global.AlmostEquals(num * num + num2 * num2, num3 * num3))
            {
                num5 = 0.0;
            }
            if (num5 < 0.0)
            {
                return(null);
            }
            if (Global.AlmostEquals(Math.Abs(num), Math.Abs(num2)))
            {
                return(null);
            }
            double num6       = 1.0 / num4;
            double scalar     = (num2 * num3 - num * Math.Sqrt(num5)) * num6;
            double scalar2    = (num * num3 + num2 * Math.Sqrt(num5)) * num6;
            double scalar3    = (num2 * num3 + num * Math.Sqrt(num5)) * num6;
            double scalar4    = (num * num3 - num2 * Math.Sqrt(num5)) * num6;
            Point  startPoint = ellipse.Center + new Point(scalar2 * semimajorAxisVector + scalar * semiminorAxisVector);
            Point  endPoint   = ellipse.Center + new Point(scalar4 * semimajorAxisVector + scalar3 * semiminorAxisVector);

            return(new Edge(startPoint, endPoint));
        }
Пример #2
0
        public Edge method_5(Circle circle)
        {
            Line line = this.method_2(circle.GetPlane());

            if (line == null)
            {
                return(null);
            }
            Edge   edge = circle.Center.PerpendicularOn(line);
            double num  = circle.Radius * circle.Radius;
            double num2 = edge.StartPoint.method_3(edge.EndPoint);
            double num3 = num - num2;

            if (Global.AlmostEquals(num, num2))
            {
                num3 = 0.0;
            }
            if (num3 < 0.0)
            {
                return(null);
            }
            line.DirectionVector.Norm = Math.Sqrt(num3);
            Point startPoint = edge.EndPoint + line.DirectionVector.ToPoint();
            Point endPoint   = edge.EndPoint - line.DirectionVector.ToPoint();

            return(new Edge(startPoint, endPoint));
        }
Пример #3
0
        public bool IsParallelTo(Vector3d a)
        {
            double num   = Vector3d.Dot(this, this);
            double value = Vector3d.Dot(this, a);
            double num2  = Vector3d.Dot(a, a);

            return(Global.AlmostEquals(Math.Abs(value), Math.Sqrt(num * num2)));
        }
Пример #4
0
        internal bool method_9(Point point_1)
        {
            Point  pointAtParameter = this.GetPointAtParameter(this.GetParameterAtPoint(point_1));
            double num  = pointAtParameter.DistanceTo(this.point_0);
            double num2 = point_1.DistanceTo(this.point_0);

            return(Global.AlmostEquals(num, num2) || num2 - num < Global.AbsoluteEpsilon);
        }
Пример #5
0
        public bool CollinearContains(Point point)
        {
            double num  = point.DistanceTo(this.startPoint);
            double num2 = point.DistanceTo(this.endPoint);
            double b    = this.startPoint.DistanceTo(this.endPoint);

            return(Global.AlmostEquals(num + num2, b));
        }
Пример #6
0
        public bool ContainsOnCircumference(Point point)
        {
            if (!point.IsCoplanarTo(this))
            {
                return(false);
            }
            double a = point.DistanceTo(this.point_0);

            return(Global.AlmostEquals(a, this.double_0));
        }
Пример #7
0
        public bool Contains(Point point)
        {
            if (!point.IsCoplanarTo(this))
            {
                return(false);
            }
            double num = point.DistanceTo(this.point_0);

            return(Global.AlmostEquals(num, this.double_0) || num - this.Radius < Global.AbsoluteEpsilon);
        }
Пример #8
0
        public bool Contains(Point point)
        {
            if (point == null)
            {
                return(false);
            }
            double a = this.vector3d_2.X * point.X + this.vector3d_2.Y * point.Y + this.vector3d_2.Z * point.Z;

            return(Global.AlmostEquals(a, this.double_0));
        }
Пример #9
0
        public bool Contains(Circle circle)
        {
            if (!this.IsCoplanarTo(circle))
            {
                return(false);
            }
            double num  = circle.point_0.DistanceTo(this.point_0);
            double num2 = num + circle.Radius;

            return(Global.AlmostEquals(num2, this.double_0) || num2 - this.double_0 < Global.AbsoluteEpsilon);
        }
Пример #10
0
        public bool Contains(Point point)
        {
            if (!point.IsCoplanarTo(this))
            {
                return(false);
            }
            Point  pointAtParameter = this.GetPointAtParameter(this.GetParameterAtPoint(point));
            double num  = pointAtParameter.DistanceTo(this.point_0);
            double num2 = point.DistanceTo(this.point_0);

            return(Global.AlmostEquals(num, num2) || num2 - num < Global.AbsoluteEpsilon);
        }
Пример #11
0
        public bool CollinearContainsXY(Point point)
        {
            double num  = this.startPoint.X - this.endPoint.X;
            double num2 = this.startPoint.Y - this.endPoint.Y;
            double num3 = this.startPoint.X - point.X;
            double num4 = this.startPoint.Y - point.Y;
            double num5 = this.endPoint.X - point.X;
            double num6 = this.endPoint.Y - point.Y;
            double b    = Math.Sqrt(num * num + num2 * num2);
            double num7 = Math.Sqrt(num3 * num3 + num4 * num4);
            double num8 = Math.Sqrt(num5 * num5 + num6 * num6);

            return(Global.AlmostEquals(num7 + num8, b));
        }
Пример #12
0
        public PointSet method_1(Circle circle)
        {
            if (!this.IsCoplanarTo(circle))
            {
                return(null);
            }
            PointSet pointSet  = new PointSet();
            Vector3d vector3d  = this.point_0.method_2();
            Vector3d left      = vector3d + this.DirectionVector;
            Vector3d vector3d2 = circle.Center.method_2();
            Vector3d vector3d3 = left - vector3d;
            Vector3d right     = vector3d - vector3d2;
            Edge     edge      = circle.Center.PerpendicularOn(this);

            if (Global.AlmostEquals(edge.Length, circle.Radius))
            {
                pointSet.Add(edge.EndPoint);
                return(pointSet);
            }
            double num  = vector3d3 * vector3d3;
            double num2 = 2.0 * (vector3d3 * right);
            double num3 = vector3d * vector3d - 2.0 * (vector3d * vector3d2) + vector3d2 * vector3d2 - circle.Radius * circle.Radius;
            double num4 = num2 * num2 - 4.0 * num * num3;

            if (Global.AlmostEquals(num2 * num2, 4.0 * num * num3))
            {
                num4 = 0.0;
            }
            if (Math.Abs(num4) < Global.AbsoluteEpsilon)
            {
                double scalar = -num2 / (2.0 * num);
                Point  point  = new Point(vector3d + scalar * vector3d3);
                pointSet.Add(point);
                return(pointSet);
            }
            if (num4 > Global.AbsoluteEpsilon)
            {
                double scalar2 = (-num2 + Math.Sqrt(num4)) / (2.0 * num);
                double scalar3 = (-num2 - Math.Sqrt(num4)) / (2.0 * num);
                Point  point2  = new Point(vector3d + scalar2 * vector3d3);
                Point  point3  = new Point(vector3d + scalar3 * vector3d3);
                pointSet.Add(point2);
                if (point2 != point3)
                {
                    pointSet.Add(point3);
                }
                return(pointSet);
            }
            return(pointSet);
        }
Пример #13
0
        public bool ContainsOnCircumference(Point point)
        {
            if (!point.IsCoplanarTo(this))
            {
                return(false);
            }
            PointSet focalPoints = this.FocalPoints;
            Point    point2      = focalPoints[0];
            Point    point3      = focalPoints[1];
            double   num         = point2.DistanceTo(point);
            double   num2        = point3.DistanceTo(point);
            double   b           = 2.0 * this.SemimajorAxisVector.Norm;

            return(Global.AlmostEquals(num + num2, b));
        }
Пример #14
0
        public bool ContainsOnCircumference(Point point)
        {
            if (!this.ToCircle().ContainsOnCircumference(point))
            {
                return(false);
            }
            Vector3d a   = new Vector3d(this.point_1 - this.point_0);
            Vector3d b   = new Vector3d(point - this.point_0);
            double   num = Vector3d.OrientedAngle(a, b, this.vector3d_0);

            if (Global.AlmostEquals(num, 6.2831853071795862, 1E-08, 1E-08))
            {
                num = 0.0;
            }
            return(num <= this.double_0 || Global.AlmostEquals(num, this.double_0, 1E-08, 1E-08));
        }
Пример #15
0
 public static bool operator ==(Circle left, Circle right)
 {
     if ((object)left == (object)right)
     {
         return(true);
     }
     if ((object)left == null || (object)right == null)
     {
         return(false);
     }
     if (!(left.point_0 == right.point_0) || !Global.AlmostEquals(left.Radius, right.Radius))
     {
         return(false);
     }
     return(left.NormalVector.IsParallelTo(right.NormalVector));
 }
Пример #16
0
        public bool IsSkewTo(Line line)
        {
            Vector3d vector3d = new Vector3d(line.Point - this.point_0);

            if (vector3d.Norm < Global.AbsoluteEpsilon)
            {
                return(false);
            }
            Vector3d vector3d2 = vector3d.Normalize();
            Vector3d vector3d3 = this.DirectionVector.Normalize();
            Vector3d vector3d4 = line.DirectionVector.Normalize();
            double   a         = vector3d2.X * vector3d3.Y * vector3d4.Z + vector3d2.Y * vector3d3.Z * vector3d4.X + vector3d2.Z * vector3d3.X * vector3d4.Y;
            double   b         = vector3d2.Z * vector3d3.Y * vector3d4.X + vector3d2.Y * vector3d3.X * vector3d4.Z + vector3d2.X * vector3d3.Z * vector3d4.Y;

            return(!Global.AlmostEquals(a, b));
        }
Пример #17
0
        public Arc(Point center, Vector3d startVector, Vector3d endVector, Vector3d normalVector)
        {
            this.point_0    = center;
            this.point_1    = center + startVector.ToPoint();
            this.vector3d_0 = normalVector;
            double num = Vector3d.OrientedAngle(startVector, endVector, normalVector);

            this.double_0 = num;
            if (!Global.AlmostEquals(startVector.Norm, endVector.Norm))
            {
                throw new ArgumentException("Error constructing arc: start vector length not equal end vector length.");
            }
            if (!startVector.IsOrthogonalTo(normalVector) && !endVector.IsOrthogonalTo(normalVector))
            {
                throw new ArgumentException("Error constructing arc: Normal vector not orthogonal to start and end vector.");
            }
        }
Пример #18
0
 public static bool operator ==(Ellipse left, Ellipse right)
 {
     if ((object)left == (object)right)
     {
         return(true);
     }
     if ((object)left == null || (object)right == null)
     {
         return(false);
     }
     if (left.point_0 != right.point_0)
     {
         return(false);
     }
     if (left.IsCircular & right.IsCircular)
     {
         return(Global.AlmostEquals(left.vector3d_0.Norm, right.vector3d_0.Norm) | Global.AlmostEquals(left.vector3d_0.Norm, right.vector3d_1.Norm) | Global.AlmostEquals(left.vector3d_1.Norm, right.vector3d_0.Norm) | Global.AlmostEquals(left.vector3d_1.Norm, right.vector3d_1.Norm));
     }
     return((left.vector3d_0.IsParallelTo(right.vector3d_0) & Global.AlmostEquals(left.vector3d_0.Norm, right.vector3d_0.Norm)) && (left.vector3d_1.IsParallelTo(right.vector3d_1) & Global.AlmostEquals(left.vector3d_1.Norm, right.vector3d_1.Norm)));
 }
Пример #19
0
        public Line method_2(Plane plane)
        {
            double   num             = Vector3d.Dot(this.vector3d_2, this.vector3d_2);
            double   num2            = Vector3d.Dot(this.vector3d_2, plane.vector3d_2);
            double   num3            = Vector3d.Dot(plane.vector3d_2, plane.vector3d_2);
            Vector3d directionVector = Vector3d.Cross(this.vector3d_2, plane.vector3d_2);
            double   num4            = num * num3;
            double   num5            = num2 * num2;

            if (Global.AlmostEquals(num4, num5))
            {
                return(null);
            }
            double num6 = 1.0 / (num4 - num5);
            double num7 = (this.d * num3 - plane.d * num2) * num6;
            double num8 = (plane.d * num - this.d * num2) * num6;
            double x    = num7 * this.vector3d_2.X + num8 * plane.vector3d_2.X;
            double y    = num7 * this.vector3d_2.Y + num8 * plane.vector3d_2.Y;
            double z    = num7 * this.vector3d_2.Z + num8 * plane.vector3d_2.Z;

            return(new Line(new Point(x, y, z), directionVector));
        }
Пример #20
0
        public double GetParameterAtPoint(Point point)
        {
            Vector3d vector3d = new Vector3d(point - this.point_0);

            if (vector3d.Norm < 4.94065645841247E-324)
            {
                return(0.0);
            }
            double num  = Vector3d.Angle(this.vector3d_0, vector3d);
            double d    = Vector3d.Angle(this.vector3d_1, vector3d);
            double num2 = Math.Cos(num);
            double num3 = Math.Cos(d);

            if (Global.AlmostEquals(num3, 1.0))
            {
                return(1.5707963267948966);
            }
            if (Global.AlmostEquals(num3, -1.0))
            {
                return(4.71238898038469);
            }
            double num4 = Math.Atan(this.vector3d_0.Norm / this.vector3d_1.Norm * Math.Tan(num));

            if (num2 >= 0.0 && num3 >= 0.0)
            {
                return(num4);
            }
            if (num2 <= 0.0 && num3 >= 0.0)
            {
                return(3.1415926535897931 + num4);
            }
            if (num2 <= 0.0 && num3 <= 0.0)
            {
                return(3.1415926535897931 - num4);
            }
            return(6.2831853071795862 - num4);
        }
Пример #21
0
 public static bool operator ==(Point left, Point right)
 {
     if ((object)left == (object)right)
     {
         return(true);
     }
     if ((object)left == null || (object)right == null)
     {
         return(false);
     }
     if (!Global.AlmostEquals(left.double_0, right.double_0))
     {
         return(false);
     }
     if (!Global.AlmostEquals(left.double_1, right.double_1))
     {
         return(false);
     }
     if (!Global.AlmostEquals(left.double_2, right.double_2))
     {
         return(false);
     }
     return(true);
 }
Пример #22
0
 public static bool operator ==(Vector3d left, Vector3d right)
 {
     return((object)left == (object)right || ((object)left != null && (object)right != null && Global.AlmostEquals(left.x, right.x) && Global.AlmostEquals(left.y, right.y) && Global.AlmostEquals(left.z, right.z)));
 }
Пример #23
0
 internal static bool smethod_1(Vector3d vector3d_0, Vector3d vector3d_1)
 {
     return(Global.AlmostEquals(-vector3d_0.x * vector3d_1.x, vector3d_0.y * vector3d_1.y + vector3d_0.z * vector3d_1.z) | Global.AlmostEquals(-vector3d_0.y * vector3d_1.y, vector3d_0.x * vector3d_1.x + vector3d_0.z * vector3d_1.z) | Global.AlmostEquals(-vector3d_0.z * vector3d_1.z, vector3d_0.y * vector3d_1.y + vector3d_0.x * vector3d_1.x));
 }
Пример #24
0
        public bool Contains(Point point)
        {
            Vector3d vector3d  = new Vector3d(point - this.point_0);
            Vector3d vector3d2 = this.vector3d_0.Normalize();

            return(Global.AlmostEquals(vector3d.Y * vector3d2.Z, vector3d.Z * vector3d2.Y) & Global.AlmostEquals(vector3d.Z * vector3d2.X, vector3d.X * vector3d2.Z) & Global.AlmostEquals(vector3d.X * vector3d2.Y, vector3d.Y * vector3d2.X));
        }
Пример #25
0
        public List <Line> TangentLines2d(Circle circle)
        {
            if (!circle.IsCoplanarTo(this))
            {
                return(null);
            }
            List <Line> list = new List <Line>();

            if (this.Contains(circle))
            {
                return(list);
            }
            if (circle.Contains(this))
            {
                return(list);
            }
            Vector3d vector3d = new Vector3d(circle.point_0 - this.point_0);

            if (this.Intersects2d(circle))
            {
                if (Global.AlmostEquals(this.double_0, circle.double_0))
                {
                    Vector3d b         = new Vector3d(this.point_0 - circle.point_0);
                    Vector3d vector3d2 = Vector3d.Cross(this.NormalVector, b);
                    vector3d2.Norm = this.double_0;
                    list.Add(new Line(this.point_0, circle.point_0).Move(vector3d2));
                    list.Add(new Line(this.point_0, circle.point_0).Move(-1.0 * vector3d2));
                    return(list);
                }
                double scalar = this.double_0 / (this.double_0 - circle.double_0);
                Point  point  = this.point_0 + scalar * vector3d.ToPoint();
                return(this.TangentLines2d(point));
            }
            else
            {
                if (Global.AlmostEquals(this.double_0, circle.double_0))
                {
                    Vector3d b2        = new Vector3d(this.point_0 - circle.point_0);
                    Vector3d vector3d3 = Vector3d.Cross(this.NormalVector, b2);
                    vector3d3.Norm = this.double_0;
                    list.Add(new Line(this.point_0, circle.point_0).Move(vector3d3));
                    list.Add(new Line(this.point_0, circle.point_0).Move(-1.0 * vector3d3));
                    double      scalar2 = this.double_0 / (this.double_0 + circle.double_0);
                    Point       point2  = this.point_0 + scalar2 * vector3d.ToPoint();
                    List <Line> list2   = this.TangentLines2d(point2);
                    foreach (Line current in list2)
                    {
                        list.Add(current);
                    }
                    return(list);
                }
                double      scalar3 = this.double_0 / (this.double_0 - circle.double_0);
                double      scalar4 = this.double_0 / (this.double_0 + circle.double_0);
                Point       point3  = this.point_0 + scalar3 * vector3d.ToPoint();
                Point       point4  = this.point_0 + scalar4 * vector3d.ToPoint();
                List <Line> list3   = this.TangentLines2d(point3);
                List <Line> list4   = this.TangentLines2d(point4);
                foreach (Line current2 in list3)
                {
                    list.Add(current2);
                }
                foreach (Line current3 in list4)
                {
                    list.Add(current3);
                }
                return(list);
            }
        }
Пример #26
0
 public static bool operator ==(Matrix3d left, Matrix3d right)
 {
     return((object)left == (object)right || ((object)left != null && (object)right != null && Global.AlmostEquals(left.double_0, right.double_0) && Global.AlmostEquals(left.double_1, right.double_1) && Global.AlmostEquals(left.double_2, right.double_2) && Global.AlmostEquals(left.double_3, right.double_3) && Global.AlmostEquals(left.double_4, right.double_4) && Global.AlmostEquals(left.double_5, right.double_5) && Global.AlmostEquals(left.double_6, right.double_6) && Global.AlmostEquals(left.double_7, right.double_7) && Global.AlmostEquals(left.double_8, right.double_8)));
 }