计算汽车节点VEINS之间的距离 [英] Calculating distance between cars nodes VEINS

查看:54
本文介绍了计算汽车节点VEINS之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VEINS的新手,正在尝试在MyVeinsApp.cc中实现加权p持久性.该公式中使用了发送节点和接收节点之间的距离.我看到了下面的两个功能.

I am new to VEINS and trying to implement weighted p-persistence inside MyVeinsApp.cc. Distance between the sending node and receiving is used in that formula. I saw the 2 functions below.

virtual Coord& getSenderPos();
virtual const Coord& getSenderPos() const {return const_cast<WaveShortMessage*>(this)->getSenderPos();}

我应该使用其中一种方法来计算节点之间的距离吗?

Should I use one of those methods to calculate the distance between nodes?

请提供最佳方法的建议.

Please advise on the best approach.

推荐答案

对于距离,您显然需要两个位置.您可以通过从收到的消息中询问移动性模块和发件人的位置来获取当前节点的位置.然后,您可以从

For the distance you obviously need the two positions. You can get the position of the current node by asking the mobility module and the position of the sender from the message you received. Then you can use the following method from Coord to calculate the distance between two points:

/**
 * @brief Returns the distance to Coord 'a'.
 */
double distance(const Coord& a) const {
    Coord dist(*this - a);
    return dist.length();
}

这篇关于计算汽车节点VEINS之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆