@@ -83,6 +83,89 @@ public void BentleyOttmann_Horizontal_Lines_Test()
8383 Assert . AreEqual ( expectedIntersections . Count , actualIntersections . Count ) ;
8484 }
8585
86+ [ TestMethod ]
87+ public void BentleyOttmann_Vertical_Horizontal_Lines_Test ( )
88+ {
89+ var lines = new List < Line > ( ) ;
90+
91+ //vertical
92+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 100 , 200 ) ) ) ;
93+ lines . Add ( new Line ( new Point ( 125 , 100 ) , new Point ( 125 , 200 ) ) ) ;
94+ lines . Add ( new Line ( new Point ( 150 , 100 ) , new Point ( 150 , 200 ) ) ) ;
95+ lines . Add ( new Line ( new Point ( 175 , 100 ) , new Point ( 175 , 200 ) ) ) ;
96+ lines . Add ( new Line ( new Point ( 200 , 100 ) , new Point ( 200 , 200 ) ) ) ;
97+
98+ //horizontal
99+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 200 , 100 ) ) ) ;
100+ lines . Add ( new Line ( new Point ( 100 , 125 ) , new Point ( 200 , 125 ) ) ) ;
101+ lines . Add ( new Line ( new Point ( 100 , 150 ) , new Point ( 200 , 150 ) ) ) ;
102+ lines . Add ( new Line ( new Point ( 100 , 175 ) , new Point ( 200 , 175 ) ) ) ;
103+ lines . Add ( new Line ( new Point ( 100 , 200 ) , new Point ( 200 , 200 ) ) ) ;
104+
105+ var expectedIntersections = getExpectedIntersections ( lines ) ;
106+
107+ var bentleyOttmannAlgorithm = new BentleyOttmann ( ) ;
108+
109+ var actualIntersections = bentleyOttmannAlgorithm . FindIntersections ( lines ) ;
110+
111+ Assert . AreEqual ( expectedIntersections . Count , actualIntersections . Count ) ;
112+ }
113+
114+ [ TestMethod ]
115+ public void BentleyOttmann_Vertical_Horizontal_Other_Lines_Test_1 ( )
116+ {
117+ var lines = new List < Line > ( ) ;
118+
119+ //vertical
120+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 100 , 200 ) ) ) ;
121+ lines . Add ( new Line ( new Point ( 200 , 100 ) , new Point ( 200 , 200 ) ) ) ;
122+
123+ //horizontal
124+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 200 , 100 ) ) ) ;
125+ lines . Add ( new Line ( new Point ( 100 , 150 ) , new Point ( 200 , 150 ) ) ) ;
126+ lines . Add ( new Line ( new Point ( 100 , 200 ) , new Point ( 200 , 200 ) ) ) ;
127+
128+ //other lines
129+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 200 , 200 ) ) ) ;
130+ lines . Add ( new Line ( new Point ( 100 , 200 ) , new Point ( 200 , 100 ) ) ) ;
131+
132+ var expectedIntersections = getExpectedIntersections ( lines ) ;
133+
134+ var bentleyOttmannAlgorithm = new BentleyOttmann ( ) ;
135+
136+ var actualIntersections = bentleyOttmannAlgorithm . FindIntersections ( lines ) ;
137+
138+ Assert . AreEqual ( expectedIntersections . Count , actualIntersections . Count ) ;
139+ }
140+
141+
142+ [ TestMethod ]
143+ public void BentleyOttmann_Vertical_Horizontal_Other_Lines_Test_2 ( )
144+ {
145+ var lines = new List < Line > ( ) ;
146+
147+ //vertical
148+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 100 , 200 ) ) ) ;
149+ lines . Add ( new Line ( new Point ( 200 , 100 ) , new Point ( 200 , 200 ) ) ) ;
150+
151+ //horizontal
152+ lines . Add ( new Line ( new Point ( 100 , 100 ) , new Point ( 200 , 100 ) ) ) ;
153+ lines . Add ( new Line ( new Point ( 100 , 150 ) , new Point ( 200 , 150 ) ) ) ;
154+ lines . Add ( new Line ( new Point ( 100 , 200 ) , new Point ( 200 , 200 ) ) ) ;
155+
156+ //other lines
157+ lines . Add ( new Line ( new Point ( 110 , 100 ) , new Point ( 210 , 200 ) ) ) ;
158+ lines . Add ( new Line ( new Point ( 90 , 200 ) , new Point ( 250 , 100 ) ) ) ;
159+
160+ var expectedIntersections = getExpectedIntersections ( lines ) ;
161+
162+ var bentleyOttmannAlgorithm = new BentleyOttmann ( ) ;
163+
164+ var actualIntersections = bentleyOttmannAlgorithm . FindIntersections ( lines ) ;
165+
166+ Assert . AreEqual ( expectedIntersections . Count , actualIntersections . Count ) ;
167+ }
168+
86169 [ TestMethod ]
87170 public void BentleyOttmann_Stress_Test ( )
88171 {
@@ -178,7 +261,7 @@ private static List<Line> horizontalLines()
178261 {
179262 var lines = new List < Line > ( ) ;
180263
181- var s1 = new Line ( new Point ( 200 , 100 ) , new Point ( 600 , 100 ) ) ;
264+ var s1 = new Line ( new Point ( 100 , 100 ) , new Point ( 600 , 100 ) ) ;
182265 var s2 = new Line ( new Point ( 225 , 100 ) , new Point ( 625 , 100 ) ) ;
183266 var s3 = new Line ( new Point ( 250 , 100 ) , new Point ( 475 , 100 ) ) ;
184267 var s4 = new Line ( new Point ( 290 , 100 ) , new Point ( 675 , 100 ) ) ;
0 commit comments