예제 #1
0
        private void Verify()
        {
            if (points.Count < 2)
            {
                throw new ArgumentException("A Collinear relationship requires at least 2 points: " + this.ToString());
            }

            // Create a segment of the endpoints to compare all points for collinearity
            Segment line = new Segment(points[0], points[points.Count - 1]);

            foreach (Point pt in points)
            {
                if (!line.PointLiesOn(pt))
                {
                    throw new ArgumentException("Point " + pt + " is not collinear with line " + line.ToString());
                }

                if (!line.PointLiesOnAndBetweenEndpoints(pt))
                {
                    throw new ArgumentException("Point " + pt + " is not between the endpoints of segment " + line.ToString());
                }
            }
        }
예제 #2
0
        private void Verify()
        {
            if (points.Count < 2) throw new ArgumentException("A Collinear relationship requires at least 2 points: " + this.ToString());

            // Create a segment of the endpoints to compare all points for collinearity
            Segment line = new Segment(points[0], points[points.Count - 1]);

            foreach (Point pt in points)
            {
                if (!line.PointLiesOn(pt))
                {
                    throw new ArgumentException("Point " + pt + " is not collinear with line " + line.ToString());
                }

                if (!line.PointLiesOnAndBetweenEndpoints(pt))
                {
                    throw new ArgumentException("Point " + pt + " is not between the endpoints of segment " + line.ToString());
                }
            }
        }