A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
geocentric-constant-position-mobility-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006,2007 INRIA
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: Mattia Sandri <mattia.sandri@unipd.it>
18 */
20
21#include <ns3/angles.h>
22
23#include <math.h>
24
25/**
26 * \file
27 * \ingroup mobility
28 * Class GeocentricConstantPositionMobilityModel implementation.
29 */
30
31namespace ns3
32{
33
34NS_OBJECT_ENSURE_REGISTERED(GeocentricConstantPositionMobilityModel);
35
36TypeId
38{
39 static TypeId tid =
40 TypeId("ns3::GeocentricConstantPositionMobilityModel")
42 .SetGroupName("Mobility")
44 .AddAttribute(
45 "PositionLatLongAlt",
46 "The geographic position, in degrees (lat/lon) and meter (alt), in the order: "
47 "latitude, longitude and "
48 "altitude",
49 Vector3DValue({0, 0, 0}),
52 .AddAttribute("GeographicReferencePoint",
53 "The point, in meters, taken as reference when converting from "
54 "geographic to topographic.",
55 Vector3DValue({0, 0, 0}),
59 return tid;
60}
61
62Vector
64{
66}
67
68void
70{
71 DoSetGeographicPosition(latLonAlt);
72}
73
74Vector
76{
78}
79
80void
82{
84}
85
86double
89{
90 return DoGetElevationAngle(other);
91}
92
93void
95 const Vector& position)
96{
98}
99
100Vector
102{
104}
105
106Vector
108{
109 return DoGetPosition();
110}
111
112void
114{
115 return DoSetPosition(position);
116}
117
118double
121{
122 return DoGetDistanceFrom(other);
123}
124
125Vector
127{
128 Vector topographicCoordinates =
132 return topographicCoordinates;
133}
134
135void
137{
138 Vector geographicCoordinates =
142 m_position = geographicCoordinates;
144}
145
146double
149{
150 Vector cartesianCoordA =
152 m_position.y,
153 m_position.z,
155 Vector cartesianCoordB = other->DoGetGeocentricPosition();
156
157 double distance = (cartesianCoordA - cartesianCoordB).GetLength();
158
159 return distance;
160}
161
162Vector
164{
165 return m_position;
166}
167
168void
170{
171 NS_ASSERT_MSG((latLonAlt.x >= -90) && (latLonAlt.x <= 90),
172 "Latitude must be between -90 deg and +90 deg");
173 NS_ASSERT_MSG(latLonAlt.z >= 0, "Altitude must be higher or equal than 0 meters");
174
175 m_position = latLonAlt;
176 // Normalize longitude to [-180, 180]
179}
180
181Vector
183{
184 Vector geocentricCoordinates =
186 m_position.y,
187 m_position.z,
189 return geocentricCoordinates;
190}
191
192void
194{
195 Vector geographicCoordinates =
198 m_position = geographicCoordinates;
200}
201
202double
205{
206 Vector me = this->DoGetGeocentricPosition();
207 Vector them = other->DoGetGeocentricPosition();
208
209 // a is assumed to be the terminal with the lowest altitude
210 Vector& a = (me.z < them.z ? me : them);
211 Vector& b = (me.z < them.z ? them : me);
212
213 Vector bMinusA = b - a;
214 double numerator = std::abs(a * bMinusA);
215 double denominator = a.GetLength() * bMinusA.GetLength();
216 double x = numerator / denominator;
217
218 // Enforce the appropriate domain range ([-1, 1]) for the argument of std::asin.
219 x = std::min(x, 1.0);
220 x = std::max(x, -1.0);
221
222 // asin returns radians, we convert to degrees
223 double elevAngle = abs((180.0 * M_1_PI) * asin(x));
224
225 return elevAngle;
226}
227
228void
230 const Vector& refPoint)
231{
233}
234
235Vector
237{
239}
240
241Vector
243{
244 return Vector(0.0, 0.0, 0.0);
245}
246
247} // namespace ns3
Mobility model using geocentric euclidean coordinates, as defined in 38.811 chapter 6....
virtual void SetGeographicPosition(const Vector &latLonAlt)
Set the position using geographic coordinates.
virtual Vector GetGeographicPosition() const
Get the position using geographic (geodetic) coordinates.
Vector m_geographicReferencePoint
This is the point (meter) taken as a reference for converting from geographic to topographic (also re...
virtual Vector GetGeocentricPosition() const
Get the position using Geocentric Cartesian coordinates.
virtual Vector GetCoordinateTranslationReferencePoint() const
Get the reference point for coordinate conversion.
static TypeId GetTypeId()
Register this type with the TypeId system.
virtual Vector DoGetGeographicPosition() const
Get the position using geographic (geodetic) coordinates.
virtual void DoSetCoordinateTranslationReferencePoint(const Vector &refPoint)
Set the reference point for coordinate conversion.
virtual void DoSetGeographicPosition(const Vector &latLonAlt)
Set the position using geographic coordinates.
virtual void SetCoordinateTranslationReferencePoint(const Vector &refPoint)
Set the reference point for coordinate conversion.
double GetDistanceFrom(Ptr< const GeocentricConstantPositionMobilityModel > other) const
virtual void SetGeocentricPosition(const Vector &position)
Set the position using Geocentric Cartesian coordinates.
virtual Vector DoGetGeocentricPosition() const
Get the position using Geocentric Cartesian coordinates.
virtual void DoSetGeocentricPosition(const Vector &position)
Set the position using Geocentric Cartesian coordinates.
Vector m_position
the constant Geographic position,, in order: latitude (degree), longitude (degree),...
virtual Vector DoGetCoordinateTranslationReferencePoint() const
Get the reference point for coordinate conversion.
double DoGetDistanceFrom(Ptr< const GeocentricConstantPositionMobilityModel > other) const
virtual double GetElevationAngle(Ptr< const GeocentricConstantPositionMobilityModel > other)
Computes elevation angle between a ground terminal and a HAPS/Satellite.
virtual double DoGetElevationAngle(Ptr< const GeocentricConstantPositionMobilityModel > other)
Computes elevation angle between a ground terminal and a HAPS/Satellite.
static Vector TopocentricToGeographicCoordinates(Vector pos, Vector refPoint, EarthSpheroidType sphType)
Conversion from topocentric to geographic.
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 GeographicToTopocentricCoordinates(Vector pos, Vector refPoint, EarthSpheroidType sphType)
Conversion from geographic to topocentric coordinates.
static Vector CartesianToGeographicCoordinates(Vector pos, EarthSpheroidType sphType)
Inverse of GeographicToCartesianCoordinates using [1].
Keep track of the current position and velocity of an object.
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Class GeocentricConstantPositionMobilityModel declaration.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
log2() macro definition; to deal with Bug 1467.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WrapTo180(double a)
Wrap angle in [-180, 180)
Definition: angles.cc:96
Ptr< const AttributeAccessor > MakeVector3DAccessor(T1 a1)
Definition: vector.h:365
Ptr< const AttributeChecker > MakeVector3DChecker()
Definition: vector.cc:39