travis-ci
2241 of 2241 new or added lines in 38 files covered. (100.0%)
4383 of 6206 relevant lines covered (70.63%)
611.85 hits per line
1 |
package constrained
|
|
2 |
|
|
3 |
import "github.com/go-spatial/geom/cmp" |
|
4 |
|
|
5 |
type Point struct { |
|
6 |
Pt [2]float64 |
|
7 |
IsConstrained bool
|
|
8 |
} |
|
9 |
|
|
|
func (pt Point) XY() [2]float64 { |
× |
|
return pt.Pt
|
× |
|
} |
× |
13 |
|
|
|
func RotatePointsToPos(pts []Point, pos int) { |
36✔ |
|
lp := len(pts)
|
36✔ |
|
if pos == 0 || pos >= lp { |
48✔ |
|
return
|
12✔ |
|
} |
12✔ |
|
is := make([]Point, lp)
|
24✔ |
|
copy(is, pts)
|
24✔ |
|
copy(pts, is[pos:])
|
24✔ |
|
copy(pts[lp-pos:], is[:pos])
|
24✔ |
23 |
} |
|
|
func RotatePointsToLowestFirst(pts []Point) {
|
24✔ |
|
if len(pts) < 2 { |
36✔ |
|
return
|
12✔ |
|
} |
12✔ |
|
var fi int |
12✔ |
|
for i := 1; i < len(pts); i++ { |
60✔ |
|
if cmp.PointLess(pts[i].Pt, pts[fi].Pt) {
|
78✔ |
|
fi = i |
30✔ |
|
} |
30✔ |
33 |
} |
|
|
RotatePointsToPos(pts, fi) |
12✔ |
35 |
} |