-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfloat64slices.go
More file actions
30 lines (28 loc) · 802 Bytes
/
float64slices.go
File metadata and controls
30 lines (28 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package proj
// CoordsToFloat64Slices is a convenience function that converts a slice of
// Coords to a slice of []float64s. For performance, the returned []float64s
// alias coords.
func CoordsToFloat64Slices(coords []Coord) [][]float64 {
if coords == nil {
return nil
}
float64Slices := make([][]float64, len(coords))
for i := range float64Slices {
float64Slices[i] = coords[i][:]
}
return float64Slices
}
// Float64SlicesToCoords is a convenience function that converts a slice of
// []float64s to a slice of Coords.
func Float64SlicesToCoords(float64Slices [][]float64) []Coord {
if float64Slices == nil {
return nil
}
coords := make([]Coord, len(float64Slices))
for i := range coords {
var coord Coord
copy(coord[:], float64Slices[i])
coords[i] = coord
}
return coords
}