Files
unison/src/mobility/vector.cc
Mathieu Lacage 00bf89e1d2 a vector class
2007-11-08 10:24:33 +01:00

49 lines
1.2 KiB
C++

/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007 INRIA
*
* 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "vector.h"
#include <cmath>
namespace ns3 {
Vector::Vector (double _x, double _y, double _z)
: x (_x),
y (_y),
z (_z)
{}
Vector::Vector ()
: x (0.0),
y (0.0),
z (0.0)
{}
double
CalculateDistance (const Vector &a, const Vector &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;
}
} // namespace ns3