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
32namespace ns3 {
33
46{
47public:
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
73 double GetLengthSquared () const;
74
81 friend double CalculateDistance (const Vector3D &a, const Vector3D &b);
82
89 friend double CalculateDistanceSquared (const Vector3D &a, const Vector3D &b);
90
99 friend std::ostream &operator << (std::ostream &os, const Vector3D &vector);
100
110 friend std::istream &operator >> (std::istream &is, Vector3D &vector);
111
118 friend bool operator < (const Vector3D &a, const Vector3D &b);
119
126 friend bool operator <= (const Vector3D &a, const Vector3D &b);
127
134 friend bool operator > (const Vector3D &a, const Vector3D &b);
135
142 friend bool operator >= (const Vector3D &a, const Vector3D &b);
143
150 friend bool operator == (const Vector3D &a, const Vector3D &b);
151
158 friend bool operator != (const Vector3D &a, const Vector3D &b);
159
166 friend Vector3D operator + (const Vector3D &a, const Vector3D &b);
167
174 friend Vector3D operator - (const Vector3D &a, const Vector3D &b);
175};
176
183{
184public:
191 Vector2D (double _x, double _y);
193 Vector2D ();
194 double x;
195 double y;
196
197 // works: /** \copydoc ns3::Vector3D::GetLength() */
199 double GetLength () const;
200
202 double GetLengthSquared () const;
203
210 friend double CalculateDistance (const Vector2D &a, const Vector2D &b);
211
218 friend double CalculateDistanceSquared (const Vector2D &a, const Vector2D &b);
219
228 friend std::ostream &operator << (std::ostream &os, const Vector2D &vector);
229
239 friend std::istream &operator >> (std::istream &is, Vector2D &vector);
240
247 friend bool operator < (const Vector2D &a, const Vector2D &b);
248
255 friend bool operator <= (const Vector2D &a, const Vector2D &b);
256
263 friend bool operator > (const Vector2D &a, const Vector2D &b);
264
271 friend bool operator >= (const Vector2D &a, const Vector2D &b);
272
279 friend bool operator == (const Vector2D &a, const Vector2D &b);
280
287 friend bool operator != (const Vector2D &a, const Vector2D &b);
288
295 friend Vector2D operator + (const Vector2D &a, const Vector2D &b);
296
303 friend Vector2D operator - (const Vector2D &a, const Vector2D &b);
304};
305
306double CalculateDistance (const Vector3D &a, const Vector3D &b);
307double CalculateDistance (const Vector2D &a, const Vector2D &b);
308double CalculateDistanceSquared (const Vector3D &a, const Vector3D &b);
309double CalculateDistanceSquared (const Vector2D &a, const Vector2D &b);
310std::ostream &operator << (std::ostream &os, const Vector3D &vector);
311std::ostream &operator << (std::ostream &os, const Vector2D &vector);
312std::istream &operator >> (std::istream &is, Vector3D &vector);
313std::istream &operator >> (std::istream &is, Vector2D &vector);
314bool operator < (const Vector3D &a, const Vector3D &b);
315bool operator < (const Vector2D &a, const Vector2D &b);
316
319
325
331
337
338
339// Document these by hand so they go in group attribute_Vector3D
355
362
363
364} // namespace ns3
365
366#endif /* NS3_VECTOR_H */
Attribute helper (ATTRIBUTE_ )macros definition.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a 2d vector
Definition: vector.h:183
friend bool operator!=(const Vector2D &a, const Vector2D &b)
Inequality operator.
Definition: vector.cc:225
friend double CalculateDistanceSquared(const Vector2D &a, const Vector2D &b)
Calculate the squared Cartesian distance between two points.
Definition: vector.cc:124
friend std::istream & operator>>(std::istream &is, Vector2D &vector)
Input streamer.
Definition: vector.cc:190
double y
y coordinate of vector
Definition: vector.h:195
friend bool operator==(const Vector2D &a, const Vector2D &b)
Equality operator.
Definition: vector.cc:220
friend bool operator<=(const Vector2D &a, const Vector2D &b)
Less than or equal to comparison operator.
Definition: vector.cc:205
Vector2D()
Constructor: (0.0, 0.0)
Definition: vector.cc:71
friend bool operator<(const Vector2D &a, const Vector2D &b)
Less than comparison operator.
Definition: vector.cc:200
friend std::ostream & operator<<(std::ostream &os, const Vector2D &vector)
Output streamer.
Definition: vector.cc:185
double x
x coordinate of vector
Definition: vector.h:194
friend Vector2D operator+(const Vector2D &a, const Vector2D &b)
Addition operator.
Definition: vector.cc:230
friend bool operator>(const Vector2D &a, const Vector2D &b)
Greater than comparison operator.
Definition: vector.cc:210
friend bool operator>=(const Vector2D &a, const Vector2D &b)
Greater than or equal to comparison operator.
Definition: vector.cc:215
friend Vector2D operator-(const Vector2D &a, const Vector2D &b)
Subtraction operator.
Definition: vector.cc:235
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:111
double GetLengthSquared() const
Compute the squared length of the vector.
Definition: vector.cc:98
AttributeChecker implementation for Vector3DValue.
Definition: vector.h:317
a 3d vector
Definition: vector.h:46
double GetLength() const
Compute the length (magnitude) of the vector.
Definition: vector.cc:79
friend double CalculateDistance(const Vector3D &a, const Vector3D &b)
Calculate the Cartesian distance between two points.
Definition: vector.cc:105
friend std::ostream & operator<<(std::ostream &os, const Vector3D &vector)
Output streamer.
Definition: vector.cc:130
friend bool operator>=(const Vector3D &a, const Vector3D &b)
Greater than or equal to comparison operator.
Definition: vector.cc:161
friend bool operator!=(const Vector3D &a, const Vector3D &b)
Inequality operator.
Definition: vector.cc:171
Vector3DValue VectorValue
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:330
friend Vector3D operator+(const Vector3D &a, const Vector3D &b)
Addition operator.
Definition: vector.cc:176
double x
x coordinate of vector
Definition: vector.h:59
friend bool operator==(const Vector3D &a, const Vector3D &b)
Equality operator.
Definition: vector.cc:166
friend std::istream & operator>>(std::istream &is, Vector3D &vector)
Input streamer.
Definition: vector.cc:135
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
friend Vector3D operator-(const Vector3D &a, const Vector3D &b)
Subtraction operator.
Definition: vector.cc:181
friend bool operator>(const Vector3D &a, const Vector3D &b)
Greater than comparison operator.
Definition: vector.cc:156
Vector3DChecker VectorChecker
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:336
Vector3D()
Create vector (0.0, 0.0, 0.0)
Definition: vector.cc:56
double z
z coordinate of vector
Definition: vector.h:61
friend bool operator<=(const Vector3D &a, const Vector3D &b)
Less than or equal to comparison operator.
Definition: vector.cc:151
double y
y coordinate of vector
Definition: vector.h:60
double GetLengthSquared() const
Compute the squared length of the vector.
Definition: vector.cc:92
friend bool operator<(const Vector3D &a, const Vector3D &b)
Less than comparison operator.
Definition: vector.cc:146
friend double CalculateDistanceSquared(const Vector3D &a, const Vector3D &b)
Calculate the squared Cartesian distance between two points.
Definition: vector.cc:118
AttributeValue implementation for Vector3D.
Definition: vector.h:317
Ptr< const AttributeChecker > MakeVectorChecker(void)
Definition: vector.cc:41
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ATTRIBUTE_HELPER_HEADER(ValueClassTest)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:162
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:176
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:105
double CalculateDistanceSquared(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:118