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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mattia Sandri <mattia.sandri@unipd.it>
7 */
9
10#include <ns3/angles.h>
11
12#include <math.h>
13
14/**
15 * \file
16 * \ingroup mobility
17 * Class GeocentricConstantPositionMobilityModel implementation.
18 */
19
20namespace ns3
21{
22
23NS_OBJECT_ENSURE_REGISTERED(GeocentricConstantPositionMobilityModel);
24
25TypeId
27{
28 static TypeId tid =
29 TypeId("ns3::GeocentricConstantPositionMobilityModel")
31 .SetGroupName("Mobility")
33 .AddAttribute(
34 "PositionLatLongAlt",
35 "The geographic position, in degrees (lat/lon) and meter (alt), in the order: "
36 "latitude, longitude and "
37 "altitude",
38 Vector3DValue({0, 0, 0}),
41 .AddAttribute("GeographicReferencePoint",
42 "The point, in meters, taken as reference when converting from "
43 "geographic to topographic.",
44 Vector3DValue({0, 0, 0}),
48 return tid;
49}
50
51Vector
56
57void
62
63Vector
68
69void
74
75double
81
82void
88
89Vector
94
95Vector
100
101void
103{
104 return DoSetPosition(position);
105}
106
107double
113
114Vector
123
124void
126{
127 Vector geographicCoordinates =
131 m_position = geographicCoordinates;
133}
134
135double
138{
139 Vector cartesianCoordA =
141 m_position.y,
142 m_position.z,
144 Vector cartesianCoordB = other->DoGetGeocentricPosition();
145
146 double distance = (cartesianCoordA - cartesianCoordB).GetLength();
147
148 return distance;
149}
150
151Vector
156
157void
159{
160 NS_ASSERT_MSG((latLonAlt.x >= -90) && (latLonAlt.x <= 90),
161 "Latitude must be between -90 deg and +90 deg");
162 NS_ASSERT_MSG(latLonAlt.z >= 0, "Altitude must be higher or equal than 0 meters");
163
164 m_position = latLonAlt;
165 // Normalize longitude to [-180, 180]
168}
169
170Vector
172{
173 Vector geocentricCoordinates =
175 m_position.y,
176 m_position.z,
178 return geocentricCoordinates;
179}
180
181void
183{
184 Vector geographicCoordinates =
187 m_position = geographicCoordinates;
189}
190
191double
194{
195 Vector me = this->DoGetGeocentricPosition();
196 Vector them = other->DoGetGeocentricPosition();
197
198 // a is assumed to be the terminal with the lowest altitude
199 Vector& a = (me.z < them.z ? me : them);
200 Vector& b = (me.z < them.z ? them : me);
201
202 Vector bMinusA = b - a;
203 double numerator = std::abs(a * bMinusA);
204 double denominator = a.GetLength() * bMinusA.GetLength();
205 double x = numerator / denominator;
206
207 // Enforce the appropriate domain range ([-1, 1]) for the argument of std::asin.
208 x = std::min(x, 1.0);
209 x = std::max(x, -1.0);
210
211 // asin returns radians, we convert to degrees
212 double elevAngle = std::abs((180.0 * M_1_PI) * asin(x));
213
214 return elevAngle;
215}
216
217void
223
224Vector
229
230Vector
232{
233 return Vector(0.0, 0.0, 0.0);
234}
235
236} // 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.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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:75
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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:85
Ptr< const AttributeAccessor > MakeVector3DAccessor(T1 a1)
Definition vector.h:354
Ptr< const AttributeChecker > MakeVector3DChecker()
Definition vector.cc:28