Skip to content

MASINavigation

MOARdV edited this page May 18, 2017 · 26 revisions

MASINavigation.cs

CAUTION: These methods are subject to change as this code matures.

MASINavigation encapsulates navigation functionality, including emulating radio navigation. It provides methods to determine the distance from the vessel to a particular lat/lon location on the planet, and the distance between two arbitrary points on a planet.

All methods use the current vessel's parent body as the body for calculations.

Equations adapted from http://www.movable-type.co.uk/scripts/latlong.html.

nav.Bearing(double latitude1, double longitude1, double latitude2, double longitude2)

  • latitude1: Latitude of position 1 in degrees. Negative values indicate south, positive is north.
  • longitude1: Longitude of position 1 in degrees. Negative values indicate west, positive is east.
  • latitude2: Latitude of position 2 in degrees. Negative values indicate south, positive is north.
  • longitude2: Longitude of position 2 in degrees. Negative values indicate west, positive is east.

Returns: Bearing (heading) in degrees.

UNTESTED

Returns the great-circle route bearing from (lat1, lon1) to (lat2, lon2).

nav.BearingFromVessel(double latitude, double longitude)

  • latitude: Latitude of the destination point in degrees. Negative values indicate south, positive is north.
  • longitude: Longitude of destination point in degrees. Negative values indicate west, positive is east.

Returns: Hearing in degrees from the vessel to the destination.

UNTESTED

Returns the great-circle bearing from the vessel to the specified lat/lon coordinates.

nav.DestinationLatitude(double latitude, double longitude, double range, double bearing)

  • latitude: Latitude of the point of origin. Negative values indicate south, positive is north.
  • longitude: Longitude of the point of origin. Negative values indicate west, positive is east.
  • range: Distance to travel along the bearing, in meters.
  • bearing: Bearing in degrees to travel.

Returns: Latitude in degrees.

UNTESTED

Returns the latitude found at the given range along the given bearing.

TODO: Replace fc.DestinationLatitude and fc.DestinationLongitude with fc.DestinationCoordinates which returns latitude and longitude at the same time so computations do not need to be made twice.

nav.DestinationLatitudeFromVessel(double range, double bearing)

  • range: Distance to travel along the bearing, in meters.
  • bearing: Bearing in degrees to travel.

Returns: Latitude in degrees.

UNTESTED

Returns the latitude found at the given range along the given bearing from the current vessel.

nav.DestinationLongitude(double latitude, double longitude, double range, double bearing)

  • latitude: Latitude of the point of origin. Negative values indicate south, positive is north.
  • longitude: Longitude of the point of origin. Negative values indicate west, positive is east.
  • range: Distance to travel along the bearing, in meters.
  • bearing: Bearing in degrees to travel.

Returns: Longitude in degrees.

UNTESTED

Returns the longitude found at the given range along the given bearing from the point of origin.

nav.DestinationLongitudeFromVessel(double range, double bearing)

  • range: Distance to travel along the bearing, in meters.
  • bearing: Bearing in degrees to travel.

Returns: Longitude in degrees.

UNTESTED

Returns the longitude found at the given range along the given bearing from the current vessel.

nav.GroundDistance(double latitude1, double longitude1, double latitude2, double longitude2)

  • latitude1: Latitude of position 1 in degrees. Negative values indicate south, positive is north.
  • longitude1: Longitude of position 1 in degrees. Negative values indicate west, positive is east.
  • latitude2: Latitude of position 2 in degrees. Negative values indicate south, positive is north.
  • longitude2: Longitude of position 2 in degrees. Negative values indicate west, positive is east.

Returns: Distance in meters between the two points, following the surface of the planet.

Return the ground distance between two coordinates on a planet.

Assumes the planet is the one the vessel is currently orbiting / flying over. Uses the sea-level altitude.

nav.GroundDistanceFromVessel(double latitude, double longitude)

  • latitude: Latitude of the destination point in degrees. Negative values indicate south, positive is north.
  • longitude: Longitude of destination point in degrees. Negative values indicate west, positive is east.

Returns: Distance in meters between the two points, following the surface of the planet.

Return the ground distance between the vessel and a location on the surface of the planet.

Uses the sea-level altitude.

nav.LineOfSight(double altitude)

  • altitude: Altitude above sea level, in meters.

Returns: Distance to the horizon, in meters.

Returns the distance to the horizon based on a given altitude ASL.

The horizon is assumed to be at sea level. Due to the small sizes of most stock KSP worlds, and the relatively large mountains, this number will not be reliable for estimating whether a given land position is within line-of-sight.


This documentation was automatically generated from source code at 18:09 UTC on 10/May/2017.

Clone this wiki locally