Mercurial > gemma
annotate pkg/octree/triangulation.go @ 3092:7dc9660df743
Fixed c&p sign error in Nash Sutcliffe calculation.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 23 Apr 2019 10:12:31 +0200 |
parents | 4fa92d468164 |
children | 6248a4bc10c7 |
rev | line source |
---|---|
2483
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // Copyright (C) 2018 Michael Fogleman |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // Permission is hereby granted, free of charge, to any person obtaining |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // a copy of this software and associated documentation files (the "Software"), |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // to deal in the Software without restriction, including without limitation |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // and/or sell copies of the Software, and to permit persons to whom the |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // Software is furnished to do so, subject to the following conditions: |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // The above copyright notice and this permission notice shall be included |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // in all copies or substantial portions of the Software. |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 package octree |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 import ( |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 "fmt" |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 "math" |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 ) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 type Triangulation struct { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 Points []Vertex |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 ConvexHull []Vertex |
2484
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
30 Triangles []int32 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
31 Halfedges []int32 |
2483
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 // Triangulate returns a Delaunay triangulation of the provided points. |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 func Triangulate(points []Vertex) (*Triangulation, error) { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 t := newTriangulator(points) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 err := t.triangulate() |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 return &Triangulation{points, t.convexHull(), t.triangles, t.halfedges}, err |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
2484
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
41 func (t *Triangulation) TriangleSlices() [][]int32 { |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
42 sl := make([][]int32, len(t.Triangles)/3) |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
43 var j int |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
44 for i := range sl { |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
45 sl[i] = t.Triangles[j : j+3] |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
46 j += 3 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
47 } |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
48 return sl |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
49 } |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
50 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
51 func (t *Triangulation) Tin() *Tin { |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
52 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
53 min := Vertex{math.MaxFloat64, math.MaxFloat64, math.MaxFloat64} |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
54 max := Vertex{-math.MaxFloat64, -math.MaxFloat64, -math.MaxFloat64} |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
55 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
56 vertices := t.Points |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
57 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
58 for _, v := range vertices { |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
59 min.Minimize(v) |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
60 max.Maximize(v) |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
61 } |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
62 |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
63 return &Tin{ |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
64 Vertices: vertices, |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
65 Triangles: t.TriangleSlices(), |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
66 Min: min, |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
67 Max: max, |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
68 } |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
69 } |
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
70 |
2483
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 func (t *Triangulation) area() float64 { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 var result float64 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 points := t.Points |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 ts := t.Triangles |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 for i := 0; i < len(ts); i += 3 { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 p0 := points[ts[i+0]] |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 p1 := points[ts[i+1]] |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 p2 := points[ts[i+2]] |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 result += area(p0, p1, p2) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 return result / 2 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 // Validate performs several sanity checks on the Triangulation to check for |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 // potential errors. Returns nil if no issues were found. You normally |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 // shouldn't need to call this function but it can be useful for debugging. |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 func (t *Triangulation) Validate() error { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 // verify halfedges |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 for i1, i2 := range t.Halfedges { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 if i1 != -1 && t.Halfedges[i1] != i2 { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 return fmt.Errorf("invalid halfedge connection") |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 } |
2484
4fa92d468164
Use fogleman's triangulation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2483
diff
changeset
|
93 if i2 != -1 && t.Halfedges[i2] != int32(i1) { |
2483
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 return fmt.Errorf("invalid halfedge connection") |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 // verify convex hull area vs sum of triangle areas |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 hull1 := t.ConvexHull |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 hull2 := ConvexHull(t.Points) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 area1 := polygonArea(hull1) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 area2 := polygonArea(hull2) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 area3 := t.area() |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 if math.Abs(area1-area2) > 1e-9 || math.Abs(area1-area3) > 1e-9 { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 return fmt.Errorf("hull areas disagree: %f, %f, %f", area1, area2, area3) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 // verify convex hull perimeter |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 perimeter1 := polygonPerimeter(hull1) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 perimeter2 := polygonPerimeter(hull2) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 if math.Abs(perimeter1-perimeter2) > 1e-9 { |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 return fmt.Errorf("hull perimeters disagree: %f, %f", perimeter1, perimeter2) |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 } |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 return nil |
620038ade708
Incorporated fogleman's fast Delaunay triangulation adjuted to our vertex model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 } |