+ // convert geodetic positions to geocentered
+ SGVec3d cartuserPos = SGVec3d::fromGeod(inpos);
+ //SGVec3d cartuserPos = getCartUserPos();
+ //SGVec3d cartPos = getCartPos();
+
+ // Transform to the right coordinate frame, configuration is done in
+ // the x-forward, y-right, z-up coordinates (feet), computation
+ // in the simulation usual body x-forward, y-right, z-down coordinates
+ // (meters) )
+ SGVec3d _off(_x_offset * SG_FEET_TO_METER,
+ _y_offset * SG_FEET_TO_METER,
+ -_z_offset * SG_FEET_TO_METER);
+
+ // Transform the user position to the horizontal local coordinate system.
+ SGQuatd hlTrans = SGQuatd::fromLonLat(inpos);
+
+ // and postrotate the orientation of the user model wrt the horizontal
+ // local frame
+ hlTrans *= SGQuatd::fromYawPitchRollDeg(
+ user_heading,
+ user_pitch,
+ user_roll);
+
+ // The offset converted to the usual body fixed coordinate system
+ // rotated to the earth-fixed coordinates axis
+ SGVec3d off = hlTrans.backTransform(_off);
+
+ // Add the position offset of the user model to get the geocentered position
+ SGVec3d offsetPos = cartuserPos + off;
+
+ return offsetPos;
+}
+
+void FGAIBallistic::setOffsetVelocity(double dt, SGGeod offsetpos) {
+ //calculate the distance from the previous offset position
+ SGVec3d cartoffsetPos = SGVec3d::fromGeod(offsetpos);
+ SGVec3d diff = cartoffsetPos - _oldcartoffsetPos;
+
+ double distance = norm(diff);
+ //calculate speed knots
+ speed = (distance/dt) * SG_MPS_TO_KT;
+
+ //now calulate the angle between the old and current postion positions (degrees)
+ double angle = 0;
+ double daltM = offsetpos.getElevationM() - _oldoffsetpos.getElevationM();