Mercurial > gemma
diff pkg/octree/vertex.go @ 3953:4233570de212
Building octrees: Don't cause havok by building ain overly large tree if the points are not really 3D.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 15 Jul 2019 17:49:50 +0200 |
parents | 71164b817d6e |
children | 56f4e8cbfab7 |
line wrap: on
line diff
--- a/pkg/octree/vertex.go Mon Jul 15 17:09:59 2019 +0200 +++ b/pkg/octree/vertex.go Mon Jul 15 17:49:50 2019 +0200 @@ -45,6 +45,9 @@ // and the second being the direction. Line [2]Vertex + // Box is a 3D box. + Box [2]Vertex + // MultiPointZ is a set of vertices. MultiPointZ []Vertex @@ -288,9 +291,10 @@ } } -// Interpolate returns a function that return s*v2 + v1 +// Interpolate returns a function that return s*b[1] + b[0] // component-wise. -func Interpolate(v1, v2 Vertex) func(Vertex) Vertex { +func (b Box) Interpolate() func(Vertex) Vertex { + v1, v2 := b[0], b[1] v2 = v2.Sub(v1) return func(s Vertex) Vertex { return Vertex{ @@ -301,6 +305,10 @@ } } +func (b Box) HasX() bool { return math.Abs(b[0].X-b[1].X) > epsPlane } +func (b Box) HasY() bool { return math.Abs(b[0].Y-b[1].Y) > epsPlane } +func (b Box) HasZ() bool { return math.Abs(b[0].Z-b[1].Z) > epsPlane } + // Less returns if one of v component is less than the // corresponing component in w. func (v Vertex) Less(w Vertex) bool {