From c64e9521e3f21466d6667b53791b05bb359790a9 Mon Sep 17 00:00:00 2001 From: Alexis Bory Date: Sat, 5 Mar 2011 21:43:00 +0100 Subject: [PATCH] Generic radar2.nas filtered a possible NaN input. --- Aircraft/Instruments-3d/radar2/radar2.nas | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Aircraft/Instruments-3d/radar2/radar2.nas b/Aircraft/Instruments-3d/radar2/radar2.nas index e2c772f98..0ae530ad2 100644 --- a/Aircraft/Instruments-3d/radar2/radar2.nas +++ b/Aircraft/Instruments-3d/radar2/radar2.nas @@ -555,8 +555,15 @@ var Target = { get_closure_rate : func() { var dt = ElapsedSec.getValue() - me.TimeLast.getValue(); var rng = me.Range.getValue(); - var t_distance = me.RangeLast.getValue() - rng; - var cr = t_distance/dt*3600; + var lrng = me.RangeLast.getValue(); + if ( debug.isnan(rng) or debug.isnan(lrng)) { + print("####### get_closure_rate(): rng or lrng = nan ########"); + me.ClosureRate.setValue(0); + me.RangeLast.setValue(0); + return(0); + } + var t_distance = lrng - rng; + var cr = (dt > 0) ? t_distance/dt*3600 : 0; me.ClosureRate.setValue(cr); me.RangeLast.setValue(rng); return(cr);