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

Function circularPermutations

plotter/contour_test.go:201–239  ·  view source on GitHub ↗
(a, b vg.Path)

Source from the content-addressed store, hash-verified

199}
200
201func circularPermutations(a, b vg.Path) bool {
202 if len(a) != len(b) {
203 return false
204 }
205
206 var off int
207
208 var forward bool
209 for i, pc := range b {
210 if reflect.DeepEqual(a[0], pc) {
211 off = i
212 forward = true
213 break
214 }
215 }
216 for i, pc := range a {
217 if !reflect.DeepEqual(b[(off+i)%len(a)], pc) {
218 forward = false
219 break
220 }
221 }
222
223 var reverse bool
224 for i, pc := range b {
225 if reflect.DeepEqual(a[0], pc) {
226 off = i
227 reverse = true
228 break
229 }
230 }
231 for i, pc := range a {
232 if !reflect.DeepEqual(b[(off-i+len(a))%len(a)], pc) {
233 reverse = false
234 break
235 }
236 }
237
238 return forward || reverse
239}
240
241// Contour paths sorted by path length.
242var wantContours = map[float64][]vg.Path{

Callers 1

TestContourPathsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected