Added MobilityModel::GetRelativeSpeed() - proposed by Jens Mittag.
--- a/CHANGES.html Sun Nov 06 17:46:16 2011 +0100
+++ b/CHANGES.html Thu Nov 17 19:02:45 2011 +0100
@@ -76,6 +76,7 @@
<h2>New API:</h2>
<ul>
+<li> In the mobility module, there is a new API MobilityModel::GetRelativeSpeed() returning the relative speed of two objects. Proposed by Jens Mittag.</li>
</ul>
<h2>Changes to existing API:</h2>
--- a/src/mobility/model/mobility-model.cc Sun Nov 06 17:46:16 2011 +0100
+++ b/src/mobility/model/mobility-model.cc Thu Nov 17 19:02:45 2011 +0100
@@ -83,6 +83,15 @@
return CalculateDistance (position, oPosition);
}
+double
+MobilityModel::GetRelativeSpeed (Ptr<const MobilityModel> other) const
+{
+ double x = GetVelocity().x - other->GetVelocity().x;
+ double y = GetVelocity().y - other->GetVelocity().y;
+ double z = GetVelocity().z - other->GetVelocity().z;
+ return sqrt( (x*x) + (y*y) + (z*z) );
+}
+
void
MobilityModel::NotifyCourseChange (void) const
{
--- a/src/mobility/model/mobility-model.h Sun Nov 06 17:46:16 2011 +0100
+++ b/src/mobility/model/mobility-model.h Thu Nov 17 19:02:45 2011 +0100
@@ -60,6 +60,12 @@
* \return the distance between the two objects. Unit is meters.
*/
double GetDistanceFrom (Ptr<const MobilityModel> position) const;
+ /**
+ * \param other reference to another object's mobility model
+ * \return the relative speed between the two objects. Unit is meters/s.
+ */
+ double GetRelativeSpeed (Ptr<const MobilityModel> other) const;
+
protected:
/**
* Must be invoked by subclasses when the course of the