/// <summary> /// Gets the elevation at the given <paramref name="position"/>, in meters. /// </summary> /// <param name="planet">The mapped planet.</param> /// <param name="elevationMap">An elevation map.</param> /// <param name="position">The position at which to determine elevation.</param> /// <param name="options">The map projection used.</param> /// <returns> /// The elevation at the given <paramref name="position"/>, in meters. /// </returns> public static double GetElevationAt( this Planetoid planet, Image <L16> elevationMap, Vector3 position, MapProjectionOptions?options = null) => planet.GetElevationAt( elevationMap, planet.VectorToLatitude(position), planet.VectorToLongitude(position), options);
/// <summary> /// Gets the elevation at the given <paramref name="position"/>, in meters. /// </summary> /// <param name="region">The mapped region.</param> /// <param name="planet">The mapped planet.</param> /// <param name="elevationMap">An elevation map.</param> /// <param name="position">The position at which to determine elevation.</param> /// <param name="equalArea"> /// If <see langword="true"/> the projection is a cylindrical equal-area projection. /// Otherwise, an equirectangular projection will be used. /// </param> /// <returns> /// The elevation at the given <paramref name="position"/>, in meters. Or <see /// cref="double.NaN"/> if the given <paramref name="position"/> is not contained within /// this region. /// </returns> public static double GetElevationAt( this SurfaceRegion region, Planetoid planet, Image <L16> elevationMap, Vector3 position, bool equalArea = false) { var pos = region.PlanetaryPosition + position; return(region.GetElevationAt( planet, elevationMap, planet.VectorToLatitude(pos), planet.VectorToLongitude(pos), equalArea)); }
double eastLongitude) GetBounds(Planetoid planet) { var lat = planet.VectorToLatitude(PlanetaryPosition); var lon = planet.VectorToLongitude(PlanetaryPosition); var range = (double)((Frustum <HugeNumber>)Shape).FieldOfViewAngle; if (range is >= Math.PI or <= 0) { return( -DoubleConstants.HalfPi, -Math.PI, DoubleConstants.HalfPi, Math.PI); } var halfLatRange = range / 2; var equalAreaAspectRatio = Math.PI * Math.Cos(lat).Square(); var halfLonRange = Math.Min( DoubleConstants.HalfPi, Math.Max(range, range * equalAreaAspectRatio / 2)); var minLat = LatitudeBounded(lat - halfLatRange); var maxLat = LatitudeBounded(lat + halfLatRange); var minLon = LongitudeBounded(lon - halfLonRange); var maxLon = LongitudeBounded(lon + halfLonRange); if (minLat > maxLat) { var tmp = minLat; minLat = maxLat; maxLat = tmp; } if (minLon > maxLon) { var tmp = minLon; minLon = maxLon; maxLon = tmp; } return( minLat, minLon, maxLat, maxLon); }