Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mat"></param>
        public override void TransformBy(Matrix2D mat)
        {
            var vec1 = GetPointAtParam((StartParam + EndParam) / 2) - Center;

            Center *= mat;
            var vec = Vector2D.XAxis * mat;

            Radius *= vec.Length;
            if (!Closed)
            {
                var vec0 = new Vector2D(Radius, StartAngle) * mat;
                vec1 *= mat;
                var vec2 = new Vector2D(Radius, EndAngle) * mat;
                StartAngle  = vec0.Angle;
                EndAngle    = vec2.Angle;
                IsClockWise = Vector2D.IsClockWise(vec0, vec1, vec2);
            }
        }
Esempio n. 2
0
        public CircleArc2D(Point2D pt1, Point2D pt2, Point2D pt3, bool isWholeCircle)
        {
            if (isWholeCircle)
            {
                var xy1 = Math.Pow(pt1.X, 2) + Math.Pow(pt1.Y, 2);
                var xy2 = xy1 - Math.Pow(pt3.X, 2) - Math.Pow(pt3.Y, 2);
                var xy3 = xy1 - Math.Pow(pt2.X, 2) - Math.Pow(pt2.Y, 2);
                xy1 = (pt1.X - pt2.X) * (pt1.Y - pt3.Y) - (pt1.X - pt3.X) * (pt1.Y - pt2.Y);
                if (GeoUtils.Equals(xy1, 0))
                {
                    throw new Exception("无法创建圆!");
                }

                Center =
                    new Point2D(
                        (xy3 * (pt1.Y - pt3.Y) - xy2 * (pt1.Y - pt2.Y)) / (2 * xy1),
                        (xy2 * (pt1.X - pt2.X) - xy3 * (pt1.X - pt3.X)) / (2 * xy1));

                Radius = (pt1 - Center).Length;
                if (GeoUtils.Equals(Radius, 0))
                {
                    throw new Exception("半径为零!");
                }

                StartAngle = Angle.Zero;
                EndAngle   = Angle.Degree360;
            }
            else
            {
                CircleArc2D cir = new CircleArc2D(pt1, pt2, pt3, true);
                Center = cir.Center;
                Radius = cir.Radius;

                IsClockWise =
                    Vector2D.IsClockWise(
                        pt1 - cir.Center,
                        pt2 - cir.Center,
                        pt3 - cir.Center);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mat"></param>
        public override void TransformBy(Matrix2D mat)
        {
            var pt0 = GetPointAtParam(StartParam);
            var pt1 = GetPointAtParam((StartParam + EndParam) / 2);
            var pt2 = GetPointAtParam(EndParam);

            pt0 *= mat;
            pt1 *= mat;
            pt2 *= mat;
            var vec = MinorAxis * mat;

            Minor    = vec.Length;
            vec      = MajorAxis * mat;
            Major    = vec.Length;
            Center  *= mat;
            Rotation = vec.Angle;
            var vec0 = pt0 - Center;
            var vec2 = pt2 - Center;

            StartAngle  = vec0.Angle - Rotation;
            EndAngle    = vec2.Angle - Rotation;
            IsClockWise = Vector2D.IsClockWise(vec0, pt1 - Center, vec2);
        }