MCPcopy Create free account
hub / github.com/tdewolff/canvas / TestIntersectionLineQuad

Function TestIntersectionLineQuad

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

Source from the content-addressed store, hash-verified

247}
248
249func 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
288func TestIntersectionLineCube(t *testing.T) {
289 var tts = []struct {

Callers

nothing calls this directly

Calls 10

MustParseSVGPathFunction · 0.85
intersectionLineQuadFunction · 0.85
AngleMethod · 0.80
ReverseScannerMethod · 0.80
TMethod · 0.80
RunMethod · 0.45
ScanMethod · 0.45
StartMethod · 0.45
EndMethod · 0.45
CP1Method · 0.45

Tested by

no test coverage detected