Ejemplo n.º 1
0
        public List <Point2F> sample_curve(Polyline p, double step)
        {
            // divide curve evenly. There is a bug in CamBam's divide by step routine (duplicate points), while 'divide to n equal segments' should work ok.
            // execution speed may be worse, but who cares
            double length = p.GetPerimeter();
            int    nsegs  = (int)Math.Max(Math.Ceiling(length / step), 1);

            List <Point2F> points = new List <Point2F>();

            foreach (Point3F pt in PointListUtils.CreatePointlistFromPolyline(p, nsegs).Points)
            {
                points.Add((Point2F)pt);
            }

            return(points);
        }
Ejemplo n.º 2
0
        public List <Point2F> sample_curve_exact(Polyline p, double step)
        {
            List <Point2F> points = new List <Point2F>();

            foreach (Point3F pt in PointListUtils.CreatePointlistFromPolylineStep(p, step).Points)
            {
                points.Add((Point2F)pt);
            }

            Point2F last_sample = points[points.Count - 1];
            Point2F poly_end    = (Point2F)p.LastPoint;

            if (last_sample.DistanceTo(poly_end) > step * 0.001)
            {
                points.Add(poly_end);
            }

            return(points);
        }