/// <summary>
        /// Divide <c>LineSegment2D</c> on straight lines polygon.
        /// </summary>
        /// <param name="start">The start point of segment.</param>
        /// <param name="source">The segment to discretization.</param>
        /// <param name="target">The <c>Polygon2D</c> as target of discretization.</param>
        public void Discretize(Point start, ISegment2D source, IPolygon2D target)
        {
            double length = source.GetLength(ref start);

            if (numberOfTiles > 1 || length > lengthOfTile)
            {
                int           tiles   = Math.Max(numberOfTiles, (int)Math.Ceiling(length / lengthOfTile));
                LineSegment2D segment = source as LineSegment2D;
                Vector        u       = Point.Subtract(segment.EndPoint, start) / tiles;
                Point         pt      = start;
                for (int i = 1; i < tiles; ++i)
                {
                    pt = Point.Add(pt, u);
                    target.Add(pt);
                }
            }

            target.Add(source.EndPoint);
        }
Example #2
0
 /// <summary>
 /// Copies the source into a new instance of <c>LineSegment2D</c>.
 /// </summary>
 /// <param name="source">The source.</param>
 public LineSegment2D(LineSegment2D source)
 {
     EndPoint = source.EndPoint;
 }