Mercurial > gemma
changeset 5716:61eff98a40ae
Prevent infinity heights in rasterizing the tin.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 28 May 2024 14:51:32 +0200 |
parents | e29c942d3e8c |
children | 0542aec69375 5a0fbdda6e2d |
files | pkg/mesh/vertex.go |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/mesh/vertex.go Thu Mar 21 08:19:21 2024 +0100 +++ b/pkg/mesh/vertex.go Tue May 28 14:51:32 2024 +0200 @@ -93,10 +93,13 @@ // If the length of normal is near zero assume we have // a plane constant in z with an average z value of // the three vertices. + // A normal z component value of zero would cause a + // division by zero which would lead to an infinity value. + // In this case we apply the averaging, too. // This should protect us from the effects of collinear // geometries. l := n.Length() - if l < 1e-7 { + if l < 1e-7 || math.Abs(n.Z) < 1e-7 { sum := t[0].Z + t[1].Z + t[2].Z return Plane3D{ A: 0,