A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
geographic-positions.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Benjamin Cizdziel <ben.cizdziel@gmail.com>
18 */
19
20#include <ns3/random-variable-stream.h>
21#include <ns3/vector.h>
22
23#ifndef GEOGRAPHIC_POSITIONS_H
24#define GEOGRAPHIC_POSITIONS_H
25
26namespace ns3
27{
28
29/**
30 * \ingroup mobility
31 *
32 * Consists of methods dealing with Earth geographic coordinates and locations.
33 */
35{
36 public:
37 /**
38 * Spheroid model to use for earth: perfect sphere (SPHERE), Geodetic
39 * Reference System 1980 (GRS80), or World Geodetic System 1984 (WGS84)
40 *
41 * Moritz, H. "Geodetic Reference System 1980." GEODETIC REFERENCE SYSTEM 1980.
42 * <https://web.archive.org/web/20170712034716/http://www.gfy.ku.dk/~iag/HB2000/part4/grs80_corr.htm>.
43 *
44 * "Department of Defense World Geodetic System 1984." National Imagery and
45 * Mapping Agency, 1 Jan. 2000.
46 * <https://web.archive.org/web/20200729203634/https://earth-info.nga.mil/GandG/publications/tr8350.2/wgs84fin.pdf>.
47 */
49 {
52 WGS84
53 };
54
55 /**
56 * Converts earth geographic/geodetic coordinates (latitude and longitude in
57 * degrees) with a given altitude above earth's surface (in meters) to Earth
58 * Centered Earth Fixed (ECEF) Cartesian coordinates (x, y, z in meters),
59 * where origin (0, 0, 0) is the center of the earth.
60 *
61 * @param latitude earth-referenced latitude (in degrees) of the point
62 * @param longitude earth-referenced longitude (in degrees) of the point
63 * @param altitude height of the point (in meters) above earth's surface
64 * @param sphType earth spheroid model to use for conversion
65 *
66 * @return a vector containing the Cartesian coordinates (x, y, z referenced
67 * in meters) of the point (origin (0, 0, 0) is center of earth)
68 */
69 static Vector GeographicToCartesianCoordinates(double latitude,
70 double longitude,
71 double altitude,
72 EarthSpheroidType sphType);
73
74 /**
75 * Inverse of GeographicToCartesianCoordinates using [1]
76 *
77 * This function iteratively converts cartesian (ECEF) coordinates to
78 * geographic coordinates. The residual delta is 1 m, which is approximately
79 * 1 / 30 arc seconds or 9.26e-6 deg.
80 *
81 * @param pos a vector containing the Cartesian coordinates (x, y, z referenced
82 * in meters) of the point (origin (0, 0, 0) is center of earth)
83 * @param sphType earth spheroid model to use for conversion
84 *
85 * @return Vector position where x = latitude (deg), y = longitude (deg),
86 * z = altitude above the ellipsoid (m)
87 *
88 * [1] "Ellipsoidal and Cartesian Coordinates Conversion", Navipedia,
89 * European Space Agency, Jul 8, 2019.
90 * <https://gssc.esa.int/navipedia/index.php/Ellipsoidal_and_Cartesian_Coordinates_Conversion>
91 */
92 static Vector CartesianToGeographicCoordinates(Vector pos, EarthSpheroidType sphType);
93
94 /**
95 * Generates uniformly distributed random points (in ECEF Cartesian
96 * coordinates) within a given altitude above earth's surface centered around
97 * a given origin point (on earth's surface, in geographic/geodetic coordinates)
98 * within a given distance radius (using arc length of earth's surface, not
99 * pythagorean distance).
100 * Distance radius is measured as if all generated points are on earth's
101 * surface (with altitude = 0).
102 * Assumes earth is a perfect sphere.
103 *
104 * @param originLatitude origin point latitude in degrees
105 * @param originLongitude origin point longitude in degrees
106 * @param maxAltitude maximum altitude in meters above earth's surface with
107 * which random points can be generated
108 * @param numPoints number of points to generate
109 * @param maxDistFromOrigin max distance in meters from origin with which
110 * random transmitters can be generated (all transmitters are less than or
111 * equal to this distance from the origin, relative to points being on earth's
112 * surface)
113 * @param uniRand pointer to the uniform random variable to use for random
114 * location and altitude generation
115 *
116 * @return a list containing the vectors (x, y, z location referenced in
117 * meters from origin at center of earth) of each point generated
118 */
119 static std::list<Vector> RandCartesianPointsAroundGeographicPoint(
120 double originLatitude,
121 double originLongitude,
122 double maxAltitude,
123 int numPoints,
124 double maxDistFromOrigin,
126};
127
128} // namespace ns3
129
130#endif /* GEOGRAPHIC_POSITIONS_H */
Consists of methods dealing with Earth geographic coordinates and locations.
static std::list< Vector > RandCartesianPointsAroundGeographicPoint(double originLatitude, double originLongitude, double maxAltitude, int numPoints, double maxDistFromOrigin, Ptr< UniformRandomVariable > uniRand)
Generates uniformly distributed random points (in ECEF Cartesian coordinates) within a given altitude...
EarthSpheroidType
Spheroid model to use for earth: perfect sphere (SPHERE), Geodetic Reference System 1980 (GRS80),...
static Vector GeographicToCartesianCoordinates(double latitude, double longitude, double altitude, EarthSpheroidType sphType)
Converts earth geographic/geodetic coordinates (latitude and longitude in degrees) with a given altit...
static Vector CartesianToGeographicCoordinates(Vector pos, EarthSpheroidType sphType)
Inverse of GeographicToCartesianCoordinates using [1].
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.