/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "ns3/log.h" #include "ns3/mobility-model.h" #include "ns3/double.h" #include "math.h" #include "isl-propagation-loss-model.h" namespace ns3 { NS_LOG_COMPONENT_DEFINE ("IslPropagationLossModel"); NS_OBJECT_ENSURE_REGISTERED (IslPropagationLossModel); TypeId IslPropagationLossModel::GetTypeId (void) { static TypeId tid = TypeId ("ns3::IslPropagationLossModel") .SetParent () .SetGroupName ("Leo") .AddConstructor () ; return tid; } IslPropagationLossModel::IslPropagationLossModel () { } IslPropagationLossModel::~IslPropagationLossModel () { } bool IslPropagationLossModel::GetLos (Ptr moda, Ptr modb) { // origin of LOS 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 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); double c = (oc.x*oc.x + oc.y*oc.y + oc.z*oc.z) - (LEO_EARTH_RAD*LEO_EARTH_RAD); double discriminant = b*b - 4*a*c; NS_LOG_DEBUG ("a_pos="<GetPosition ()<<";b_pos"<GetPosition () <<";u="<