コード例 #1
0
        /// <summary>
        ///     ''' The along-track distance, calculated from the start point to the closest point on the path to the given point.
        ///     ''' </summary>
        ///     ''' <param name="at">The <see cref="Position">position</see> to caclulate the on track distance for.</param>
        ///     ''' <returns>The on track distance from the start of the stretch.</returns>
        ///     ''' <remarks></remarks>
        public static Distance OnTrackDistance(this Stretch me, Position at)
        {
            const double r   = EarthMeanRadiusMeters / 1000;
            var          s   = Stretch.Between(me.From, at);
            var          d13 = s.Distance.Meters;
            var          dXt = me.CrossTrackDistance(at).Meters;
            var          d   = Acos(Cos(d13 / r) / Cos(dXt / r)) * r;

            return(Distance.FromMeters(Abs(d)));
        }
コード例 #2
0
 public static bool IsOnTrack(this Stretch me, Position at, Distance maxOffTrackDistance) => me.CrossTrackDistance(at) <= maxOffTrackDistance;