A Discrete-Event Network Simulator
API
vector.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef NS3_VECTOR_H
21 #define NS3_VECTOR_H
22 
23 #include "attribute.h"
24 #include "attribute-helper.h"
25 
32 namespace ns3 {
33 
45 class Vector3D
46 {
47 public:
55  Vector3D (double _x, double _y, double _z);
57  Vector3D ();
58 
59  double x;
60  double y;
61  double z;
62 
67  double GetLength () const;
68 
75  friend double CalculateDistance (const Vector3D &a, const Vector3D &b);
76 
85  friend std::ostream &operator << (std::ostream &os, const Vector3D &vector);
86 
96  friend std::istream &operator >> (std::istream &is, Vector3D &vector);
97 
104  friend bool operator < (const Vector3D &a, const Vector3D &b);
105 
112  friend Vector3D operator + (const Vector3D &a, const Vector3D &b);
113 
120  friend Vector3D operator - (const Vector3D &a, const Vector3D &b);
121 };
122 
128 class Vector2D
129 {
130 public:
137  Vector2D (double _x, double _y);
139  Vector2D ();
140  double x;
141  double y;
142 
143  // works: /** \copydoc ns3::Vector3D::GetLength() */
145  double GetLength () const;
146 
153  friend double CalculateDistance (const Vector2D &a, const Vector2D &b);
154 
163  friend std::ostream &operator << (std::ostream &os, const Vector2D &vector);
164 
174  friend std::istream &operator >> (std::istream &is, Vector2D &vector);
175 
182  friend bool operator < (const Vector2D &a, const Vector2D &b);
183 
190  friend Vector2D operator + (const Vector2D &a, const Vector2D &b);
191 
198  friend Vector2D operator - (const Vector2D &a, const Vector2D &b);
199 };
200 
201 double CalculateDistance (const Vector3D &a, const Vector3D &b);
202 double CalculateDistance (const Vector2D &a, const Vector2D &b);
203 std::ostream &operator << (std::ostream &os, const Vector3D &vector);
204 std::ostream &operator << (std::ostream &os, const Vector2D &vector);
205 std::istream &operator >> (std::istream &is, Vector3D &vector);
206 std::istream &operator >> (std::istream &is, Vector2D &vector);
207 bool operator < (const Vector3D &a, const Vector3D &b);
208 bool operator < (const Vector2D &a, const Vector2D &b);
209 
212 
217 typedef Vector3D Vector;
218 
224 
230 
231 
232 // Document these by hand so they go in group attribute_Vector3D
248 
255 
256 
257 } // namespace ns3
258 
259 #endif /* NS3_VECTOR_H */
friend bool operator<(const Vector2D &a, const Vector2D &b)
Less than comparison operator.
Definition: vector.cc:150
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
double x
x coordinate of vector
Definition: vector.h:59
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ptr< const AttributeChecker > MakeVectorChecker(void)
Definition: vector.cc:41
friend std::istream & operator>>(std::istream &is, Vector2D &vector)
Input streamer.
Definition: vector.cc:140
friend bool operator<(const Vector3D &a, const Vector3D &b)
Less than comparison operator.
Definition: vector.cc:120
friend Vector2D operator-(const Vector2D &a, const Vector2D &b)
Subtraction operator.
Definition: vector.cc:161
friend Vector3D operator-(const Vector3D &a, const Vector3D &b)
Subtraction operator.
Definition: vector.cc:131
a 3d vector
Definition: vector.h:45
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:153
double GetLength() const
Compute the length (magnitude) of the vector.
Definition: vector.cc:79
double x
x coordinate of vector
Definition: vector.h:140
Vector2D()
Constructor: (0.0, 0.0)
Definition: vector.cc:71
double y
y coordinate of vector
Definition: vector.h:141
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:92
Vector3D()
Create vector (0.0, 0.0, 0.0)
Definition: vector.cc:56
Vector3D Vector
Definition: vector.h:217
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Vector3DChecker VectorChecker
Definition: vector.h:229
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
a 2d vector
Definition: vector.h:128
friend Vector2D operator+(const Vector2D &a, const Vector2D &b)
Addition operator.
Definition: vector.cc:156
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double y
y coordinate of vector
Definition: vector.h:60
friend std::ostream & operator<<(std::ostream &os, const Vector2D &vector)
Output streamer.
Definition: vector.cc:135
Attribute helper (ATTRIBUTE_ )macros definition.
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
Vector3DValue VectorValue
Definition: vector.h:223
friend std::ostream & operator<<(std::ostream &os, const Vector3D &vector)
Output streamer.
Definition: vector.cc:104
friend std::istream & operator>>(std::istream &is, Vector3D &vector)
Input streamer.
Definition: vector.cc:109
friend Vector3D operator+(const Vector3D &a, const Vector3D &b)
Addition operator.
Definition: vector.cc:126
friend double CalculateDistance(const Vector3D &a, const Vector3D &b)
Calculate the Cartesian distance between two points.
Definition: vector.cc:92
AttributeValue implementation for Vector3D.
Definition: vector.h:210
AttributeChecker implementation for Vector3DValue.
Definition: vector.h:210
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type.
double GetLength() const
Compute the length (magnitude) of the vector.
Definition: vector.cc:85
friend double CalculateDistance(const Vector2D &a, const Vector2D &b)
Calculate the Cartesian distance between two points.
Definition: vector.cc:98
double z
z coordinate of vector
Definition: vector.h:61