Exemple #1
0
        static public Point2d[] LineLine(Line2d lin1, Line2d lin2)
        {
            double s, t;

            if (!LineLineParametric(lin1, lin2, out s, out t))
            {
                return(null);
            }
            return(new Point2d[] { lin1.PointAt(s) });
        }
Exemple #2
0
        static public Point2d LineLineAsPoint(Line2d lin1, Line2d lin2)
        {
            double s, t;

            if (!LineLineParametric(lin1, lin2, out s, out t))
            {
                return(null);
            }
            return(lin1.PointAt(s));
        }
Exemple #3
0
        const double seg_maxparam = 1.0;    //used as max limit for parameters beeing on a segment

        #region PRIVATE_UTILS

        /// <summary>
        /// Converts an array of line parameters to an array of points, limited
        /// by a minimum and maximum parameter. On emty result, null is returned,
        /// otherwise a list of points along the line.
        /// </summary>
        private static Point2d[] LineParamsToPoints(double[] ts, Line2d l, double mint, double maxt)
        {
            if (ts == null)
            {
                return(null);
            }
            int n = ts.Length;

            if (n <= 0)
            {
                return(null);
            }

            Point2d[] res = new Point2d[n];
            int       idx = 0;

            for (int q = 0; q < n; q++)
            {
                double t = ts[q];
                if (t >= mint && t <= maxt)
                {
                    res[idx++] = l.PointAt(ts[q]);
                }
            }

            if (idx == 0)
            {
                return(null);    //all params out of range
            }
            if (idx != n)
            {
                Array.Resize(ref res, idx);
            }

            return(res);
        }