scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
vector_unit_2d.hpp File Reference
#include "./scalar_unit.hpp"
#include "../meca_number/angle.hpp"
#include "../util/is_number.hpp"
#include "../coordinates/direction.hpp"
#include "boost/algorithm/string.hpp"
#include <iostream>
#include <string>
Include dependency graph for vector_unit_2d.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  scifir::vector_unit_2d
 Class that creates a vector unit in 2D. The vector is in polar coordinates with a value and dimensions of the scalar_unit, and an angle theta for his direction. All base and derived vectorial unit classes in 2D inherit from vector_unit_2d, and add the suffix **_2d** in their name. Initialization string example: "1 N 20θ". 'θ' is the Unicode Character U+03B8. More...
 

Namespaces

namespace  scifir
 The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
 

Macros

#define VECTOR_UNIT_2D_HPP_BEGIN(name)
 
#define VECTOR_UNIT_2D_HPP_END()
 
#define VECTOR_UNIT_2D_HPP(name)
 
#define VECTOR_UNIT_2D_CPP(name, init_real_dimensions)
 

Functions

string scifir::to_string (const vector_unit_2d &x)
 It generates a string representation of vector_unit_2d.
 
scalar_unit scifir::norm (const vector_unit_2d &x)
 It returns the value of the vector in polar coordinates, p.
 
vector_unit_2d scifir::sqrt (const vector_unit_2d &x)
 It squares the vector, creating a vector_unit_2d with the value squared and always the same theta. The dimensions are squared with the same rules for the square of dimensions than scalar_unit classes.
 
vector_unit_2d scifir::sqrt_nth (const vector_unit_2d &x, int index)
 It takes the root of the vector with the index given, creating a vector_unit_2d with the value rooted to that index and always maintains the same theta. The dimensions are squared with the same rules for the square of dimensions than scalar_unit classes.
 
scalar_unit scifir::dot_product (const vector_unit_2d &x, const vector_unit_2d &y)
 Creates a scalar_unit as the dot product of the two vectors x and y.
 
angle scifir::angle_between (const vector_unit_2d &x, const vector_unit_2d &y)
 Returns the angle between two vectors x and y inside a 2D space.
 
bool scifir::same_direction (const vector_unit_2d &x, const vector_unit_2d &y)
 Checks if two vectors x and y have the same direction.
 
bool scifir::parallel (const vector_unit_2d &x, const vector_unit_2d &y)
 Checks if two vectors x and y are parallel, which means that their direction is the same or the exact opposite.
 
bool scifir::orthogonal (const vector_unit_2d &x, const vector_unit_2d &y)
 Checks if two vectors x and y are orthogonal, that's, if they have 90 degrees of difference.
 
scifir::vector_unit_2d operator* (const scifir::scalar_unit &x, const scifir::vector_unit_2d &y)
 It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator+ (const T y, const scifir::vector_unit_2d &x)
 It creates a new vector as the addition of the numeric type x to the value. Theta is not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator- (const T y, const scifir::vector_unit_2d &x)
 Substraction of vectors in 2D. It creates a new vector as the difference of the other two.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator* (const T y, const scifir::vector_unit_2d &x)
 It creates a new vector as the multiplication of the numeric type x to the value. Theta is not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator/ (const T y, const scifir::vector_unit_2d &x)
 It creates a new vector as the division of the value x to the numeric type. Theta is not changed.
 
bool operator!= (const scifir::vector_unit_2d &x, const scifir::vector_unit_2d &y)
 Comparison operator. Two vector_unit_2d are not equal if their value, dimensions or theta are different.
 
bool operator== (const scifir::vector_unit_2d &x, const string &init_vector_2d)
 Returns true if x is equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
 
bool operator!= (const scifir::vector_unit_2d &x, const string &init_vector_2d)
 Returns true if x is not equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
 
bool operator== (const string &init_vector_2d, const scifir::vector_unit_2d &x)
 Returns true if x is equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
 
bool operator!= (const string &init_vector_2d, const scifir::vector_unit_2d &x)
 Returns true if x is not equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.
 
void operator+= (string &x, const scifir::vector_unit_2d &y)
 Concatenates the string representation of the vector_unit_2d y to the string x.
 
string operator+ (const string &x, const scifir::vector_unit_2d &y)
 Creates a new string as the concatenation of the string x with the representation string of the vector_unit_2d y.
 
string operator+ (const scifir::vector_unit_2d &y, const string &x)
 Creates a new string as the concatenation of the string x with the representation string of the vector_unit_2d y.
 
ostream & operator<< (ostream &os, const scifir::vector_unit_2d &x)
 Adds the string representation of the vector_unit_2d x to an output stream os.
 
istream & operator>> (istream &is, scifir::vector_unit_2d &x)
 Allows that an istream initializes by string a vector_unit_2d x.
 

Macro Definition Documentation

◆ VECTOR_UNIT_2D_CPP

#define VECTOR_UNIT_2D_CPP (   name,
  init_real_dimensions 
)

Definition at line 109 of file vector_unit_2d.hpp.

109 : vector_unit_2d() {} \
110 name##_2d::name##_2d(const name##_2d& x) : vector_unit_2d(x) {} \
111 name##_2d::name##_2d(name##_2d&& x) : vector_unit_2d(std::move(x)) {} \
112 name##_2d::name##_2d(float new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
113 { \
114 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
115 } \
116\
117 name##_2d::name##_2d(float new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
118 { \
119 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
120 } \
121\
122 name##_2d::name##_2d(double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
123 { \
124 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
125 } \
126\
127 name##_2d::name##_2d(double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
128 { \
129 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
130 } \
131\
132 name##_2d::name##_2d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
133 { \
134 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
135 } \
136\
137 name##_2d::name##_2d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
138 { \
139 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
140 } \
141\
142 name##_2d::name##_2d(int new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
143 { \
144 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
145 } \
146\
147 name##_2d::name##_2d(int new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position) : vector_unit_2d(new_value,new_dimension,new_prefix,new_theta,new_position) \
148 { \
149 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
150 } \
151\
152 name##_2d::name##_2d(float new_value,const string& init_dimensions,float new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
153 { \
154 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
155 } \
156\
157 name##_2d::name##_2d(float new_value,const string& init_dimensions,const angle& new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
158 { \
159 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
160 } \
161\
162 name##_2d::name##_2d(double new_value,const string& init_dimensions,float new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
163 { \
164 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
165 } \
166\
167 name##_2d::name##_2d(double new_value,const string& init_dimensions,const angle& new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
168 { \
169 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
170 } \
171\
172 name##_2d::name##_2d(long double new_value,const string& init_dimensions,float new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
173 { \
174 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
175 } \
176\
177 name##_2d::name##_2d(long double new_value,const string& init_dimensions,const angle& new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
178 { \
179 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
180 } \
181\
182 name##_2d::name##_2d(int new_value,const string& init_dimensions,float new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
183 { \
184 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
185 } \
186\
187 name##_2d::name##_2d(int new_value,const string& init_dimensions,const angle& new_theta) : vector_unit_2d(new_value,init_dimensions,new_theta) \
188 { \
189 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
190 } \
191\
192 name##_2d::name##_2d(float new_value,const vector<dimension>& new_dimensions,float new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
193 { \
194 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
195 } \
196\
197 name##_2d::name##_2d(float new_value,const vector<dimension>& new_dimensions,const angle& new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
198 { \
199 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
200 } \
201\
202 name##_2d::name##_2d(double new_value,const vector<dimension>& new_dimensions,float new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
203 { \
204 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
205 } \
206\
207 name##_2d::name##_2d(double new_value,const vector<dimension>& new_dimensions,const angle& new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
208 { \
209 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
210 } \
211\
212 name##_2d::name##_2d(long double new_value,const vector<dimension>& new_dimensions,float new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
213 { \
214 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
215 } \
216\
217 name##_2d::name##_2d(long double new_value,const vector<dimension>& new_dimensions,const angle& new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
218 { \
219 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
220 } \
221\
222 name##_2d::name##_2d(int new_value,const vector<dimension>& new_dimensions,float new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
223 { \
224 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
225 } \
226\
227 name##_2d::name##_2d(int new_value,const vector<dimension>& new_dimensions,const angle& new_theta) : vector_unit_2d(new_value,new_dimensions,new_theta) \
228 { \
229 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
230 } \
231\
232 name##_2d::name##_2d(const scalar_unit& x,float new_theta) : vector_unit_2d(x,new_theta) \
233 { \
234 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
235 } \
236\
237 name##_2d::name##_2d(const scalar_unit& x,const angle& new_theta) : vector_unit_2d(x,new_theta) \
238 { \
239 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
240 } \
241\
242 name##_2d::name##_2d(const string& init_scalar,float new_theta) : vector_unit_2d(init_scalar,new_theta) \
243 { \
244 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
245 } \
246\
247 name##_2d::name##_2d(const string& init_scalar,const angle& new_theta) : vector_unit_2d(init_scalar,new_theta) \
248 { \
249 scalar_unit::check_dimensions(name##_2d::real_dimensions); \
250 } \
251\
252 name##_2d::name##_2d(const string& init_vector_2d) : vector_unit_2d() \
253 { \
254 vector_unit_2d::initialize_from_string(init_vector_2d); \
255 } \
256\
257 name##_2d::name##_2d(const vector_unit_2d& x) : vector_unit_2d() \
258 { \
259 if (x.has_dimensions(name##_2d::real_dimensions)) \
260 { \
261 value = x.get_value(); \
262 dimensions = x.get_dimensions(); \
263 theta = x.theta; \
264 } \
265 } \
266\
267 name##_2d::name##_2d(vector_unit_2d&& x) : vector_unit_2d() \
268 { \
269 if (x.has_dimensions(name##_2d::real_dimensions)) \
270 { \
271 value = std::move(x.get_value()); \
272 dimensions = std::move(x.get_dimensions()); \
273 theta = std::move(x.theta); \
274 } \
275 } \
276\
277 name##_2d& name##_2d::operator =(const name##_2d& x) \
278 { \
279 vector_unit_2d::operator =(x); \
280 return *this; \
281 } \
282\
283 name##_2d& name##_2d::operator =(name##_2d&& x) \
284 { \
285 vector_unit_2d::operator =(std::move(x)); \
286 return *this; \
287 } \
288const string name##_2d::dimensions_match = init_real_dimensions; \
289const vector<dimension> name##_2d::real_dimensions = create_base_dimensions(init_real_dimensions)
vector< dimension > create_base_dimensions(const string &init_dimensions)
Creates the base dimensions from an initialization string of dimensions.

◆ VECTOR_UNIT_2D_HPP

#define VECTOR_UNIT_2D_HPP (   name)

Definition at line 62 of file vector_unit_2d.hpp.

62 : public vector_unit_2d \
63 { \
64 public: \
65 name##_2d(); \
66 name##_2d(const name##_2d&); \
67 name##_2d(name##_2d&&); \
68 explicit name##_2d(float new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta,dimension::position new_position = dimension::NUMERATOR); \
69 explicit name##_2d(float new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
70 explicit name##_2d(double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position = dimension::NUMERATOR); \
71 explicit name##_2d(double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
72 explicit name##_2d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position = dimension::NUMERATOR); \
73 explicit name##_2d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
74 explicit name##_2d(int new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position = dimension::NUMERATOR); \
75 explicit name##_2d(int new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
76 explicit name##_2d(float new_value,const string& init_dimensions,float new_theta); \
77 explicit name##_2d(float new_value,const string& init_dimensions,const angle& new_theta); \
78 explicit name##_2d(double new_value,const string& init_dimensions,float new_theta); \
79 explicit name##_2d(double new_value,const string& init_dimensions,const angle& new_theta); \
80 explicit name##_2d(long double new_value,const string& init_dimensions,float new_theta); \
81 explicit name##_2d(long double new_value,const string& init_dimensions,const angle& new_theta); \
82 explicit name##_2d(int new_value,const string& init_dimensions,float new_theta); \
83 explicit name##_2d(int new_value,const string& init_dimensions,const angle& new_theta); \
84 explicit name##_2d(float new_value,const vector<dimension>& new_dimensions,float new_theta); \
85 explicit name##_2d(float new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
86 explicit name##_2d(double new_value,const vector<dimension>& new_dimensions,float new_theta); \
87 explicit name##_2d(double new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
88 explicit name##_2d(long double new_value,const vector<dimension>& new_dimensions,float new_theta); \
89 explicit name##_2d(long double new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
90 explicit name##_2d(int new_value,const vector<dimension>& new_dimensions,float new_theta); \
91 explicit name##_2d(int new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
92 explicit name##_2d(const scalar_unit& x,float new_theta); \
93 explicit name##_2d(const scalar_unit& x,const angle& new_theta); \
94 explicit name##_2d(const string& init_scalar,float new_theta); \
95 explicit name##_2d(const string& init_scalar,const angle& new_theta); \
96 explicit name##_2d(const string& init_vector_2d); \
97 explicit name##_2d(const vector_unit_2d& x); \
98 explicit name##_2d(vector_unit_2d&& x); \
99 name##_2d& operator =(const name##_2d& x); \
100 name##_2d& operator =(name##_2d&& x); \
101 using vector_unit_2d::operator =; \
102 using vector_unit_2d::operator+=; \
103 using vector_unit_2d::operator-=; \
104\
105 static const string dimensions_match; \
106 static const vector<dimension> real_dimensions; \
107 }

◆ VECTOR_UNIT_2D_HPP_BEGIN

#define VECTOR_UNIT_2D_HPP_BEGIN (   name)

Definition at line 14 of file vector_unit_2d.hpp.

14 : public vector_unit_2d \
15 { \
16 public: \
17 name##_2d(); \
18 name##_2d(const name##_2d&); \
19 name##_2d(name##_2d&&); \
20 explicit name##_2d(float new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta,dimension::position new_position = dimension::NUMERATOR); \
21 explicit name##_2d(float new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
22 explicit name##_2d(double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position = dimension::NUMERATOR); \
23 explicit name##_2d(double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
24 explicit name##_2d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position = dimension::NUMERATOR); \
25 explicit name##_2d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
26 explicit name##_2d(int new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, dimension::position new_position = dimension::NUMERATOR); \
27 explicit name##_2d(int new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, dimension::position new_position = dimension::NUMERATOR); \
28 explicit name##_2d(float new_value,const string& init_dimensions,float new_theta); \
29 explicit name##_2d(float new_value,const string& init_dimensions,const angle& new_theta); \
30 explicit name##_2d(double new_value,const string& init_dimensions,float new_theta); \
31 explicit name##_2d(double new_value,const string& init_dimensions,const angle& new_theta); \
32 explicit name##_2d(long double new_value,const string& init_dimensions,float new_theta); \
33 explicit name##_2d(long double new_value,const string& init_dimensions,const angle& new_theta); \
34 explicit name##_2d(int new_value,const string& init_dimensions,float new_theta); \
35 explicit name##_2d(int new_value,const string& init_dimensions,const angle& new_theta); \
36 explicit name##_2d(float new_value,const vector<dimension>& new_dimensions,float new_theta); \
37 explicit name##_2d(float new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
38 explicit name##_2d(double new_value,const vector<dimension>& new_dimensions,float new_theta); \
39 explicit name##_2d(double new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
40 explicit name##_2d(long double new_value,const vector<dimension>& new_dimensions,float new_theta); \
41 explicit name##_2d(long double new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
42 explicit name##_2d(int new_value,const vector<dimension>& new_dimensions,float new_theta); \
43 explicit name##_2d(int new_value,const vector<dimension>& new_dimensions,const angle& new_theta); \
44 explicit name##_2d(const scalar_unit& x,float new_theta); \
45 explicit name##_2d(const scalar_unit& x,const angle& new_theta); \
46 explicit name##_2d(const string& init_scalar,float new_theta); \
47 explicit name##_2d(const string& init_scalar,const angle& new_theta); \
48 explicit name##_2d(const string& init_vector_2d); \
49 explicit name##_2d(const vector_unit_2d& x); \
50 explicit name##_2d(vector_unit_2d&& x); \
51 name##_2d& operator =(const name##_2d& x); \
52 name##_2d& operator =(name##_2d&& x); \
53 using vector_unit_2d::operator =; \
54 using vector_unit_2d::operator+=; \
55 using vector_unit_2d::operator-=

◆ VECTOR_UNIT_2D_HPP_END

#define VECTOR_UNIT_2D_HPP_END ( )
Value:
public: \
static const string dimensions_match; \
static const vector<dimension> real_dimensions; \
}

Definition at line 57 of file vector_unit_2d.hpp.

57 : \
58 static const string dimensions_match; \
59 static const vector<dimension> real_dimensions; \
60 }

Function Documentation

◆ operator!=() [1/3]

bool operator!= ( const scifir::vector_unit_2d x,
const scifir::vector_unit_2d y 
)

Comparison operator. Two vector_unit_2d are not equal if their value, dimensions or theta are different.

Definition at line 397 of file vector_unit_2d.cpp.

398{
399 return !(x == y);
400}

◆ operator!=() [2/3]

bool operator!= ( const scifir::vector_unit_2d x,
const string &  init_vector_2d 
)

Returns true if x is not equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.

Definition at line 408 of file vector_unit_2d.cpp.

409{
410 return !(x == init_vector_2d);
411}

◆ operator!=() [3/3]

bool operator!= ( const string &  init_vector_2d,
const scifir::vector_unit_2d x 
)

Returns true if x is not equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.

Definition at line 419 of file vector_unit_2d.cpp.

420{
421 return !(init_vector_2d == x);
422}

◆ operator*() [1/2]

scifir::vector_unit_2d operator* ( const scifir::scalar_unit x,
const scifir::vector_unit_2d y 
)

It creates a new vector_unit_3d scaling a vector_unit_3d by the scalar_unit x.

Definition at line 390 of file vector_unit_2d.cpp.

391{
392 long double new_value = x.get_value() * y.get_value();
393 vector<scifir::dimension> new_dimensions = multiply_dimensions(x.get_dimensions(), y.get_dimensions(),new_value);
394 return scifir::vector_unit_2d(float(new_value), new_dimensions, y.theta);
395}
const vector< dimension > & get_dimensions() const
Read-only getter of the dimensions.
const float & get_value() const
Read-only getter of the value.
Class that creates a vector unit in 2D. The vector is in polar coordinates with a value and dimension...
angle theta
Angle of the vector in 2D space, in polar coordinates. As all angles of scifir-units,...
vector< dimension > multiply_dimensions(const vector< dimension > &x, const vector< dimension > &y)
Multiplies two vectors of dimensions. The result is normalized after, which means that equal dimensio...

◆ operator*() [2/2]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator* ( const T  y,
const scifir::vector_unit_2d x 
)

It creates a new vector as the multiplication of the numeric type x to the value. Theta is not changed.

Definition at line 481 of file vector_unit_2d.hpp.

482{
484 z *= y;
485 return z;
486}

◆ operator+() [1/3]

string operator+ ( const scifir::vector_unit_2d y,
const string &  x 
)

Creates a new string as the concatenation of the string x with the representation string of the vector_unit_2d y.

Definition at line 439 of file vector_unit_2d.cpp.

440{
441 ostringstream output;
442 output << y;
443 output << x;
444 return output.str();
445}

◆ operator+() [2/3]

string operator+ ( const string &  x,
const scifir::vector_unit_2d y 
)

Creates a new string as the concatenation of the string x with the representation string of the vector_unit_2d y.

Definition at line 431 of file vector_unit_2d.cpp.

432{
433 ostringstream output;
434 output << x;
435 output << y;
436 return output.str();
437}

◆ operator+() [3/3]

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator+ ( const T  y,
const scifir::vector_unit_2d x 
)

It creates a new vector as the addition of the numeric type x to the value. Theta is not changed.

Definition at line 467 of file vector_unit_2d.hpp.

468{
470 z += y;
471 return z;
472}

◆ operator+=()

void operator+= ( string &  x,
const scifir::vector_unit_2d y 
)

Concatenates the string representation of the vector_unit_2d y to the string x.

Definition at line 424 of file vector_unit_2d.cpp.

425{
426 ostringstream output;
427 output << y;
428 x += output.str();
429}

◆ operator-()

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator- ( const T  y,
const scifir::vector_unit_2d x 
)

Substraction of vectors in 2D. It creates a new vector as the difference of the other two.

Definition at line 475 of file vector_unit_2d.hpp.

476{
478}

◆ operator/()

template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_2d operator/ ( const T  y,
const scifir::vector_unit_2d x 
)

It creates a new vector as the division of the value x to the numeric type. Theta is not changed.

Definition at line 489 of file vector_unit_2d.hpp.

490{
491 vector<scifir::dimension> new_dimensions = x.get_dimensions();
492 for (scifir::dimension& new_dimension : new_dimensions)
493 {
494 new_dimension.invert();
495 }
496 return scifir::vector_unit_2d(y / x.get_value(),new_dimensions,x.theta);
497}
Class that represents dimensions of the SI system of units. Each dimension sizes 6 bytes,...
Definition dimension.hpp:31

◆ operator<<()

ostream & operator<< ( ostream &  os,
const scifir::vector_unit_2d x 
)

Adds the string representation of the vector_unit_2d x to an output stream os.

Definition at line 447 of file vector_unit_2d.cpp.

448{
449 return os << to_string(x);
450}
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
Definition aid.cpp:582

◆ operator==() [1/2]

bool operator== ( const scifir::vector_unit_2d x,
const string &  init_vector_2d 
)

Returns true if x is equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.

Definition at line 402 of file vector_unit_2d.cpp.

403{
404 scifir::vector_unit_2d y(init_vector_2d);
405 return (x == y);
406}

◆ operator==() [2/2]

bool operator== ( const string &  init_vector_2d,
const scifir::vector_unit_2d x 
)

Returns true if x is equal to the vector_unit_2d initialized with the string being compared. The vectorial_display() function is not used, and so the values are compared with all its decimal numbers.

Definition at line 413 of file vector_unit_2d.cpp.

414{
415 scifir::vector_unit_2d y(init_vector_2d);
416 return (y == x);
417}

◆ operator>>()

istream & operator>> ( istream &  is,
scifir::vector_unit_2d x 
)

Allows that an istream initializes by string a vector_unit_2d x.

Definition at line 452 of file vector_unit_2d.cpp.

453{
454 char a[256];
455 is.getline(a, 256);
456 string b(a);
457 boost::trim(b);
459 return is;
460}