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_3d.hpp File Reference
#include "./scalar_unit.hpp"
#include "./vector_unit_2d.hpp"
#include "./vector_unit_nd.hpp"
#include "../meca_number/angle.hpp"
#include "../util/is_number.hpp"
#include "../coordinates/direction.hpp"
#include "boost/algorithm/string.hpp"
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
Include dependency graph for vector_unit_3d.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_3d
 Class that creates a vector unit in 3D. The vector is in spherical coordinates with a value and dimensions of the scalar_unit, and an angle theta and another angle phi for his direction. All base and derived vectorial unit classes in 3D inherit from vector_unit_3d, and add the suffix **_3d** in their name. Initialization string example: "1 N 20θ 30Φ". 'θ' is the Unicode Character U+03B8. 'Φ' is the Unicode Character U+03A6. More...
 

Namespaces

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

Macros

#define VECTOR_UNIT_3D_HPP_BEGIN(name)
 
#define VECTOR_UNIT_3D_HPP_END()
 
#define VECTOR_UNIT_3D_HPP(name)
 
#define VECTOR_UNIT_3D_CPP(name, init_real_dimensions)
 
#define VECTOR_UNIT_HPP(name)
 
#define VECTOR_UNIT_CPP(name, init_real_dimensions)
 

Functions

string scifir::to_string (const vector_unit_3d &x)
 It generates a string representation of vector_unit_3d.
 
scalar_unit scifir::norm (const vector_unit_3d &x)
 It returns the value of the vector in spherical coordinates, r.
 
vector_unit_3d scifir::sqrt (const vector_unit_3d &x)
 It squares the vector, creating a vector_unit_3d with the value squared and always the same theta and the same phi. The dimensions are squared with the same rules for the square of dimensions than scalar_unit classes.
 
vector_unit_3d scifir::sqrt_nth (const vector_unit_3d &x, int index)
 It takes the root of the vector with the index given, creating a vector_unit_3d with the value rooted to that index and always maintains the same theta and the same phi. 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_3d &x, const vector_unit_3d &y)
 Creates a scalar_unit as the dot product of the two vectors x and y.
 
vector_unit_3d scifir::cross_product (const vector_unit_3d &x, const vector_unit_3d &y)
 Creates a vector_unit_3d as the cross product of the two vectors x and y.
 
angle scifir::angle_between (const vector_unit_3d &x, const vector_unit_3d &y)
 Returns the angle between two vectors x and y inside a 3D space.
 
bool scifir::same_direction (const vector_unit_3d &x, const vector_unit_3d &y)
 Checks if two vectors x and y have the same direction.
 
bool scifir::parallel (const vector_unit_3d &x, const vector_unit_3d &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_3d &x, const vector_unit_3d &y)
 Checks if two vectors x and y are orthogonal, that's, if they have 90 degrees between them.
 
scifir::vector_unit_3d operator* (const scifir::scalar_unit &x, const scifir::vector_unit_3d &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_3d operator+ (const T y, const scifir::vector_unit_3d &x)
 It creates a new vector as the addition of the numeric type x to the value. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_3d operator- (const T y, const scifir::vector_unit_3d &x)
 It creates a new vector as the substraction of the numeric type x with the value. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_3d operator* (const T y, const scifir::vector_unit_3d &x)
 It creates a new vector as the multiplication of the numeric type x to the value. Theta and phi are not changed.
 
template<typename T , typename = typename enable_if<scifir::is_number<T>::value>::type>
scifir::vector_unit_3d operator/ (const T y, const scifir::vector_unit_3d &x)
 It creates a new vector as the division of the numeric type x with the value. Theta and phi are not changed.
 
bool operator!= (const scifir::vector_unit_3d &x, const scifir::vector_unit_3d &y)
 Comparison operator. Two vector_unit_3d are not equal if their value, dimensions, theta or phi are different.
 
bool operator== (const scifir::vector_unit_3d &x, const string &init_vector_3d)
 Returns true if x is equal to the vector_unit_3d 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_3d &x, const string &init_vector_3d)
 Returns true if x is not equal to the vector_unit_3d 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_3d, const scifir::vector_unit_3d &x)
 Returns true if x is equal to the vector_unit_3d 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_3d, const scifir::vector_unit_3d &x)
 Returns true if x is not equal to the vector_unit_3d 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_3d &y)
 Concatenates the string representation of the vector_unit_3d y to the string x.
 
string operator+ (const string &x, const scifir::vector_unit_3d &y)
 Creates a new string as the concatenation of the string x with the representation string of the vector_unit_3d y.
 
string operator+ (const scifir::vector_unit_3d &y, const string &x)
 Creates a new string as the concatenation of the string x with the representation string of the vector_unit_3d y.
 
ostream & operator<< (ostream &os, const scifir::vector_unit_3d &x)
 Adds the string representation of the vector_unit_3d x to an output stream os.
 
istream & operator>> (istream &is, scifir::vector_unit_3d &x)
 Allows that an istream initializes by string a vector_unit_3d x.
 

Macro Definition Documentation

◆ VECTOR_UNIT_3D_CPP

#define VECTOR_UNIT_3D_CPP (   name,
  init_real_dimensions 
)

Definition at line 116 of file vector_unit_3d.hpp.

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

#define VECTOR_UNIT_3D_HPP (   name)

Definition at line 69 of file vector_unit_3d.hpp.

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

◆ VECTOR_UNIT_3D_HPP_BEGIN

#define VECTOR_UNIT_3D_HPP_BEGIN (   name)

Definition at line 21 of file vector_unit_3d.hpp.

21 : public vector_unit_3d \
22 { \
23 public: \
24 name##_3d(); \
25 name##_3d(const name##_3d&); \
26 name##_3d(name##_3d&&); \
27 explicit name##_3d(float new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi,dimension::position new_position = dimension::NUMERATOR); \
28 explicit name##_3d(float new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, const angle& new_phi, dimension::position new_position = dimension::NUMERATOR); \
29 explicit name##_3d(double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position = dimension::NUMERATOR); \
30 explicit name##_3d(double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, const angle& new_phi, dimension::position new_position = dimension::NUMERATOR); \
31 explicit name##_3d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position = dimension::NUMERATOR); \
32 explicit name##_3d(long double new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, const angle& new_phi, dimension::position new_position = dimension::NUMERATOR); \
33 explicit name##_3d(int new_value, dimension::type new_dimension, prefix::type new_prefix, float new_theta, float new_phi, dimension::position new_position = dimension::NUMERATOR); \
34 explicit name##_3d(int new_value, dimension::type new_dimension, prefix::type new_prefix, const angle& new_theta, const angle& new_phi, dimension::position new_position = dimension::NUMERATOR); \
35 explicit name##_3d(float new_value,const string& init_dimensions,float new_theta,float new_phi); \
36 explicit name##_3d(float new_value,const string& init_dimensions,const angle& new_theta,const angle& new_phi); \
37 explicit name##_3d(double new_value,const string& init_dimensions,float new_theta,float new_phi); \
38 explicit name##_3d(double new_value,const string& init_dimensions,const angle& new_theta,const angle& new_phi); \
39 explicit name##_3d(long double new_value,const string& init_dimensions,float new_theta,float new_phi); \
40 explicit name##_3d(long double new_value,const string& init_dimensions,const angle& new_theta,const angle& new_phi); \
41 explicit name##_3d(int new_value,const string& init_dimensions,float new_theta,float new_phi); \
42 explicit name##_3d(int new_value,const string& init_dimensions,const angle& new_theta,const angle& new_phi); \
43 explicit name##_3d(float new_value,const vector<dimension>& new_dimensions,float new_theta,float new_phi); \
44 explicit name##_3d(float new_value,const vector<dimension>& new_dimensions,const angle& new_theta,const angle& new_phi); \
45 explicit name##_3d(double new_value,const vector<dimension>& new_dimensions,float new_theta,float new_phi); \
46 explicit name##_3d(double new_value,const vector<dimension>& new_dimensions,const angle& new_theta,const angle& new_phi); \
47 explicit name##_3d(long double new_value,const vector<dimension>& new_dimensions,float new_theta,float new_phi); \
48 explicit name##_3d(long double new_value,const vector<dimension>& new_dimensions,const angle& new_theta,const angle& new_phi); \
49 explicit name##_3d(int new_value,const vector<dimension>& new_dimensions,float new_theta,float new_phi); \
50 explicit name##_3d(int new_value,const vector<dimension>& new_dimensions,const angle& new_theta,const angle& new_phi); \
51 explicit name##_3d(const scalar_unit& x,float new_theta,float new_phi); \
52 explicit name##_3d(const scalar_unit& x,const angle& new_theta,const angle& new_phi); \
53 explicit name##_3d(const string& init_scalar,float new_theta,float new_phi); \
54 explicit name##_3d(const string& init_scalar,const angle& new_theta,const angle& new_phi); \
55 explicit name##_3d(const string& init_vector_3d); \
56 explicit name##_3d(const vector_unit_3d& init_vector_3d); \
57 explicit name##_3d(vector_unit_3d&& init_vector_3d); \
58 name##_3d& operator =(const name##_3d& x); \
59 name##_3d& operator =(name##_3d&& x); \
60 using vector_unit_3d::operator =; \
61 using vector_unit_3d::operator+=; \
62 using vector_unit_3d::operator-=

◆ VECTOR_UNIT_3D_HPP_END

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

Definition at line 64 of file vector_unit_3d.hpp.

64 : \
65 static const string dimensions_match; \
66 static const vector<dimension> real_dimensions; \
67 }

◆ VECTOR_UNIT_CPP

#define VECTOR_UNIT_CPP (   name,
  init_real_dimensions 
)
Value:
SCALAR_UNIT_CPP(name,init_real_dimensions); \
VECTOR_UNIT_2D_CPP(name,init_real_dimensions); \
VECTOR_UNIT_3D_CPP(name,init_real_dimensions); \
VECTOR_UNIT_ND_CPP(name,init_real_dimensions)
#define SCALAR_UNIT_CPP(name, init_real_dimensions)

Definition at line 293 of file vector_unit_3d.hpp.

◆ VECTOR_UNIT_HPP

#define VECTOR_UNIT_HPP (   name)
Value:
VECTOR_UNIT_2D_HPP(name); \
VECTOR_UNIT_3D_HPP(name); \
VECTOR_UNIT_ND_HPP(name)
#define SCALAR_UNIT_HPP(name)

Definition at line 288 of file vector_unit_3d.hpp.

Function Documentation

◆ operator!=() [1/3]

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

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

Definition at line 539 of file vector_unit_3d.cpp.

540{
541 return !(x == y);
542}

◆ operator!=() [2/3]

bool operator!= ( const scifir::vector_unit_3d x,
const string &  init_vector_3d 
)

Returns true if x is not equal to the vector_unit_3d 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 550 of file vector_unit_3d.cpp.

551{
552 return !(x == init_vector_3d);
553}

◆ operator!=() [3/3]

bool operator!= ( const string &  init_vector_3d,
const scifir::vector_unit_3d x 
)

Returns true if x is not equal to the vector_unit_3d 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 561 of file vector_unit_3d.cpp.

562{
563 return !(init_vector_3d == y);
564}

◆ operator*() [1/2]

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

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

Definition at line 532 of file vector_unit_3d.cpp.

533{
534 long double new_value = x.get_value() * y.get_value();
535 vector<scifir::dimension> new_dimensions = multiply_dimensions(x.get_dimensions(), y.get_dimensions(),new_value);
536 return scifir::vector_unit_3d(float(new_value), new_dimensions, y.theta, y.phi);
537}
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 3D. The vector is in spherical coordinates with a value and dimen...
angle theta
Angle theta of the vector in 3D space, in spherical coordinates. As all angles of scifir-units,...
angle phi
Angle phi of the vector in 3D space, in spherical 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_3d operator* ( const T  y,
const scifir::vector_unit_3d x 
)

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

Definition at line 504 of file vector_unit_3d.hpp.

505{
507 z *= y;
508 return z;
509}

◆ operator+() [1/3]

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

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

Definition at line 581 of file vector_unit_3d.cpp.

582{
583 ostringstream output;
584 output << y;
585 output << x;
586 return output.str();
587}

◆ operator+() [2/3]

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

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

Definition at line 573 of file vector_unit_3d.cpp.

574{
575 ostringstream output;
576 output << x;
577 output << y;
578 return output.str();
579}

◆ operator+() [3/3]

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

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

Definition at line 490 of file vector_unit_3d.hpp.

491{
493 z += y;
494 return z;
495}

◆ operator+=()

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

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

Definition at line 566 of file vector_unit_3d.cpp.

567{
568 ostringstream output;
569 output << y;
570 x += output.str();
571}

◆ operator-()

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

It creates a new vector as the substraction of the numeric type x with the value. Theta and phi are not changed.

Definition at line 498 of file vector_unit_3d.hpp.

499{
501}

◆ operator/()

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

It creates a new vector as the division of the numeric type x with the value. Theta and phi are not changed.

Definition at line 512 of file vector_unit_3d.hpp.

513{
514 vector<scifir::dimension> new_dimensions = x.get_dimensions();
515 for (scifir::dimension& new_dimension : new_dimensions)
516 {
517 new_dimension.invert();
518 }
519 return scifir::vector_unit_3d(y / x.get_value(),new_dimensions,x.theta,x.phi);
520}
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_3d x 
)

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

Definition at line 589 of file vector_unit_3d.cpp.

590{
591 return os << to_string(x);
592}
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_3d x,
const string &  init_vector_3d 
)

Returns true if x is equal to the vector_unit_3d 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 544 of file vector_unit_3d.cpp.

545{
546 scifir::vector_unit_3d y(init_vector_3d);
547 return (x == y);
548}

◆ operator==() [2/2]

bool operator== ( const string &  init_vector_3d,
const scifir::vector_unit_3d x 
)

Returns true if x is equal to the vector_unit_3d 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 555 of file vector_unit_3d.cpp.

556{
557 scifir::vector_unit_3d x(init_vector_3d);
558 return (x == y);
559}

◆ operator>>()

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

Allows that an istream initializes by string a vector_unit_3d x.

#endif // SCIFIR_UNITS_UNITS_VECTOR_UNIT_3D_HPP_INCLUDED

Definition at line 594 of file vector_unit_3d.cpp.

595{
596 char a[256];
597 is.getline(a, 256);
598 string b(a);
599 boost::trim(b);
601 return is;
602}