/// <summary>
        /// Gets the deviation angle of 3 points.
        /// </summary>
        /// <param name="pointA">The point a.</param>
        /// <param name="pointO">The point o.</param>
        /// <param name="pointB">The point b.</param>
        /// <param name="isNegativeOffset">if set to <c>true</c> [is negative offset].</param>
        /// <returns></returns>
        private double GetAOBAngle(LRSPoint pointA, LRSPoint pointO, LRSPoint pointB, bool isNegativeOffset)
        {
            const double angleCorrection = Math.PI / 2;
            const double angleConversion = 2 * Math.PI;

            var atanAo = pointA.GetAtanInRadian(pointO) + angleCorrection;
            var atanBo = pointB.GetAtanInRadian(pointO) + angleCorrection;

            // angle conversion
            atanAo = SpatialUtil.ToDegrees(atanAo <= 0 ? angleConversion + atanAo : atanAo);
            atanBo = SpatialUtil.ToDegrees(atanBo <= 0 ? angleConversion + atanBo : atanBo);

            var deviationAngle =
                360 - (atanAo > atanBo
                    ? 360 - (atanAo - atanBo)
                    : atanBo - atanAo);

            // for positive offset; offset curve will be to the left of input geom;
            // so for positive deviation angle the computed angle should be subtracted from 360
            // for negative offset; offset curve will be to the right of input geom
            return(isNegativeOffset ? deviationAngle : 360 - deviationAngle);
        }
Пример #2
0
 // Angle in degrees between vectors a and b.
 public double AngleInDegrees(Vector3 a)
 {
     return(SpatialUtil.ToDegrees(Angle(a)));
 }
 /// <summary>
 /// Calculates the offset bearing.
 /// </summary>
 /// <param name="nextPoint">The next point.</param>
 private double CalculateOffsetBearing(LRSPoint nextPoint)
 {
     _angle = SpatialUtil.ToDegrees(GetAtanInRadian(nextPoint));
     return((90 - _angle + 360) % 360);
 }
        /// <summary>
        /// Gets the atan2 in degrees.
        /// This does angle correct when atan2 value is negative
        /// </summary>
        /// <param name="point1">The point1.</param>
        /// <param name="point2">The point2.</param>
        /// <returns>Atan2 in degrees</returns>
        private double GetAtanInDegree(LRSPoint point1, LRSPoint point2)
        {
            var atan = point1.GetAtanInRadian(point2);

            return(SpatialUtil.ToDegrees(atan <= 0 ? (2 * Math.PI) + atan : atan));
        }