Exemple #1
0
 public double GetAngle(Turn that)
 {
     return GetAngleInRadians(that.BearingInRadians, 0.0);
 }
Exemple #2
0
 public double GetAngle(Turn that)
 {
     return(GetAngleInRadians(that.BearingInRadians, 0.0));
 }
Exemple #3
0
        /// <summary>
        /// Checks whether a location falls in the sector lying between two points on a
        /// clockwise circular arc. The only condition is that the location has an appropriate
        /// bearing with respect to the bearings of the BC & EC (i.e. the location does not
        /// necessarily lie ON the arc).
        /// </summary>
        /// <param name="pos">The position to check</param>
        /// <param name="centre">The centre of the circular arc</param>
        /// <param name="start">The first point of the arc (reckoned clockwise)</param>
        /// <param name="end">The second point of the arc (reckoned clockwise)</param>
        /// <param name="angtol">Angular tolerance (locations that are beyond the BC or EC
        /// by up to this much will also be regarded as "in-sector").</param>
        /// <returns>True if position falls in the sector defined by the arc</returns>
        public static bool IsInSector(IPosition pos
                                      , IPosition centre
                                      , IPosition start
                                      , IPosition end
                                      , double angtol)
        {
            // Work out the clockwise angle, using the direction from
            // the centre to the start of sector as the reference
            // bearing.

            // 18-OCT-99: I think the following only finds close matches
            // at the start of the curve, since the angular tolerance
            // is compared with respect to the reference bearing.

            //	CeTurn turn(centre,start);
            //	if ( turn.GetAngle(*this,angtol) <= turn.GetAngle(end,angtol) )
            //		return TRUE;
            //	else
            //		return FALSE;

            /*
             *      Don't know what's wrong with the following ...
             *
             * // Define a reference bearing through THIS location.
             * CeTurn turn(centre,*this);
             *
             * // Get the angle to the BC & check for an exact match.
             * FLOAT8 sAngle = turn.GetAngle(start,angtol);
             * if ( sAngle<TINY ) return TRUE;
             *
             * // Same for the EC.
             * FLOAT8 eAngle = turn.GetAngle(end,angtol);
             * if ( eAngle<TINY ) return TRUE;
             *
             * // This location is in sector if the angle to the EC
             * // is less than the angle to the BC.
             * return (eAngle<sAngle);
             */

            // Check if definitely in sector.

            Turn   turn  = new Turn(centre, start);
            double aThis = turn.GetAngleInRadians(pos);
            double aEnd  = turn.GetAngleInRadians(end);

            if (aThis <= aEnd)
            {
                return(true);
            }

            Debug.Assert(aThis >= 0.0 && aThis <= MathConstants.PIMUL2);
            Debug.Assert(aEnd >= 0.0 && aEnd <= MathConstants.PIMUL2);

            if (angtol > MathConstants.TINY)
            {
                // Check for match at the start of the curve.
                if (aThis < angtol || Math.Abs(aThis - MathConstants.PIMUL2) < angtol)
                {
                    return(true);
                }

                // And at the end of the curve.
                if (Math.Abs(aThis - aEnd) < angtol)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #4
0
        /// <summary>
        /// Checks whether a location falls in the sector lying between two points on a 
        /// clockwise circular arc. The only condition is that the location has an appropriate
        /// bearing with respect to the bearings of the BC & EC (i.e. the location does not
        /// necessarily lie ON the arc).
        /// </summary>
        /// <param name="pos">The position to check</param>
        /// <param name="centre">The centre of the circular arc</param>
        /// <param name="start">The first point of the arc (reckoned clockwise)</param>
        /// <param name="end">The second point of the arc (reckoned clockwise)</param>
        /// <param name="angtol">Angular tolerance (locations that are beyond the BC or EC
        /// by up to this much will also be regarded as "in-sector").</param>
        /// <returns>True if position falls in the sector defined by the arc</returns>
        public static bool IsInSector( IPosition pos
            , IPosition centre
            , IPosition start
            , IPosition end
            , double angtol)
        {
            // Work out the clockwise angle, using the direction from
            // the centre to the start of sector as the reference
            // bearing.

            // 18-OCT-99: I think the following only finds close matches
            // at the start of the curve, since the angular tolerance
            // is compared with respect to the reference bearing.

            //	CeTurn turn(centre,start);
            //	if ( turn.GetAngle(*this,angtol) <= turn.GetAngle(end,angtol) )
            //		return TRUE;
            //	else
            //		return FALSE;

            /*
                Don't know what's wrong with the following ...

            // Define a reference bearing through THIS location.
            CeTurn turn(centre,*this);

            // Get the angle to the BC & check for an exact match.
            FLOAT8 sAngle = turn.GetAngle(start,angtol);
            if ( sAngle<TINY ) return TRUE;

            // Same for the EC.
            FLOAT8 eAngle = turn.GetAngle(end,angtol);
            if ( eAngle<TINY ) return TRUE;

            // This location is in sector if the angle to the EC
            // is less than the angle to the BC.
            return (eAngle<sAngle);
            */

            // Check if definitely in sector.

            Turn turn = new Turn(centre, start);
            double aThis = turn.GetAngleInRadians(pos);
            double aEnd  = turn.GetAngleInRadians(end);
            if (aThis <= aEnd)
                return true;

            Debug.Assert(aThis>=0.0 && aThis<=MathConstants.PIMUL2);
            Debug.Assert(aEnd>=0.0 && aEnd<=MathConstants.PIMUL2);

            if (angtol > MathConstants.TINY)
            {
                // Check for match at the start of the curve.
                if (aThis<angtol || Math.Abs(aThis-MathConstants.PIMUL2)<angtol)
                    return true;

                // And at the end of the curve.
                if (Math.Abs(aThis-aEnd)<angtol)
                    return true;
            }

            return false;
        }