a vector class
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 08 Nov 2007 10:24:33 +0100
changeset 1815 be6c04bc96ef
parent 1814 21c9c4dd9768
child 1816 d7c9b9da78f4
a vector class
src/mobility/vector.cc
src/mobility/vector.h
src/mobility/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/vector.cc	Thu Nov 08 10:24:33 2007 +0100
@@ -0,0 +1,48 @@
+/* -*-  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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/vector.h	Thu Nov 08 10:24:33 2007 +0100
@@ -0,0 +1,63 @@
+/* -*-  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>
+ */
+#ifndef VECTOR_H
+#define VECTOR_H
+
+namespace ns3 {
+
+/**
+ * \brief a 3d cartesian position vector
+ *
+ * Unit is meters.
+ */
+class Vector
+{
+public:
+  /**
+   * \param _x x coordinate of vector vector
+   * \param _y y coordinate of vector vector
+   * \param _z z coordinate of vector vector
+   *
+   * Create vector vector (_x, _y, _z)
+   */
+  Vector (double _x, double _y, double _z);
+  /**
+   * Create vector vector (0.0, 0.0, 0.0)
+   */
+  Vector ();
+  /**
+   * x coordinate of vector vector
+   */
+  double x;
+  /**
+   * y coordinate of vector vector
+   */
+  double y;
+  /**
+   * z coordinate of vector vector
+   */
+  double z;
+};
+
+double CalculateDistance (const Vector &a, const Vector &b);
+
+} // namespace ns3
+
+#endif /* VECTOR_H */
--- a/src/mobility/wscript	Tue Nov 06 15:45:05 2007 -0800
+++ b/src/mobility/wscript	Thu Nov 08 10:24:33 2007 +0100
@@ -3,6 +3,7 @@
 def build(bld):
     mobility = bld.create_ns3_module('mobility', ['core', 'simulator'])
     mobility.source = [
+        'vector.cc',
         'grid-topology.cc',
         'hierarchical-mobility-model.cc',
         'mobility-model.cc',
@@ -24,6 +25,7 @@
 
     headers = bld.create_obj('ns3header')
     headers.source = [
+        'vector.h',
         'grid-topology.h',
         'hierarchical-mobility-model.h',
         'mobility-model.h',