Mercurial > gemma
annotate cmd/octree2contour/vertex.go @ 687:be90ab542aa7 octree
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 20 Sep 2018 11:32:03 +0200 |
parents | 120a82bd9953 |
children | 614135d69823 |
rev | line source |
---|---|
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package main |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 type vertex struct { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 x float64 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 y float64 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 z float64 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 func (v *vertex) minimize(w vertex) { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 if w.x < v.x { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 v.x = w.x |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 if w.y < v.y { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 v.y = w.y |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 if w.z < v.z { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 v.z = w.z |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 func (v *vertex) maximize(w vertex) { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 if w.x > v.x { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 v.x = w.x |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 if w.y > v.y { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 v.y = w.y |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 if w.z > v.z { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 v.z = w.z |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 func (v vertex) sub(w vertex) vertex { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 return vertex{ |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 v.x - w.x, |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 v.y - w.y, |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 v.z - w.z, |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
41 func (v vertex) add(w vertex) vertex { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
42 return vertex{ |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
43 v.x + w.x, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
44 v.y + w.y, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
45 v.z + w.z, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
46 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
47 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
48 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
49 func (v vertex) scale(s float64) vertex { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
50 return vertex{ |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
51 s * v.x, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
52 s * v.y, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
53 s * v.z, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
54 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
55 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
56 |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 func interpolate(v1, v2 vertex) func(vertex) vertex { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 v2 = v2.sub(v1) |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 return func(s vertex) vertex { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 return vertex{ |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 v2.x*s.x + v1.x, |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 v2.y*s.y + v1.y, |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 v2.z*s.z + v1.z, |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 func (a vertex) less(b vertex) bool { |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 return a.x < b.x || a.y < b.y || a.z < b.z |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
71 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
72 type line [2]vertex |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
73 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
74 func newLine(p1, p2 vertex) line { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
75 return line{ |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
76 p2.sub(p1), |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
77 p1, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
78 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
79 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
80 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
81 func (l line) eval(t float64) vertex { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
82 return l[0].scale(t).add(l[1]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
83 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
84 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
85 func (l line) intersectH(h float64) vertex { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
86 t := (h - l[1].z) / l[0].z |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
87 return l.eval(t) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
88 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
89 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
90 type triangle [3]vertex |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
91 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
92 func side(z, h float64) int { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
93 switch { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
94 case z < h: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
95 return -1 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
96 case z > h: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
97 return +1 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
98 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
99 return 0 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
100 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
101 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
102 func (t *triangle) intersectH(h float64, points []vertex) []vertex { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
103 sides := [3]int{ |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
104 side(t[0].z, h), |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
105 side(t[1].z, h), |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
106 side(t[2].z, h), |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
107 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
108 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
109 for i := 0; i < 3; i++ { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
110 j := (i + 1) % 3 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
111 si := sides[i] |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
112 sj := sides[j] |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
113 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
114 switch { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
115 case si == 0 && sj == 0: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
116 // both on plane |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
117 points = append(points, t[i], t[j]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
118 case si == 0 && sj != 0: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
119 // first on plane |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
120 points = append(points, t[i]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
121 case si != 0 && sj == 0: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
122 // second on plane |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
123 points = append(points, t[j]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
124 case si == sj: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
125 // both on same side |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
126 default: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
127 // real intersection |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
128 v := newLine(t[i], t[j]).intersectH(h) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
129 points = append(points, v) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
130 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
131 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
132 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
133 return points |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
134 } |