Collinear() public static method

Detects if three points are collinear.
public static Collinear ( PointF pt1, PointF pt2, PointF pt3 ) : bool
pt1 System.Drawing.PointF
pt2 System.Drawing.PointF
pt3 System.Drawing.PointF
return bool
Beispiel #1
0
        /// <summary>
        ///   Checks if the selected points will result in a degenerate homography.
        /// </summary>
        ///
        private bool degenerate(int[] points)
        {
            PointF[] x1 = this.pointSet1.Submatrix(points);
            PointF[] x2 = this.pointSet2.Submatrix(points);

            // If any three of the four points in each set is collinear,
            //  the resulting homography matrix will be degenerate.

            return(Tools.Collinear(x1[0], x1[1], x1[2]) ||
                   Tools.Collinear(x1[0], x1[1], x1[3]) ||
                   Tools.Collinear(x1[0], x1[2], x1[3]) ||
                   Tools.Collinear(x1[1], x1[2], x1[3]) ||

                   Tools.Collinear(x2[0], x2[1], x2[2]) ||
                   Tools.Collinear(x2[0], x2[1], x2[3]) ||
                   Tools.Collinear(x2[0], x2[2], x2[3]) ||
                   Tools.Collinear(x2[1], x2[2], x2[3]));
        }
Beispiel #2
0
        public void ColinearTest1()
        {
            bool   actual;
            PointF pt1, pt2, pt3;

            pt1 = new PointF(0, 0);
            pt2 = new PointF(1, 1);
            pt3 = new PointF(2, 2);

            actual = Tools.Collinear(pt1, pt2, pt3);
            Assert.AreEqual(true, actual);


            pt1 = new PointH(0, 1);
            pt2 = new PointH(1, 1);
            pt3 = new PointH(2, 2);

            actual = Tools.Collinear(pt1, pt2, pt3);
            Assert.AreEqual(false, actual);
        }
Beispiel #3
0
        public void ColinearTest()
        {
            bool actual;

            PointH p1 = new PointH(0, 1);
            PointH p2 = new PointH(0, 2);
            PointH p3 = new PointH(0, 3);

            bool expected = true;

            actual = Tools.Collinear(p1, p2, p3);
            Assert.AreEqual(expected, actual);


            p1 = new PointH(0, 1);
            p2 = new PointH(1, 0);
            p3 = new PointH(1, 1);

            expected = false;
            actual   = Tools.Collinear(p1, p2, p3);
            Assert.AreEqual(expected, actual);
        }