/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Tim Schubert */ #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="<