-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector4D.h
More file actions
135 lines (114 loc) · 3.46 KB
/
vector4D.h
File metadata and controls
135 lines (114 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2020 Universidade Federal de Minas Gerais
*
* 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: Igor Castejon F. e Castro <igorcastejon@dcc.ufmg.br>
*/
#ifndef NS3_VECTOR4D_H
#define NS3_VECTOR4D_H
#include "ns3/attribute.h"
#include "ns3/attribute-helper.h"
/**
* \file
* \ingroup geometry
* ns3::Vector4D declaration.
*/
namespace ns3 {
/**
* \ingroup core
* \defgroup geometry Geometry primitives
* \brief Primitives for geometry, such as vectors and angles.
*/
/**
* \ingroup geometry
* \brief a 4d vector
* \see attribute_Vector4D
*/
class Vector4D
{
public:
/**
* \param [in] _x X coordinate of vector
* \param [in] _y Y coordinate of vector
* \param [in] _z Z coordinate of vector
* \param [in] _w W coordinate of vector
*
* Create vector (_x, _y, _z, _w)
*/
Vector4D (double _x, double _y, double _z, double _w);
/** Create vector (0.0, 0.0, 0.0, 0.0) */
Vector4D ();
double x; //!< x coordinate of vector
double y; //!< y coordinate of vector
double z; //!< z coordinate of vector
double w; //!< w coordinate of vector
/**
* Compute the length (magnitude) of the vector.
* \returns the vector length.
*/
double GetLength () const;
/**
* \brief Calculate the Cartesian distance between two points.
* \param [in] a One point
* \param [in] b Another point
* \returns The distance between \p a and \p b.
*/
friend double CalculateDistance (const Vector4D &a, const Vector4D &b);
/**
* Output streamer.
* Vectors are written as "x:y:z:w".
*
* \param [in,out] os The stream.
* \param [in] vector The vector to stream
* \return The stream.
*/
friend std::ostream &operator << (std::ostream &os, const Vector4D &vector);
/**
* Input streamer.
*
* Vectors are expected to be in the form "x:y:z:w".
*
* \param [in,out] is The stream.
* \param [in] vector The vector.
* \returns The stream.
*/
friend std::istream &operator >> (std::istream &is, Vector4D &vector);
/**
* Less than comparison operator
* \param [in] a lhs vector
* \param [in] b rhs vector
* \returns \c true if \p a is less than \p b
*/
friend bool operator < (const Vector4D &a, const Vector4D &b);
friend bool operator == (const Vector4D &a, const Vector4D &b);
/**
* Addition operator.
* \param [in] a lhs vector.
* \param [in] b rhs vector.
* \returns The vector sum of \p a and \p b.
*/
friend Vector4D operator + (const Vector4D &a, const Vector4D &b);
/**
* Subtraction operator.
* \param [in] a lhs vector.
* \param [in] b rhs vector.
* \returns The vector difference of \p a and \p b.
*/
friend Vector4D operator - (const Vector4D &a, const Vector4D &b);
};
ATTRIBUTE_HELPER_HEADER (Vector4D);
} // namespace ns3
#endif /* NS3_VECTOR4D_H */