MCPcopy Create free account
hub / github.com/gonum/plot / exciseQuick

Method exciseQuick

plotter/contour.go:646–667  ·  view source on GitHub ↗

exciseQuick is a heuristic approach to loop excision. It does not correctly identify loops in all cases, but those cases are likely to be rare.

(conts contourSet)

Source from the content-addressed store, hash-verified

644// correctly identify loops in all cases, but those cases are likely
645// to be rare.
646func (c *contour) exciseQuick(conts contourSet) {
647 wp := append(c.backward.reverse(), c.forward...)
648 seen := make(map[point]int)
649 for j := 0; j < len(wp); {
650 p := wp[j]
651 if i, ok := seen[p]; ok && p != wp[0] && p != wp[len(wp)-1] {
652 conts[&contour{
653 z: c.z,
654 backward: path{wp[i]},
655 forward: slices.Clone(wp[i+1 : j+1]),
656 }] = struct{}{}
657 wp = append(wp[:i], wp[j:]...)
658 j = i + 1
659 } else {
660 seen[p] = j
661 j++
662 }
663 }
664 c.backward = c.backward[:1]
665 c.backward[0] = wp[0]
666 c.forward = wp[1:]
667}

Callers 1

exciseLoopsMethod · 0.95

Calls 1

reverseMethod · 0.80

Tested by

no test coverage detected