Esempio n. 1
0
        /**
         * Calculate the feature area of the (x,y) points to the input line
         *
         * @param points
         *            points
         * @param line
         *            line to find feature area to
         * @return feature area from the (x,y) points to the input line
         */
        public static double toLine(StylusPointCollection points, Line2D line)
        {
            double area = 0;
            double b1, b2, d, h;

            for (int i = 0; i < points.Count - 1; i++)
            {
                b1 = line.ptSegDist(points[i].X, points[i].Y);
                b2 = line.ptSegDist(points[i + 1].X, points[i + 1]
                                    .Y);
                d = distance(points[i], points[i + 1]);
                h = Math.Sqrt(Math.Abs(Math.Pow(d, 2)
                                       - Math.Pow(Math.Abs(b1 - b2), 2)));
                area += Math.Abs(0.5 * (b1 + b2) * h);
            }
            return(area);
        }
Esempio n. 2
0
        /**
         * Return the total least squares error between the array of points and the
         * input line
         *
         * @param points
         *            points
         * @param line
         *            line to find the LSE to
         * @return total least squares error between the input points and line
         */
        public static double error(StylusPointCollection points, Line2D line)
        {
            double err  = 0.0;
            double err2 = 0.0;

            for (int i = 0; i < points.Count; i++)
            {
                err  += line.ptSegDist(points[i].X, points[i].Y);
                err2 += line.ptSegDist2(points[i].X, points[i].Y);
            }
            return(err);
        }