(t *testing.T)
| 247 | } |
| 248 | |
| 249 | func TestIntersectionLineQuad(t *testing.T) { |
| 250 | var tts = []struct { |
| 251 | line, quad string |
| 252 | zs Intersections |
| 253 | }{ |
| 254 | // secant |
| 255 | {"M0 5L10 5", "Q10 5 0 10", Intersections{ |
| 256 | {Point{5.0, 5.0}, [2]float64{0.5, 0.5}, [2]float64{0.0, 0.5 * math.Pi}, false, false}, |
| 257 | }}, |
| 258 | |
| 259 | // tangent |
| 260 | {"L0 10", "Q10 5 0 10", Intersections{ |
| 261 | {Point{0.0, 0.0}, [2]float64{0.0, 0.0}, [2]float64{0.5 * math.Pi, Point{2.0, 1.0}.Angle()}, true, false}, |
| 262 | {Point{0.0, 10.0}, [2]float64{1.0, 1.0}, [2]float64{0.5 * math.Pi, Point{-2.0, 1.0}.Angle()}, true, false}, |
| 263 | }}, |
| 264 | {"M5 0L5 10", "Q10 5 0 10", Intersections{ |
| 265 | {Point{5.0, 5.0}, [2]float64{0.5, 0.5}, [2]float64{0.5 * math.Pi, 0.5 * math.Pi}, true, false}, |
| 266 | }}, |
| 267 | |
| 268 | // none |
| 269 | {"M-1 0L-1 10", "Q10 5 0 10", Intersections{}}, |
| 270 | } |
| 271 | origEpsilon := Epsilon |
| 272 | for _, tt := range tts { |
| 273 | t.Run(fmt.Sprint(tt.line, "x", tt.quad), func(t *testing.T) { |
| 274 | Epsilon = origEpsilon |
| 275 | line := MustParseSVGPath(tt.line).ReverseScanner() |
| 276 | quad := MustParseSVGPath(tt.quad).ReverseScanner() |
| 277 | line.Scan() |
| 278 | quad.Scan() |
| 279 | |
| 280 | zs := intersectionLineQuad(nil, line.Start(), line.End(), quad.Start(), quad.CP1(), quad.End()) |
| 281 | Epsilon = 3.0 * origEpsilon |
| 282 | test.T(t, zs, tt.zs) |
| 283 | }) |
| 284 | } |
| 285 | Epsilon = origEpsilon |
| 286 | } |
| 287 | |
| 288 | func TestIntersectionLineCube(t *testing.T) { |
| 289 | var tts = []struct { |
nothing calls this directly
no test coverage detected