24 #include <ns3/geographic-positions.h> 78 double originLongitude,
81 double maxDistFromOrigin,
86 virtual void DoRun (
void);
94 static std::string
Name (
double originLatitude,
95 double originLongitude,
96 double maxDistFromOrigin);
107 double originLongitude,
108 double maxDistFromOrigin)
110 std::ostringstream oss;
111 oss <<
"origin latitude = " << originLatitude <<
" degrees, " 112 <<
"origin longitude = " << originLongitude <<
" degrees, " 113 <<
"max distance from origin = " << maxDistFromOrigin;
118 double originLongitude,
121 double maxDistFromOrigin,
123 :
TestCase (
Name (originLatitude, originLongitude, maxDistFromOrigin)),
124 m_originLatitude (originLatitude),
125 m_originLongitude (originLongitude),
126 m_maxAltitude (maxAltitude),
127 m_numPoints (numPoints),
128 m_maxDistFromOrigin (maxDistFromOrigin),
140 std::list<Vector> points = GeographicPositions::RandCartesianPointsAroundGeographicPoint (
m_originLatitude,
146 Vector origin = GeographicPositions::GeographicToCartesianCoordinates (
m_originLatitude,
149 GeographicPositions::SPHERE);
151 while (!points.empty ())
153 randPoint = points.front ();
157 double straightDistFromOrigin = sqrt (pow (randPoint.x - origin.x, 2) +
158 pow (randPoint.y - origin.y, 2) +
159 pow (randPoint.z - origin.z, 2));
166 "random point (" << randPoint.x <<
", " << randPoint.y
167 <<
", " << randPoint.z <<
") is outside of max radius from origin");
184 :
TestSuite (
"rand-cart-around-geo", UNIT)
186 NS_LOG_INFO (
"creating RandCartAroundGeoTestSuite");
189 for (
double originLatitude = -89.9; originLatitude <= 89.9; originLatitude += 35.96)
191 for (
double originLongitude = 0; originLongitude <= 360; originLongitude += 72)
193 for (
double maxDistFromOrigin = 1000; maxDistFromOrigin <= 1000000; maxDistFromOrigin *= 10)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Rand Cart Around Geo Test Case.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
RandCartAroundGeoTestCase(double originLatitude, double originLongitude, double maxAltitude, int numPoints, double maxDistFromOrigin, Ptr< UniformRandomVariable > uniRand)
Constructor.
virtual ~RandCartAroundGeoTestCase()
static std::string Name(std::string str, uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t serverReadSize, uint32_t serverWriteSize, uint32_t sourceReadSize, bool useIpv6)
Rand Cart Around Geo Test Suite.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
static std::string Name(double originLatitude, double originLongitude, double maxDistFromOrigin)
name function
double m_originLongitude
origin longitude
double m_originLatitude
origin latitude
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static RandCartAroundGeoTestSuite g_RandCartAroundGeoTestSuite
the test suite
double m_maxAltitude
maximum altitude
static const double EARTH_RADIUS
Earth's radius in meters if modeled as a perfect sphere.
const double TOLERANCE
0.1 meter tolerance for testing, which is very small compared to the maximum distances from origin be...
Ptr< UniformRandomVariable > m_uniRand
random number
static const double EARTH_RADIUS
earth's radius in meters if modeled as a perfect sphere
int m_numPoints
number of points
RandCartAroundGeoTestSuite()
static const double TOLERANCE
Tolerance used to check reciprocal of two numbers.
double m_maxDistFromOrigin
maximum distance from origin
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.