/// <summary> /// Calculates the offset distance. /// </summary> /// <param name="offset">The offset.</param> /// <param name="offsetBearing"></param> /// <param name="offsetAngle"></param> private static double CalculateOffsetDistance(double offset, double offsetBearing, double offsetAngle) { // offset / (SIN(RADIANS(((OffsetBearing - OffsetAngleLeft) + 360) % 360))) var denominator = (Math.Sin(SpatialUtil.ToRadians(((offsetBearing - offsetAngle) + 360) % 360))); return(offset / denominator); }
public static double InputLong(double longDeg, double max, string name) { if (double.IsNaN(longDeg) || longDeg < -max || longDeg > max) { throw new ArgumentOutOfRangeException(nameof(longDeg), string.Format(CultureInfo.InvariantCulture, Resource.InputLongitudeIsOutOfRange, longDeg, max)); } return(NormalizeLongitudeRad(SpatialUtil.ToRadians(longDeg))); }
public static double InputLat(double latDeg, double max, string name) { if (double.IsNaN(latDeg) || latDeg < -max || latDeg > max) { throw new ArgumentOutOfRangeException(name, string.Format(CultureInfo.InvariantCulture, Resource.InputLatitudeIsOutOfRange, latDeg, max)); } return(Clamp(Math.PI / 2, SpatialUtil.ToRadians(latDeg))); }
/// <summary> /// Gets the second point radian. /// </summary> /// <param name="nextPoint">The next point.</param> /// <param name="middlePoint">The middle point.</param> /// <returns></returns> private double GetSecondPointRadian(LRSPoint nextPoint, LRSPoint middlePoint) { var atan = GetAtanInDegree(middlePoint, nextPoint); atan = 90 - atan; atan = atan <= 0 ? 360 + atan : atan; return(SpatialUtil.ToRadians(180 - atan)); }
/// <summary> /// Gets the first point radian. /// </summary> /// <param name="previousPoint">The previous point.</param> /// <param name="middlePoint">The middle point.</param> /// <returns></returns> private double GetFirstPointRadian(LRSPoint previousPoint, LRSPoint middlePoint) { var atan = GetAtanInDegree(middlePoint, previousPoint); atan = 90 - atan; atan = atan <= 0 ? 360 + atan : atan; return(SpatialUtil.ToRadians(360 - atan)); }
public static AffineTransform Rotate(double angleDeg) { var angle = SpatialUtil.ToRadians(angleDeg); var transform = new AffineTransform { _ax = Math.Cos(angle), _ay = Math.Sin(angle) }; transform._bx = -transform._ay; transform._by = transform._ax; return(transform); }
/// <summary> /// Gets the parallel point. /// </summary> /// <returns>Point parallel to the current point.</returns> private LRSPoint GetParallelPoint() { var newX = X + (OffsetDistance * Math.Cos(SpatialUtil.ToRadians(90 - _offsetAngle))); var newY = Y + (OffsetDistance * Math.Sin(SpatialUtil.ToRadians(90 - _offsetAngle))); return(new LRSPoint( newX, newY, null, M, _srid )); }
public void AddLine(double latitude, double longitude, double?z, double?m) { // Transforming from geodetic coordinates to a unit vector. var endPoint = SpatialUtil.SphericalDegToCartesian(latitude, longitude); var angle = endPoint.Angle(_startPoint); if (angle > MinAngle) { // _startPoint and endPoint are the unit vectors that correspond to the input // start and end points. In their 3D space we operate in a local coordinate system // where _startPoint is the x axis and the xy plane contains endPoint. Every // point is now generated from the previous one by a fixed rotation in the local // xy plane, and converted back to geodetic coordinates. // Construct the local z and y axes. var zAxis = (_startPoint + endPoint).CrossProduct(_startPoint - endPoint).Unitize(); var yAxis = (_startPoint).CrossProduct(zAxis); // Calculating how many points we need. var count = Convert.ToInt32(Math.Ceiling(angle / SpatialUtil.ToRadians(_angle))); // Scaling the angle so that points are equally placed. var exactAngle = angle / count; var cosine = Math.Cos(exactAngle); var sine = Math.Sin(exactAngle); // Setting the first x and y points in our local coordinate system. var x = cosine; var y = sine; for (var i = 0; i < count - 1; i++) { var newPoint = (_startPoint * x + yAxis * y).Unitize(); // Adding the point. _sink.AddLine(SpatialUtil.LatitudeDeg(newPoint), SpatialUtil.LongitudeDeg(newPoint), null, null); // Rotating to get next point. var r = x * cosine - y * sine; y = x * sine + y * cosine; x = r; } } _sink.AddLine(latitude, longitude, z, m); // Remembering last point we added. _startPoint = endPoint; }