summaryrefslogtreecommitdiffstats
path: root/progs/demos/tunnel.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-05-09 20:02:28 +0000
committerBrian Paul <[email protected]>2001-05-09 20:02:28 +0000
commita41edc31ce81daf69157a345525933ca6c560004 (patch)
treefedb95c9a2e9495b4767c6a3c85c41e4c6f6c821 /progs/demos/tunnel.c
parent61cb081a357e60e988ecfa2fd945a8d2657c49f0 (diff)
check for tiny values in dir[] vector in calcposobjs(), prevents FP underflows later
Diffstat (limited to 'progs/demos/tunnel.c')
-rw-r--r--progs/demos/tunnel.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/progs/demos/tunnel.c b/progs/demos/tunnel.c
index d495b31b4f6..f0faa61a0bf 100644
--- a/progs/demos/tunnel.c
+++ b/progs/demos/tunnel.c
@@ -164,6 +164,13 @@ calcposobs(void)
dir[1] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
dir[2] = cos(beta * M_PI / 180.0);
+ if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5)
+ dir[0] = 0;
+ if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5)
+ dir[1] = 0;
+ if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5)
+ dir[2] = 0;
+
obs[0] += v * dir[0];
obs[1] += v * dir[1];
obs[2] += v * dir[2];