コード例 #1
0
        private void DoIntersectionTest(int i, double incidentAngleFactor)
        {
            var basePt = RandomCoordinate();

            double baseAngle = 2 * Math.PI * RandGen.NextDouble();

            var p1 = ComputeVector(basePt, baseAngle, 0.1 * SEG_LEN);
            var p2 = ComputeVector(basePt, baseAngle, 1.1 * SEG_LEN);

            double angleBetween = baseAngle + incidentAngleFactor * Math.PI;

            var q1 = ComputeVector(basePt, angleBetween, 0.1 * SEG_LEN);
            var q2 = ComputeVector(basePt, angleBetween, 1.1 * SEG_LEN);

            var intPt     = IntersectionAlgorithms.IntersectionBasic(p1, p2, q1, q2);
            var intPtDD   = CGAlgorithmsDD.Intersection(p1, p2, q1, q2);
            var intPtCB   = IntersectionAlgorithms.IntersectionCB(p1, p2, q1, q2);
            var intPtCond = IntersectionComputer.Intersection(p1, p2, q1, q2);

            if (Verbose)
            {
                Console.WriteLine(i + ":  Lines: "
                                  + WKTWriter.ToLineString(p1, p2) + "  -  "
                                  + WKTWriter.ToLineString(q1, q2));
            }

            PrintStats("DP    ", intPt, p1, p2, q1, q2);
            PrintStats("CB    ", intPtCB, p1, p2, q1, q2);
            PrintStats("Cond  ", intPtCond, p1, p2, q1, q2);
            PrintStats("DD    ", intPtDD, p1, p2, q1, q2);
        }
コード例 #2
0
 public static bool IsAllOrientationsEqualDD(Coordinate[] pts)
 {
     int[] orient = new int[3];
     orient[0] = CGAlgorithmsDD.OrientationIndex(pts[0], pts[1], pts[2]);
     orient[1] = CGAlgorithmsDD.OrientationIndex(pts[1], pts[2], pts[0]);
     orient[2] = CGAlgorithmsDD.OrientationIndex(pts[2], pts[0], pts[1]);
     return(orient[0] == orient[1] && orient[0] == orient[2]);
 }
コード例 #3
0
        public void TestIntersection()
        {
            var p1    = new Coordinate(413219.0849208352, 990424.3721256976);
            var p2    = new Coordinate(413217.6678330222, 990524.3620845041);
            var q1    = new Coordinate(413216.2715430226, 990404.8197292066);
            var q2    = new Coordinate(413186.72067708324, 990309.2857231029);
            var intPt = CGAlgorithmsDD.Intersection(p1, p2, q1, q2);

            Assert.IsTrue(intPt != null);
        }
コード例 #4
0
        public static Coordinate IntersectionDDWithFilter(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
        {
            var intPt = IntersectionDDFilter(p1, p2, q1, q2);

            if (intPt != null)
            {
                return(intPt);
            }
            return(CGAlgorithmsDD.Intersection(p1, p2, q1, q2));
        }
コード例 #5
0
        public static int OrientationIndexDd(Geometry segment, Geometry ptGeom)
        {
            if (segment.NumPoints != 2 || ptGeom.NumPoints != 1)
            {
                throw new ArgumentException("A must have two points and B must have one");
            }
            var segPt = segment.Coordinates;

            var p     = ptGeom.Coordinate;
            int index = CGAlgorithmsDD.OrientationIndex(segPt[0], segPt[1], p);

            return(index);
        }
コード例 #6
0
        public static Geometry LineIntersectionDD(Geometry g1, Geometry g2)
        {
            var pt1 = g1.Coordinates;
            var pt2 = g2.Coordinates;

            var intPt = CGAlgorithmsDD.Intersection(pt1[0], pt1[1], pt2[0], pt2[1]);

            // handle parallel case
            if (double.IsNaN(intPt.X))
            {
                intPt = null;
            }
            return(g1.Factory.CreatePoint(intPt));
        }
コード例 #7
0
        public static Geometry SegmentIntersectionDd(Geometry g1, Geometry g2)
        {
            var pt1 = g1.Coordinates;
            var pt2 = g2.Coordinates;

            // first check if there actually is an intersection
            var ri = new RobustLineIntersector();

            ri.ComputeIntersection(pt1[0], pt1[1], pt2[0], pt2[1]);
            if (!ri.HasIntersection)
            {
                // no intersection => return empty point
                return(g1.Factory.CreatePoint((Coordinate)null));
            }

            var intPt = CGAlgorithmsDD.Intersection(pt1[0], pt1[1], pt2[0], pt2[1]);

            return(g1.Factory.CreatePoint(intPt));
        }
コード例 #8
0
ファイル: Vector2D.cs プロジェクト: zhza/NetTopologySuite
 /// <summary>
 ///
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 public bool IsParallel(Vector2D v)
 {
     return(0 == CGAlgorithmsDD.SignOfDet2x2(_x, _y, v._x, v._y));
 }
コード例 #9
0
 public void RunDD()
 {
     var intPt = CGAlgorithmsDD.Intersection(p0, p1, q0, q1);
 }
コード例 #10
0
 public void RunDD_easy()
 {
     var intPt = CGAlgorithmsDD.Intersection(a0, a1, b0, b1);
 }