MCPcopy
hub / github.com/tdewolff/canvas / TestIntersectionEllipseEllipse

Function TestIntersectionEllipseEllipse

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

Source from the content-addressed store, hash-verified

429}
430
431func TestIntersectionEllipseEllipse(t *testing.T) {
432 var tts = []struct {
433 arc, arc2 string
434 zs Intersections
435 }{
436 // secant
437 {"M5 0A5 5 0 0 1 -5 0", "M-10 -5A10 10 0 0 1 -10 15", Intersections{
438 {Point{0.0, 5.0}, [2]float64{0.5, 0.5}, [2]float64{math.Pi, 0.5 * math.Pi}, false, false},
439 }},
440
441 // tangent
442 {"A5 5 0 0 1 0 10", "M10 0A5 5 0 0 0 10 10", Intersections{
443 {Point{5.0, 5.0}, [2]float64{0.5, 0.5}, [2]float64{0.5 * math.Pi, 0.5 * math.Pi}, true, false},
444 }},
445
446 // fully same
447 {"A5 5 0 0 1 0 10", "A5 5 0 0 1 0 10", Intersections{
448 {Point{0.0, 0.0}, [2]float64{0.0, 0.0}, [2]float64{0.0, 0.0}, true, true},
449 {Point{0.0, 10.0}, [2]float64{1.0, 1.0}, [2]float64{math.Pi, math.Pi}, true, true},
450 }},
451 {"A5 5 0 0 1 0 10", "M0 10A5 5 0 0 0 0 0", Intersections{
452 {Point{0.0, 0.0}, [2]float64{0.0, 1.0}, [2]float64{0.0, math.Pi}, true, true},
453 {Point{0.0, 10.0}, [2]float64{1.0, 0.0}, [2]float64{math.Pi, 0.0}, true, true},
454 }},
455
456 // partly same
457 {"A5 5 0 0 1 0 10", "A5 5 0 0 1 5 5", Intersections{
458 {Point{0.0, 0.0}, [2]float64{0.0, 0.0}, [2]float64{0.0, 0.0}, true, true},
459 {Point{5.0, 5.0}, [2]float64{0.5, 1.0}, [2]float64{0.5 * math.Pi, 0.5 * math.Pi}, true, true},
460 }},
461 {"A5 5 0 0 1 0 10", "M5 5A5 5 0 0 1 0 10", Intersections{
462 {Point{5.0, 5.0}, [2]float64{0.5, 0.0}, [2]float64{0.5 * math.Pi, 0.5 * math.Pi}, true, true},
463 {Point{0.0, 10.0}, [2]float64{1.0, 1.0}, [2]float64{math.Pi, math.Pi}, true, true},
464 }},
465 {"A5 5 0 0 1 0 10", "M5 5A5 5 0 0 1 -5 5", Intersections{
466 {Point{5.0, 5.0}, [2]float64{0.5, 0.0}, [2]float64{0.5 * math.Pi, 0.5 * math.Pi}, true, true},
467 {Point{0.0, 10.0}, [2]float64{1.0, 0.5}, [2]float64{math.Pi, math.Pi}, true, true},
468 }},
469
470 {"M30.170131507649785 37.66143576791836A0.8700000000002787 0.8700000000002787 0 0 1 28.82999999999447 36.92939999999941", "M30.242341004748596 37.609669236818846A0.8700000000000001 0.8700000000000001 0 0 1 28.82999999999447 36.9294", Intersections{
471 {Point{30.170131507649785, 37.66143576791836}, [2]float64{0.0, 0.0455326614}, [2]float64{2.5707027528269983, 2.5707027528269983}, true, true},
472 {Point{28.82999999999447, 36.92939999999941}, [2]float64{1.0, 1.0}, [2]float64{1.5 * math.Pi, 1.5 * math.Pi}, true, true},
473 }}, // #280
474 }
475 origEpsilon := Epsilon
476 for _, tt := range tts {
477 t.Run(fmt.Sprint(tt.arc, "x", tt.arc2), func(t *testing.T) {
478 Epsilon = origEpsilon
479 arc := MustParseSVGPath(tt.arc).ReverseScanner()
480 arc2 := MustParseSVGPath(tt.arc2).ReverseScanner()
481 arc.Scan()
482 arc2.Scan()
483
484 rx, ry, rot, large, sweep := arc.Arc()
485 phi := rot * math.Pi / 180.0
486 cx, cy, theta0, theta1 := ellipseToCenter(arc.Start().X, arc.Start().Y, rx, ry, phi, large, sweep, arc.End().X, arc.End().Y)
487
488 rx2, ry2, rot2, large2, sweep2 := arc2.Arc()

Callers

nothing calls this directly

Calls 10

MustParseSVGPathFunction · 0.85
ellipseToCenterFunction · 0.85
ReverseScannerMethod · 0.80
TMethod · 0.80
RunMethod · 0.45
ScanMethod · 0.45
ArcMethod · 0.45
StartMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected