コード例 #1
0
        private Polygon CreateThreePointPolygon(List<PointF> pointList)
        {
            PolyPoint p0 = new PolyPoint(pointList[0]);
            PolyPoint p1 = new PolyPoint(pointList[1]);
            PolyPoint p2 = new PolyPoint(pointList[2]);

            double zeroToOne = GetSlope(pointList[0], pointList[1]);
            double zeroToTwo = GetSlope(pointList[0], pointList[2]);

            // The slope of oneToOne is more negative
            // than oneToTwo. Thus, to maintain clockwise
            // order, pointList[1] is the PolyPoint.next
            // of pointList[0].
            if (zeroToOne < zeroToTwo)
            {
                p0.next = p1;
                p0.prev = p2;
                p1.next = p2;
                p1.prev = p0;
                p2.next = p0;
                p2.prev = p1;
            }
            else
            {
                p0.next = p2;
                p0.prev = p1;
                p1.next = p0;
                p1.prev = p2;
                p2.next = p1;
                p2.prev = p0;
            }

            return new Polygon(p0, p2);
        }
コード例 #2
0
        private Polygon CreateTwoPointPolygon(List<PointF> pointList)
        {
            PolyPoint p1 = new PolyPoint(pointList[0]);
            PolyPoint p2 = new PolyPoint(pointList[1]);

            p1.next = p2;
            p1.prev = p2;

            p2.next = p1;
            p2.prev = p1;

            return new Polygon(p1, p2);
        }