comparison pkg/octree/tree.go @ 1692:f4dcbe8941a1

Octree: Resolved the remaing golint issues with this package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 31 Dec 2018 11:13:49 +0100
parents a244b18cb916
children 00f34a00e6d5
comparison
equal deleted inserted replaced
1691:de09bd3b5c05 1692:f4dcbe8941a1
15 15
16 import ( 16 import (
17 "math" 17 "math"
18 ) 18 )
19 19
20 // Tree is an Octree holding triangles.
20 type Tree struct { 21 type Tree struct {
22 // EPSG is the projection.
21 EPSG uint32 23 EPSG uint32
22 24
23 vertices []Vertex 25 vertices []Vertex
24 triangles [][]int32 26 triangles [][]int32
25 index []int32 27 index []int32
26 28
29 // Min is the lower left corner of the bbox.
27 Min Vertex 30 Min Vertex
31 // Max is the upper right corner of the bbox.
28 Max Vertex 32 Max Vertex
29 } 33 }
30 34
31 var scale = [4][4]float64{ 35 var scale = [4][4]float64{
32 {0.0, 0.0, 0.5, 0.5}, 36 {0.0, 0.0, 0.5, 0.5},
33 {0.5, 0.0, 1.0, 0.5}, 37 {0.5, 0.0, 1.0, 0.5},
34 {0.0, 0.5, 0.5, 1.0}, 38 {0.0, 0.5, 0.5, 1.0},
35 {0.5, 0.5, 1.0, 1.0}, 39 {0.5, 0.5, 1.0, 1.0},
36 } 40 }
37 41
42 // Vertical does a vertical cross cut from (x1, y1) to (x2, y2).
38 func (ot *Tree) Vertical(x1, y1, x2, y2 float64, fn func(*Triangle)) { 43 func (ot *Tree) Vertical(x1, y1, x2, y2 float64, fn func(*Triangle)) {
39 44
40 box := Box2D{ 45 box := Box2D{
41 X1: math.Min(x1, x2), 46 X1: math.Min(x1, x2),
42 Y1: math.Min(y1, y2), 47 Y1: math.Min(y1, y2),
121 } 126 }
122 } 127 }
123 } 128 }
124 } 129 }
125 130
131 // Horizontal does a horizontal cross cut.
126 func (ot *Tree) Horizontal(h float64, fn func(*Triangle)) { 132 func (ot *Tree) Horizontal(h float64, fn func(*Triangle)) {
127 133
128 if h < ot.Min.Z || ot.Max.Z < h { 134 if h < ot.Min.Z || ot.Max.Z < h {
129 return 135 return
130 } 136 }