mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
Fix ISL LOS
This commit is contained in:
parent
ae1d24ca80
commit
5aa6ec32b7
2 changed files with 33 additions and 14 deletions
|
@ -35,15 +35,19 @@ IslPropagationLossModel::~IslPropagationLossModel ()
|
|||
bool
|
||||
IslPropagationLossModel::GetLos (Ptr<MobilityModel> moda, Ptr<MobilityModel> modb)
|
||||
{
|
||||
// TODO get max distance with line-sphere intersection
|
||||
|
||||
// origin of LOS
|
||||
Vector3D oc = moda->GetPosition ();
|
||||
Vector3D bp = modb->GetPosition ();
|
||||
Vector3D apos = moda->GetPosition ();
|
||||
Vector3D bpos = modb->GetPosition ();
|
||||
|
||||
// select upper satellite as origin
|
||||
Vector oc = apos.GetLength () > bpos.GetLength () ? apos : bpos;
|
||||
Vector bp = apos.GetLength () > bpos.GetLength () ? bpos : apos;
|
||||
|
||||
Vector3D u = bp - oc;
|
||||
// distance from s1 to s2
|
||||
double s2 = u.GetLength ();
|
||||
// direction unit vector
|
||||
Vector3D u = Vector3D (bp.x - oc.x, bp.y - oc.y, bp.z - oc.z);
|
||||
u = Vector3D (u.x / u.GetLength (), u.y / u.GetLength (), u.z / u.GetLength ());
|
||||
u = Vector3D (u.x / s2, u.y / s2, u.z / s2);
|
||||
|
||||
double a = u.x*u.x + u.y*u.y + u.z*u.z;
|
||||
double b = 2.0 * (oc.x*u.x + oc.y*u.y + oc.z*u.z);
|
||||
|
@ -57,7 +61,23 @@ IslPropagationLossModel::GetLos (Ptr<MobilityModel> moda, Ptr<MobilityModel> mod
|
|||
<<";c="<<c
|
||||
<<";disc="<<discriminant);
|
||||
|
||||
return discriminant < 0;
|
||||
if (discriminant < 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// distances from oc (first sat)
|
||||
double t1 = (-b - sqrt (discriminant)) / (2.0 * a);
|
||||
double t2 = (-b + sqrt (discriminant)) / (2.0 * a);
|
||||
|
||||
NS_LOG_DEBUG ("t1="<<t1
|
||||
<<"t2="<<t2
|
||||
<<"s2="<<s2);
|
||||
|
||||
// check if second sat is behind earth
|
||||
return (s2 < abs (t1) && s2 < abs (t2));
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -65,14 +85,12 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
|||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << txPowerDbm << a << b);
|
||||
if (!GetLos (a, b))
|
||||
{
|
||||
NS_LOG_DEBUG ("DROP;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||
return -1000.0;
|
||||
}
|
||||
|
||||
NS_LOG_DEBUG ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||
|
||||
return txPowerDbm;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue