(t *testing.T)
| 286 | } |
| 287 | |
| 288 | func TestIntersectionLineCube(t *testing.T) { |
| 289 | var tts = []struct { |
| 290 | line, cube string |
| 291 | zs Intersections |
| 292 | }{ |
| 293 | // secant |
| 294 | {"M0 5L10 5", "C8 0 8 10 0 10", Intersections{ |
| 295 | {Point{6.0, 5.0}, [2]float64{0.6, 0.5}, [2]float64{0.0, 0.5 * math.Pi}, false, false}, |
| 296 | }}, |
| 297 | {"M0 1L1 1", "C0 2 1 0 1 2", Intersections{ // parallel at intersection |
| 298 | {Point{0.5, 1.0}, [2]float64{0.5, 0.5}, [2]float64{0.0, 0.0}, false, false}, |
| 299 | }}, |
| 300 | {"M0 1L1 1", "M0 2C0 0 1 2 1 0", Intersections{ // parallel at intersection |
| 301 | {Point{0.5, 1.0}, [2]float64{0.5, 0.5}, [2]float64{0.0, 0.0}, false, false}, |
| 302 | }}, |
| 303 | {"M0 1L1 1", "C0 3 1 -1 1 2", Intersections{ // three intersections |
| 304 | {Point{0.0791512117, 1.0}, [2]float64{0.0791512117, 0.1726731646}, [2]float64{0.0, 74.05460410 / 180.0 * math.Pi}, false, false}, |
| 305 | {Point{0.5, 1.0}, [2]float64{0.5, 0.5}, [2]float64{0.0, 315 / 180.0 * math.Pi}, false, false}, |
| 306 | {Point{0.9208487883, 1.0}, [2]float64{0.9208487883, 0.8273268354}, [2]float64{0.0, 74.05460410 / 180.0 * math.Pi}, false, false}, |
| 307 | }}, |
| 308 | |
| 309 | // tangent |
| 310 | {"L0 10", "C8 0 8 10 0 10", Intersections{ |
| 311 | {Point{0.0, 0.0}, [2]float64{0.0, 0.0}, [2]float64{0.5 * math.Pi, 0.0}, true, false}, |
| 312 | {Point{0.0, 10.0}, [2]float64{1.0, 1.0}, [2]float64{0.5 * math.Pi, math.Pi}, true, false}, |
| 313 | }}, |
| 314 | {"M6 0L6 10", "C8 0 8 10 0 10", Intersections{ |
| 315 | {Point{6.0, 5.0}, [2]float64{0.5, 0.5}, [2]float64{0.5 * math.Pi, 0.5 * math.Pi}, true, false}, |
| 316 | }}, |
| 317 | |
| 318 | // none |
| 319 | {"M-1 0L-1 10", "C8 0 8 10 0 10", Intersections{}}, |
| 320 | } |
| 321 | origEpsilon := Epsilon |
| 322 | for _, tt := range tts { |
| 323 | t.Run(fmt.Sprint(tt.line, "x", tt.cube), func(t *testing.T) { |
| 324 | Epsilon = origEpsilon |
| 325 | line := MustParseSVGPath(tt.line).ReverseScanner() |
| 326 | cube := MustParseSVGPath(tt.cube).ReverseScanner() |
| 327 | line.Scan() |
| 328 | cube.Scan() |
| 329 | |
| 330 | zs := intersectionLineCube(nil, line.Start(), line.End(), cube.Start(), cube.CP1(), cube.CP2(), cube.End()) |
| 331 | Epsilon = 3.0 * origEpsilon |
| 332 | test.T(t, zs, tt.zs) |
| 333 | }) |
| 334 | } |
| 335 | Epsilon = origEpsilon |
| 336 | } |
| 337 | |
| 338 | func TestIntersectionLineEllipse(t *testing.T) { |
| 339 | var tts = []struct { |
nothing calls this directly
no test coverage detected