Example #1
0
 public GeoLine(Point p1, Point p2)
 {
     P1         = p1;
     P2         = p2;
     _direction = p2 - p1;
     Length     = _direction.Length;
     _direction.Normalize();
     GraphicHelper.CalcABC(p1, p2, out A, out B, out C);
 }
Example #2
0
        public IEnumerable <Point> ToSegments(double segmentLength)
        {
            var points = GraphicHelper.ToSegments(_center, _radius, 0, Math.PI * 2, segmentLength);

            if (_isReverse)
            {
                points.Reverse();
            }
            return(points);
        }
Example #3
0
        public IEnumerable <Point> ToSegments(double segmentLength)
        {
            var points = GraphicHelper.ToSegments(_degree, _controlPoints, _knots, _weights, _startParameter, _endParameter, _length, segmentLength);

            if (_isReverse)
            {
                points.Reverse();
            }
            return(points);
        }
Example #4
0
        public IEnumerable <Point> ToSegments(double segmentLength)
        {
            var points = GraphicHelper.ToSegments(_center, _radius, Utilities.AngleToRadian(_startAngle), Utilities.AngleToRadian(_endAngle), segmentLength);

            if (_isReverse)
            {
                points.Reverse();
            }
            return(points);
        }
Example #5
0
        public IEnumerable <Point> ToSegments(double segmentLength)
        {
            var vector    = (Vector)_center;
            var transform = GraphicHelper.CreateRotateMatrix(_center, _rotateAngle);
            var points    = GraphicHelper.ToSegments(_lr, _sr, 0, Math.PI * 2, segmentLength);

            if (_isReverse)
            {
                points.Reverse();
            }
            return(points.Select(p => (p + vector) * transform));
        }
Example #6
0
        public IGraphic Extend(double distance, double segmentLength, JointType jointType, IEnumerable <Segment> segments = null)
        {
            var      start   = Start;
            var      end     = End;
            var      vec     = GraphicHelper.GetVector(end - start) * distance;
            IGraphic graphic = new GraphicLine(start + vec, end + vec);

            if (segments != null)
            {
                graphic = new GraphicCompositeCurve(graphic.Spilt(segments, segmentLength), false);
            }
            return(graphic);
        }
Example #7
0
        public Point GetPoint(double length, double segmentLength)
        {
            if (length < 0 || length > Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (_isReverse)
            {
                length = Length - length;
            }
            var parameter = GraphicHelper.GetParameter(_lr, _sr, 0, length, segmentLength);

            return(_center + new Vector(_lr * Math.Cos(parameter), _sr * Math.Sin(parameter)) * GraphicHelper.CreateRotateMatrix(_center, _rotateAngle));
        }
Example #8
0
        public Point GetPoint(double length, double segmentLength)
        {
            if (length < 0 || length > Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (_isReverse)
            {
                length = Length - length;
            }
            var parameter = GraphicHelper.GetParameter(_degree, _controlPoints, _knots, _weights, _startParameter, length, _length, segmentLength);

            return(GraphicHelper.ComputePoint(_degree, _knots, _controlPoints, _weights, parameter));
        }
Example #9
0
        public GraphicEllipse(Point center, double lr, double sr, double rotateAngle, bool isClockwise = false)
        {
            if (lr <= 0 || sr <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            _center      = center;
            _lr          = lr;
            _sr          = sr;
            _rotateAngle = rotateAngle;
            _isReverse   = isClockwise;
            _length      = GraphicHelper.ComputeArcLength(_lr, _sr, 0, Math.PI * 2, Math.PI / 4);
        }
Example #10
0
        public GraphicPolyLine(IEnumerable <Point> points)
        {
            if (points == null)
            {
                throw new ArgumentNullException();
            }

            _points = GraphicHelper.FilterRepeat(points).ToList();
            if (_points.Count < 2)
            {
                throw new ArgumentOutOfRangeException();
            }

            _length = GraphicHelper.CalcLength(_points);
        }
Example #11
0
 public IGraphic Extend(double distance, double segmentLength, JointType jointType, IEnumerable <Segment> segments = null)
 {
     if (_isContinuously)
     {
         return(GraphicHelper.Extend(_ToSegments(segmentLength).ToList(), distance, jointType, segments, IsClosed));
     }
     else
     {
         var graphics = _graphics.Select(graphic => graphic.Extend(distance, segmentLength, jointType));
         if (graphics.Any(graphic => graphic == null))
         {
             return(null);
         }
         return(new GraphicCompositeCurve(graphics, _isContinuously));
     }
 }
Example #12
0
 public IEnumerable <IGraphic> Spilt(IEnumerable <Segment> segments, double segmentLength)
 {
     foreach (var segment in segments)
     {
         var startOffset = segment.StartOffset;
         var endOffset   = segment.EndOffset;
         if (_isReverse)
         {
             startOffset = _length - segment.EndOffset;
             endOffset   = _length - segment.StartOffset;
         }
         var startAngle = Utilities.RadianToAngle(GraphicHelper.GetParameter(_lr, _sr, 0, startOffset, segmentLength));
         var endAngle   = Utilities.RadianToAngle(GraphicHelper.GetParameter(_lr, _sr, 0, endOffset, segmentLength));
         yield return(new GraphicEllipticalArc(_center, _lr, _sr, startAngle, endAngle, _rotateAngle, _isReverse));
     }
 }
Example #13
0
        public GraphicBezier(int degree, IEnumerable <Point> controlPoints, bool isReverse = false)
        {
            if (controlPoints == null)
            {
                throw new ArgumentNullException();
            }

            _degree        = degree;
            _controlPoints = controlPoints.ToArray();
            if (_controlPoints.Length < 2)
            {
                throw new ArgumentException();
            }
            _isReverse = isReverse;

            _length = GraphicHelper.ComputeArcLength(_controlPoints, _degree, 0, 1, 0.1);
        }
Example #14
0
        public Vector GetTangent(double length, double segmentLength)
        {
            if (length < 0 || length > Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (_isReverse)
            {
                length = Length - length;
            }
            var parameter = GraphicHelper.GetParameter(_degree, _controlPoints, _knots, _weights, _startParameter, length, _length, segmentLength);
            var dir       = GraphicHelper.ComputeVector(_degree, 1, _knots, _controlPoints, parameter);

            if (_isReverse)
            {
                dir = -dir;
            }
            return(dir);
        }
Example #15
0
        public Vector GetTangent(double length, double segmentLength)
        {
            if (length < 0 || length > Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (_isReverse)
            {
                length = Length - length;
            }
            var parameter = GraphicHelper.GetParameter(_lr, _sr, 0, length, segmentLength);
            var dir       = new Vector(-_lr * Math.Sin(parameter), _sr * Math.Cos(parameter));

            if (_isReverse)
            {
                dir = -dir;
            }
            return(dir);
        }
Example #16
0
        public GraphicEllipticalArc(Point center, double lr, double sr, double startAngle, double endAngle, double rotateAngle, bool isClockwise = false)
        {
            if (lr < 0 || sr < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (startAngle > endAngle)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (endAngle - startAngle > 360)
            {
                throw new ArgumentException();
            }

            _center      = center;
            _lr          = lr;
            _sr          = sr;
            _startAngle  = startAngle;
            _endAngle    = endAngle;
            _rotateAngle = rotateAngle;
            _isReverse   = isClockwise;
            _length      = GraphicHelper.ComputeArcLength(_lr, _sr, Utilities.AngleToRadian(_startAngle), Utilities.AngleToRadian(_endAngle), Math.PI / 4);
        }
Example #17
0
        public IEnumerable <IGraphic> Spilt(IEnumerable <Segment> segments, double segmentLength)
        {
            var points = ToSegments(segmentLength).ToList();

            return(GraphicHelper.Spilt(points, _length, segments));
        }
Example #18
0
 public IGraphic Extend(double distance, double segmentLength, JointType jointType, IEnumerable <Segment> segments = null)
 {
     return(GraphicHelper.Extend(ToSegments(segmentLength).ToList(), distance, jointType, segments, IsClosed));
 }
Example #19
0
 private void _Init()
 {
     _length = GraphicHelper.ComputeArcLength(_degree, _knots, _controlPoints, _weights, _startParameter, _endParameter, 0.1);
     _start  = GraphicHelper.ComputePoint(_degree, _knots, _controlPoints, _weights, _startParameter);
     _end    = GraphicHelper.ComputePoint(_degree, _knots, _controlPoints, _weights, _endParameter);
 }
Example #20
0
 public IEnumerable <IGraphic> Spilt(IEnumerable <Segment> segments, double segmentLength)
 {
     return(GraphicHelper.Spilt(_points, _length, segments));
 }
Example #21
0
 public IEnumerable <Point> ToSegments(double segmentLength)
 {
     return(GraphicHelper.ToSegments(_p1, _p2, segmentLength));
 }