-
Notifications
You must be signed in to change notification settings - Fork 9
/
box3d.go
44 lines (39 loc) · 750 Bytes
/
box3d.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package geos
import (
"fmt"
"math"
)
// A Box3D is a three-dimensional bounds.
type Box3D struct {
MinX float64
MinY float64
MinZ float64
MaxX float64
MaxY float64
MaxZ float64
}
// NewBox3D returns a new bounds.
func NewBox3D(minX, minY, minZ, maxX, maxY, maxZ float64) *Box3D {
return &Box3D{
MinX: minX,
MinY: minY,
MinZ: minZ,
MaxX: maxX,
MaxY: maxY,
MaxZ: maxZ,
}
}
// NewBox3DEmpty returns a new empty bounds.
func NewBox3DEmpty() *Box3D {
return &Box3D{
MinX: math.Inf(1),
MinY: math.Inf(1),
MinZ: math.Inf(1),
MaxX: math.Inf(-1),
MaxY: math.Inf(-1),
MaxZ: math.Inf(-1),
}
}
func (b *Box3D) String() string {
return fmt.Sprintf("[%f %f %f %f %f %f]", b.MinX, b.MinY, b.MinZ, b.MaxX, b.MaxY, b.MaxX)
}