-
Notifications
You must be signed in to change notification settings - Fork 4
GeoreferenceSystem
The Georeference System handles conversions between Unity coordinates and geospatial coordinates.
public class GeoreferenceSystem
: MonoBehaviour
Access | Type | Name | Description | |
---|---|---|---|---|
const | double | EARTH_FLATTENING | The WGS-84 inverse flattening value of the Earth. | |
const | double | EARTH_MAJOR_AXIS | The WGS-84 equatorial radius of the Earth in meters. | |
const | double | EARTH_MINOR_AXIS | The WGS-84 polar radius of the Earth in meters. | |
Public | EEarthShape | EarthShape | The shape of the world in the scene. | |
Private | dmat4 | ECEFFrameToWorldFrame | The matrix to transform a vector from ECEF CRS to Unity. | |
const | double | EPSILON | Machine Epsilon - float approx 1e-7, double approx 2e-16 | |
Private | Vector3Double | GeographicEllipsoid | Vector containing ellipsoidal information pertaining to the WGS-84 Earth (X = EARTH_MAJOR_AXIS, Y = EARTH_MAJOR_AXIS, Z = EARTH_MINOR_AXIS). | |
Private | Vector3Double | OriginECEF | The ECEF location of the Unity origin. | |
Public | FLatLonAlt | OriginLLA | The Latitude in decimal degrees, Longitude in decimal degrees, and Altitude in meters of the Unity origin (0, 0, 0). | |
Private | dmat4 | UnityFrameToWorldFrame | The matrix to transform a vector into the Unity coordinate frame. | |
Private | dmat4 | WorldFrameToECEFFrame | The matrix to transform a vector from Unity to ECEF CRS. | |
Private | dmat4 | WorldFrameToUnityFrame | The matrix to transform a vector from the Unity coordinate frame. |
Access | Return | Name | Description | |
---|---|---|---|---|
Private | void | Awake() | Awake is called when the script instance is being loaded. | |
Private | Vector3Double | ecef_to_flatearth(Vector3Double ecefLocation) | Transforms the given ECEF XYZ location to a flat Earth coordinate. | |
Public | Vector3 | ECEFToUnity(Vector3Double ECEFLocation, Vector3 OriginRebasingOffset) | Converts ECEF coordinates to Unity coordinates. | |
Private | Vector3Double | flatearth_to_ecef(Vector3Double FlatEarthCoords) | Transforms the given flat Earth coordinates to an ECEF XYZ coordinate | |
Private | FLatLonAlt | flatearth_to_geodetic(Vector3Double FlatEarthCoords) | Transforms the given flat Earth coordinates to geodetic Lat, Lon, Alt coordinates | |
Private | Vector3Double | geodetic_to_flatearth(FLatLonAlt latlonalt) | Transforms the given geodetic Lat, Lon, Alt coordinate to a flat earth coordinate | |
Public | FEastNorthUp | GetENUVectorsAtECEFLocation(Vector3Double ECEFLocation) | Get the East, North, Up vectors at the given ECEF location. | |
Public | FEastNorthUp | GetENUVectorsAtEngineLocation(Vector3 UnityLocation, Vector3 OriginRebasingOffset) | Get the East, North, Up vectors at the given Unity location. | |
Public | FNorthEastDown | GetNEDVectorsAtECEFLocation(Vector3Double ECEFLocation) | Get the North, East, Down vectors at the given ECEF location. | |
Public | FNorthEastDown | GetNEDVectorsAtEngineLocation(Vector3 UnityLocation, Vector3 OriginRebasingOffset) | Get the North, East, Down vectors at the given Unity location. | |
Public | Vector3Double | GetOriginECEF() | Gets the ECEF location of the Unity origin. | |
Public | FLatLonAlt | GetOriginLLA() | Gets the Lat, Lon, Alt coordinates of the Unity origin. | |
Private | string | GetUTMLetterDesignator(double Lat) | Gets the UTM letter designator for the given latitude. | |
Private | dmat4 | GetWorldFrameToECEFFrame(Vector3Double Ellisoid, Vector3Double ECEFLocation) | Get the matrix to transform a vector from Unity to ECEF CRS. | |
Public | FUTMCoordinates | LatLonAltToProjected(FLatLonAlt LatLonAltToConvert) | Converts the given Lat and Lon to UTM coordinates. Lat and Lon should be in decimal degrees. | |
Public | Vector3 | LatLonAltToUnity(FLatLonAlt LatLonAlt, Vector3 OriginRebasingOffset) | Converts the given Lat, Lon, Alt coordinates to Unity coordinates. | |
Private | void | SetupVars() | Initializes the needed variables that are used for geospatial conversions. | |
Public | Vector3Double | UnityToECEF(Vector3 UnityLocation, Vector3 OriginRebasingOffset) | Converts Unity coordinates into ECEF coordinates. | |
Public | FLatLonAlt | UnityToLatLonAlt(Vector3 UnityLocation, Vector3 OriginRebasingOffset) | Converts Unity coordinates into geodetic Lat, Lon, Alt coordinates. |
const double EARTH_FLATTENING = 298.257223563
The WGS-84 inverse flattening value of the Earth.
const double EARTH_MAJOR_AXIS = 6378137
The WGS-84 equatorial radius of the Earth in meters.
const double EARTH_MINOR_AXIS = 6356752.314245
The WGS-84 polar radius of the Earth in meters.
public EEarthShape EarthShape
The shape of the world in the scene.
private dmat4 ECEFFrameToWorldFrame
The matrix to transform a vector from ECEF CRS to Unity.
const double EPSILON = 2.220446049250313e-16
Machine Epsilon - float approx 1e-7, double approx 2e-16
private Vector3Double GeographicEllipsoid = new Vector3Double
{
X = EARTH_MAJOR_AXIS,
Y = EARTH_MAJOR_AXIS,
Z = EARTH_MINOR_AXIS
}
Vector containing ellipsoidal information pertaining to the WGS-84 Earth.
private Vector3Double OriginECEF
The ECEF location of the Unity origin.
public FLatLonAlt OriginLLA
The Latitude in decimal degrees, Longitude in decimal degrees, and Altitude in meters of the Unity origin (0, 0, 0).
private dmat4 UnityFrameToWorldFrame
The matrix to transform a vector into the Unity coordinate frame.
private dmat4 WorldFrameToECEFFrame
The matrix to transform a vector from Unity to ECEF CRS.
private dmat4 WorldFrameToUnityFrame
The matrix to transform a vector from the Unity coordinate frame.
private void Awake()
Awake is called when the script instance is being loaded.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html
private Vector3Double ecef_to_flatearth
(
Vector3Double ecefLocation
)
Transforms the given ECEF XYZ location to a flat Earth coordinate.
Parameter | Description |
---|---|
ecefLocation | The ECEF location to transform. |
Returns |
---|
The X (East), Y (North), and Z (Up) location in a flat Earth coordinate system. |
public Vector3 ECEFToUnity
(
Vector3Double ECEFLocation,
Vector3 OriginRebasingOffset = default
)
Converts ECEF coordinates to Unity coordinates.
Parameter | Description |
---|---|
ECEFLocation | The ECEF location to transform. |
OriginRebasingOffset | The offset that has been applied to the origin if any origin shifting has been performed. |
Returns |
---|
The Unity coordinates. |
private Vector3Double flatearth_to_ecef
(
Vector3Double FlatEarthCoords
)
Transforms the given flat Earth coordinates to an ECEF XYZ coordinate
Parameter | Description |
---|---|
FlatEarthCoords | The flat Earth X (East), Y (North), and Z (Up) coordinate to transform. |
Returns |
---|
The ECEF XYZ location. |
private FLatLonAlt flatearth_to_geodetic
(
Vector3Double FlatEarthCoords
)
Transforms the given flat Earth coordinates to geodetic Lat, Lon, Alt coordinates
Parameter | Description |
---|---|
FlatEarthCoords | The flat Earth X (East), Y (North), and Z (Up) coordinate to transform. |
Returns |
---|
The Lat in decimal degrees, Lon in decimal degrees, and Alt in meters. |
private Vector3Double geodetic_to_flatearth
(
FLatLonAlt latlonalt
)
Transforms the given geodetic Lat, Lon, Alt coordinate to a flat earth coordinate
Parameter | Description |
---|---|
latlonalt | The Lat in decimal degrees, Lon in decimal degrees, and Alt in meters to transform. |
Returns |
---|
The X (East), Y (North), and Z (Up) location in a flat Earth coordinate system. |
public FEastNorthUp GetENUVectorsAtECEFLocation
(
Vector3Double ECEFLocation
)
Get the East, North, Up vectors at the given ECEF location.
Parameter | Description |
---|---|
ECEFLocation | The ECEF location to get the East, North, Up vectors of. |
Returns |
---|
The East, North, Up vectors in terms of Unity's coordinate system |
public FEastNorthUp GetENUVectorsAtEngineLocation
(
Vector3 UnityLocation,
Vector3 OriginRebasingOffset = default
)
Get the East, North, Up vectors at the given Unity location.
Parameter | Description |
---|---|
UnityLocation | The Unity location to get the East, North, Up vectors of. |
OriginRebasingOffset | The offset that has been applied to the origin if any origin shifting has been performed. |
Returns |
---|
The East, North, Up vectors in terms of Unity's coordinate system. |
public FNorthEastDown GetNEDVectorsAtECEFLocation
(
Vector3Double ECEFLocation
)
Get the North, East, Down vectors at the given ECEF location.
Parameter | Description |
---|---|
ECEFLocation | The ECEF location to get the North, East, Down vectors of. |
Returns |
---|
The North, East, Down vectors in terms of Unity's coordinate system |
public FNorthEastDown GetNEDVectorsAtEngineLocation
(
Vector3 UnityLocation,
Vector3 OriginRebasingOffset = default
)
Get the North, East, Down vectors at the given Unity location.
Parameter | Description |
---|---|
UnityLocation | The Unity location to get the North, East, Down vectors of. |
OriginRebasingOffset | The offset that has been applied to the origin if any origin shifting has been performed. |
Returns |
---|
The North, East, Down vectors in terms of Unity's coordinate system. |
public Vector3Double GetOriginECEF()
Gets the ECEF location of the Unity origin.
public FLatLonAlt GetOriginLLA()
Gets the Lat, Lon, Alt coordinates of the Unity origin.
private string GetUTMLetterDesignator
(
double Lat
)
Gets the UTM letter designator for the given latitude.
Parameter | Description |
---|---|
Lat | The latitude to get the UTM letter designator of. Should be given in decimal degrees. |
Returns |
---|
A string containing the UTM letter designator. |
private dmat4 GetWorldFrameToECEFFrame
(
Vector3Double Ellisoid,
Vector3Double ECEFLocation
)
Get the matrix to transform a vector from Unity to ECEF CRS.
Parameter | Description |
---|---|
Ellisoid | The ellipsoid of the world. |
ECEFLocation | The ECEF to get the world frame of. |
Returns |
---|
The transformation matrix needed to convert Unity locations to ECEF CRS. |
public FUTMCoordinates LatLonAltToProjected
(
FLatLonAlt LatLonAltToConvert
)
Converts the given Lat and Lon to UTM coordinates. Lat and Lon should be in decimal degrees.
Parameter | Description |
---|---|
LatLonAltToConvert | The Lat and Lon to convert |
Returns |
---|
The UTM Coordinates. |
public Vector3 LatLonAltToUnity
(
FLatLonAlt LatLonAlt,
Vector3 OriginRebasingOffset = default
)
Converts the given Lat, Lon, Alt coordinates to Unity coordinates.
Parameter | Description |
---|---|
LatLonAlt | The Lat, Lon, Alt coordinates to transform. |
OriginRebasingOffset | The offset that has been applied to the origin if any origin shifting has been performed. |
Returns |
---|
The Unity coordinates. |
private void SetupVars()
Initializes the needed variables that are used for geospatial conversions.
public Vector3Double UnityToECEF
(
Vector3 UnityLocation,
Vector3 OriginRebasingOffset = default
)
Converts Unity coordinates into ECEF coordinates.
Parameter | Description |
---|---|
UnityLocation | The Unity coordinates to transform. |
OriginRebasingOffset | The offset that has been applied to the origin if any origin shifting has been performed. |
Returns |
---|
The ECEF XYZ coordinates. |
public FLatLonAlt UnityToLatLonAlt
(
Vector3 UnityLocation,
Vector3 OriginRebasingOffset = default
)
Converts Unity coordinates into geodetic Lat, Lon, Alt coordinates.
Parameter | Description |
---|---|
UnityLocation | The Unity coordinates to transform. |
OriginRebasingOffset | The offset that has been applied to the origin if any origin shifting has been performed. |
Returns |
---|
The Lat, Lon, Alt coordinates. |