Use Vector{2,3}D.GetLength ()
This commit is contained in:
@@ -73,7 +73,7 @@ Angles::Angles (double p, double t)
|
||||
|
||||
Angles::Angles (Vector v)
|
||||
: phi (std::atan2 (v.y, v.x)),
|
||||
theta (std::acos (v.z / sqrt (v.x*v.x + v.y*v.y + v.z*v.z)))
|
||||
theta (std::acos (v.z / v.GetLength ()))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -92,20 +92,13 @@ double
|
||||
CalculateDistance (const Vector3D &a, const Vector3D &b)
|
||||
{
|
||||
NS_LOG_FUNCTION (a << b);
|
||||
double dx = b.x - a.x;
|
||||
double dy = b.y - a.y;
|
||||
double dz = b.z - a.z;
|
||||
double distance = std::sqrt (dx * dx + dy * dy + dz * dz);
|
||||
return distance;
|
||||
return (b - a).GetLength ();
|
||||
}
|
||||
double
|
||||
CalculateDistance (const Vector2D &a, const Vector2D &b)
|
||||
{
|
||||
NS_LOG_FUNCTION (a << b);
|
||||
double dx = b.x - a.x;
|
||||
double dy = b.y - a.y;
|
||||
double distance = std::sqrt (dx * dx + dy * dy);
|
||||
return distance;
|
||||
return (b - a).GetLength ();
|
||||
}
|
||||
|
||||
std::ostream &operator << (std::ostream &os, const Vector3D &vector)
|
||||
|
||||
@@ -88,10 +88,7 @@ MobilityModel::GetDistanceFrom (Ptr<const MobilityModel> other) const
|
||||
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) );
|
||||
return (GetVelocity () - other->GetVelocity ()).GetLength ();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user