+ cdi_xtrack_error_node->setDoubleValue( xtrack_error );
+
+ //////////////////////////////////////////////////////////
+ // compute an approximate ground track heading error
+ //////////////////////////////////////////////////////////
+ double hdg_error = 0.0;
+ if ( inrange && cdi_serviceable ) {
+ double vn = fgGetDouble( "/velocities/speed-north-fps" );
+ double ve = fgGetDouble( "/velocities/speed-east-fps" );
+ double gnd_trk_true = atan2( ve, vn ) * SGD_RADIANS_TO_DEGREES;
+ if ( gnd_trk_true < 0.0 ) { gnd_trk_true += 360.0; }
+
+ SGPropertyNode *true_hdg
+ = fgGetNode("/orientation/heading-deg", true);
+ hdg_error = gnd_trk_true - true_hdg->getDoubleValue();
+
+ // cout << "ground track = " << gnd_trk_true
+ // << " orientation = " << true_hdg->getDoubleValue() << endl;
+ }
+ cdi_xtrack_hdg_err_node->setDoubleValue( hdg_error );
+
+ //////////////////////////////////////////////////////////
+ // compute the time to intercept selected radial (based on
+ // current and last cross track errors and dt
+ //////////////////////////////////////////////////////////
+ double t = 0.0;
+ if ( inrange && cdi_serviceable ) {
+ double xrate_ms = (last_xtrack_error - xtrack_error) / dt;
+ if ( fabs(xrate_ms) > 0.00001 ) {
+ t = xtrack_error / xrate_ms;
+ } else {
+ t = 9999.9;
+ }
+ }
+ time_to_intercept->setDoubleValue( t );
+
+ //////////////////////////////////////////////////////////
+ // compute the amount of glide slope needle deflection
+ // (.i.e. the number of degrees we are off the glide slope * 5.0
+ //
+ // CLO - 13 Mar 2006: The glide slope needle should peg at
+ // +/-0.7 degrees off the ideal glideslope. I'm not sure why
+ // we compute the factor the way we do (5*gs_error), but we
+ // need to compensate for our 'odd' number in the glideslope
+ // needle animation. This means that the needle should peg
+ // when this values is +/-3.5.
+ //////////////////////////////////////////////////////////
+ r = 0.0;
+ if ( has_gs && gs_serviceable_node->getBoolValue() ) {
+ if ( nav_slaved_to_gps_node->getBoolValue() ) {
+ // FIXME/FINISHME, what should be set here?
+ } else if ( inrange ) {
+ double x = gs_dist_node->getDoubleValue();
+ double y = (fgGetDouble("/position/altitude-ft") - nav_elev)
+ * SG_FEET_TO_METER;
+ // cout << "dist = " << x << " height = " << y << endl;
+ double angle = asin( y / x ) * SGD_RADIANS_TO_DEGREES;
+ r = (target_gs - angle) * 5.0;
+ }
+ }
+ gs_deflection_node->setDoubleValue( r );