MCPcopy Index your code
hub / github.com/tdewolff/canvas / TestIntersectionLineLineBentleyOttmann

Function TestIntersectionLineLineBentleyOttmann

path_intersection_test.go:159–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestIntersectionLineLineBentleyOttmann(t *testing.T) {
160 var tts = []struct {
161 line1, line2 string
162 zs []Point
163 }{
164 // secant
165 {"M2 0L2 3", "M1 2L3 2", []Point{{2.0, 2.0}}},
166
167 // tangent
168 {"M2 0L2 3", "M2 2L3 2", []Point{{2.0, 2.0}}},
169 {"M2 0L2 2", "M2 2L3 2", nil},
170 {"L2 2", "M0 4L2 2", nil},
171 {"L10 5", "M0 10L10 5", nil},
172 {"M10 5L20 10", "M10 5L20 0", nil},
173
174 // parallel
175 {"L2 2", "L2 2", nil},
176 {"L2 2", "M3 3L5 5", nil},
177 {"L2 2", "M-3 -3L-1 -1", nil},
178 {"L2 2", "M-1 1L1 3", nil},
179 {"L2 2", "M2 2L4 4", nil},
180 {"L2 2", "M-2 -2L0 0", nil},
181 {"L4 4", "M2 2L4 4", []Point{{2.0, 2.0}}},
182 {"L4 4", "M2 2L6 6", []Point{{2.0, 2.0}, {4.0, 4.0}}},
183 {"L4 4", "M0 0L2 2", []Point{{2.0, 2.0}}},
184 {"L4 4", "M0 0L6 6", []Point{{4.0, 4.0}}},
185 {"L4 4", "M-2 -2L2 2", []Point{{0.0, 0.0}, {2.0, 2.0}}},
186 {"L4 4", "M-2 -2L4 4", []Point{{0.0, 0.0}}},
187 {"L4 4", "M1 1L3 3", []Point{{1.0, 1.0}, {3.0, 3.0}}},
188 {"L4 4", "M-1 -1L5 5", []Point{{0.0, 0.0}, {4.0, 4.0}}},
189
190 // none
191 {"M2 0L2 1", "M3 0L3 1", nil},
192 {"M2 0L2 1", "M0 2L1 2", nil},
193
194 // almost vertical
195 {"L2 0", "M1 -1L1.0000000000000002 2", []Point{{1.0000000000000002, 0.0}}},
196 {"L2 0", "M1 1L1.0000000000000002 -2", []Point{{1.0000000000000002, 0.0}}},
197 {"M1 -1L1.0000000000000002 2", "L2 0", []Point{{1.0000000000000002, 0.0}}},
198 {"M1 1L1.0000000000000002 -2", "L2 0", []Point{{1.0000000000000002, 0.0}}},
199
200 // bugs
201 {"M21.590990257669734 18.40900974233027L22.651650429449557 17.348349570550447", "M21.23743686707646 18.762563132923542L21.590990257669738 18.409009742330266",
202 nil, //[]Point{{21.590990257669738, 18.40900974233027}},
203 }, // almost colinear
204 {"M-0.1997406229376793 158.88740153238177L-0.1997406229376793 296.9999999925494", "M-0.1997406229376793 158.88740153238177L-0.19974062293732664 158.8874019079834",
205 nil,
206 }, // #287
207 {"M-0.1997406229376793 158.88740153238177L-0.1997406229376793 296.9999999925494", "M-0.19999999999964735 20.77454766193328L-0.19974062293732664 158.8874019079834",
208 []Point{{-0.1997406229376793, 158.88740172019808}},
209 }, // #287
210 {"M-0.1997406229376793 158.88740153238177L-0.19974062293732664 158.8874019079834", "M-0.19999999999964735 20.77454766193328L-0.19974062293732664 158.8874019079834",
211 nil, //[]Point{{-0.19974062293732664, 158.8874019079834}},
212 }, // almost colinear, #287
213 {"M162.43449681368278 -9.999996185876771L162.43449681368278 -9.99998551284069", "M162.2344968136828 -9.99998551284069L162.43449681368278 -9.999985512840682",
214 nil,
215 }, // almost colinear, #287
216 {"M0.7814851602550552,0.3987574923859699L0.7814861805182336,0.39875653588924026", "M0.7814852358775772,0.39875773815916654L0.7814861805182336,0.39875653588924026",

Callers

nothing calls this directly

Calls 9

MustParseSVGPathFunction · 0.85
isIncreasingFunction · 0.85
ReverseScannerMethod · 0.80
TMethod · 0.80
RunMethod · 0.45
ScanMethod · 0.45
StartMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected