📄 sdist.cc
字号:
#include <math.h>#include <packet.h>#include <packet-stamp.h>#include <sdist.h>static class SimpleDistanceClass: public TclClass {public: SimpleDistanceClass() : TclClass("Propagation/SimpleDistance") {} TclObject* create(int, const char*const*) { return (new SimpleDistance); }} class_simpledistance;SimpleDistance::SimpleDistance(){}doubleSimpleDistance::Pr(PacketStamp *t, PacketStamp *r, WirelessPhy *ifp){ double rX, rY, rZ; // loc of receiver double tX, tY, tZ; // loc of xmitter double d; // dist r->getNode()->getLoc(&rX, &rY, &rZ); t->getNode()->getLoc(&tX, &tY, &tZ); rX += r->getAntenna()->getX(); rY += r->getAntenna()->getY(); tX += t->getAntenna()->getX(); tY += t->getAntenna()->getY(); d = sqrt((rX - tX) * (rX - tX) + (rY - tY) * (rY - tY) + (rZ - tZ) * (rZ - tZ)); return (t->getTxPr() >= d) ? ifp->getRXThresh() * 2 : 0.0; // XXX *2 just to be on the safe side}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -