Mercurial > gemma
comparison cmd/tin2octree/vertex.go @ 673:9a0246ab3021 octree
octree: simplified vertex interpolation.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 19 Sep 2018 11:03:00 +0200 |
parents | be0327dc3119 |
children | b17e3ce53285 |
comparison
equal
deleted
inserted
replaced
672:5fa2eaffac84 | 673:9a0246ab3021 |
---|---|
28 if w.z > v.z { | 28 if w.z > v.z { |
29 v.z = w.z | 29 v.z = w.z |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 func (v vertex) sub(w vertex) vertex { | |
34 return vertex{ | |
35 v.x - w.x, | |
36 v.y - w.y, | |
37 v.z - w.z, | |
38 } | |
39 } | |
40 | |
33 func interpolate(v1, v2 vertex) func(vertex) vertex { | 41 func interpolate(v1, v2 vertex) func(vertex) vertex { |
42 v2 = v2.sub(v1) | |
34 return func(s vertex) vertex { | 43 return func(s vertex) vertex { |
35 return vertex{ | 44 return vertex{ |
36 (v2.x-v1.x)*s.x + v1.x, | 45 v2.x*s.x + v1.x, |
37 (v2.y-v1.y)*s.y + v1.y, | 46 v2.y*s.y + v1.y, |
38 (v2.z-v1.z)*s.z + v1.z, | 47 v2.z*s.z + v1.z, |
39 } | 48 } |
40 } | 49 } |
41 } | 50 } |
42 | 51 |
43 func (a vertex) less(b vertex) bool { | 52 func (a vertex) less(b vertex) bool { |