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
vector_unit_nd.cpp
Go to the documentation of this file.
2
3#include "../coordinates/coordinates_2d.hpp"
4#include "../coordinates/coordinates_3d.hpp"
5
6using namespace std;
7
8namespace scifir
9{
12
14 {}
15
16 vector_unit_nd::vector_unit_nd(vector_unit_nd&& x) : scalar_unit(std::move(x)),angles(std::move(x.angles))
17 {}
18
26
29
37
40
48
51
59
62
65
67 {
68 for(const float& x_angle : new_angles)
69 {
70 angles.push_back(angle(x_angle));
71 }
72 }
73
76
79
81 {
82 for(const float& x_angle : new_angles)
83 {
84 angles.push_back(angle(x_angle));
85 }
86 }
87
90
93
95 {
96 for(const float& x_angle : new_angles)
97 {
98 angles.push_back(angle(x_angle));
99 }
100 }
101
104
107
109 {
110 for(const float& x_angle : new_angles)
111 {
112 angles.push_back(angle(x_angle));
113 }
114 }
115
118
121
123 {
124 for(const float& x_angle : new_angles)
125 {
126 angles.push_back(angle(x_angle));
127 }
128 }
129
132
135
137 {
138 for(const float& x_angle : new_angles)
139 {
140 angles.push_back(angle(x_angle));
141 }
142 }
143
146
149
151 {
152 for(const float& x_angle : new_angles)
153 {
154 angles.push_back(angle(x_angle));
155 }
156 }
157
160
163
165 {
166 for(const float& x_angle : new_angles)
167 {
168 angles.push_back(angle(x_angle));
169 }
170 }
171
174
177
179 {
180 for(const float& x_angle : new_angles)
181 {
182 angles.push_back(angle(x_angle));
183 }
184 }
185
188
190 {
191 for(const float& x_angle : new_angles)
192 {
193 angles.push_back(angle(x_angle));
194 }
195 }
196
199
204
206 {
208 angles = x.angles;
209 return *this;
210 }
211
213 {
214 scalar_unit::operator =(std::move(x));
215 angles = std::move(x.angles);
216 return *this;
217 }
218
220 {
222 return *this;
223 }
224
226 {
227 scalar_unit::operator =(std::move(x));
228 return *this;
229 }
230
236
238 {
239 x.change_dimensions(*this);
241 {
242 return true;
243 }
244 else
245 {
246 return false;
247 }
248 }
249
251 {
252 if (is_nd(1))
253 {
254 if (x == direction::LEFT)
255 {
256 if (value > 0)
257 {
258 value *= -1;
259 }
260 }
261 else if(x == direction::RIGHT)
262 {
263 if (value < 0)
264 {
265 value *= -1;
266 }
267 }
268 }
269 else if (is_nd(2))
270 {
271 if (x == direction::LEFT)
272 {
273 angles[0] = 180.0f;
274 }
275 else if(x == direction::RIGHT)
276 {
277 angles[0] = 0.0f;
278 }
279 else if(x == direction::TOP)
280 {
281 angles[0] = 90.0f;
282 }
283 else if(x == direction::BOTTOM)
284 {
285 angles[0] = 270.0f;
286 }
287 else if(x == direction::LEFT_TOP)
288 {
289 angles[0] = 135.0f;
290 }
291 else if(x == direction::RIGHT_TOP)
292 {
293 angles[0] = 45.0f;
294 }
295 else if(x == direction::RIGHT_BOTTOM)
296 {
297 angles[0] = 315.0f;
298 }
299 else if(x == direction::LEFT_BOTTOM)
300 {
301 angles[0] = 225.0f;
302 }
303 }
304 else if (is_nd(3))
305 {
306 if (x == direction::LEFT)
307 {
308 angles[0] = 270.0f;
309 angles[1] = 90.0f;
310 }
311 else if(x == direction::RIGHT)
312 {
313 angles[0] = 90.0f;
314 angles[1] = 90.0f;
315 }
316 else if(x == direction::TOP)
317 {
318 angles[0] = 0.0f;
319 angles[1] = 0.0f;
320 }
321 else if(x == direction::BOTTOM)
322 {
323 angles[0] = 0.0f;
324 angles[1] = 180.0f;
325 }
326 else if(x == direction::LEFT_TOP)
327 {
328 angles[0] = 270.0f;
329 angles[1] = 45.0f;
330 }
331 else if(x == direction::RIGHT_TOP)
332 {
333 angles[0] = 90.0f;
334 angles[1] = 45.0f;
335 }
336 else if(x == direction::RIGHT_BOTTOM)
337 {
338 angles[0] = 90.0f;
339 angles[1] = 135.0f;
340 }
341 else if(x == direction::LEFT_BOTTOM)
342 {
343 angles[0] = 270.0f;
344 angles[1] = 135.0f;
345 }
346 else if(x == direction::FRONT)
347 {
348 angles[0] = 0.0f;
349 angles[1] = 90.0f;
350 }
351 else if(x == direction::BACK)
352 {
353 angles[0] = 180.0f;
354 angles[1] = 90.0f;
355 }
356 else if(x == direction::LEFT_FRONT)
357 {
358 angles[0] = 315.0f;
359 angles[1] = 90.0f;
360 }
361 else if(x == direction::RIGHT_FRONT)
362 {
363 angles[0] = 45.0f;
364 angles[1] = 90.0f;
365 }
366 else if(x == direction::TOP_FRONT)
367 {
368 angles[0] = 0.0f;
369 angles[1] = 45.0f;
370 }
371 else if(x == direction::BOTTOM_FRONT)
372 {
373 angles[0] = 0.0f;
374 angles[1] = 135.0f;
375 }
376 else if(x == direction::LEFT_BACK)
377 {
378 angles[0] = 225.0f;
379 angles[1] = 90.0f;
380 }
381 else if(x == direction::RIGHT_BACK)
382 {
383 angles[0] = 135.0f;
384 angles[1] = 90.0f;
385 }
386 else if(x == direction::TOP_BACK)
387 {
388 angles[0] = 180.0f;
389 angles[1] = 45.0f;
390 }
391 else if(x == direction::BOTTOM_BACK)
392 {
393 angles[0] = 180.0f;
394 angles[1] = 135.0f;
395 }
396 else if(x == direction::LEFT_TOP_FRONT)
397 {
398 angles[0] = 315.0f;
399 angles[1] = 45.0f;
400 }
401 else if(x == direction::RIGHT_TOP_FRONT)
402 {
403 angles[0] = 45.0f;
404 angles[1] = 45.0f;
405 }
406 else if(x == direction::LEFT_BOTTOM_FRONT)
407 {
408 angles[0] = 315.0f;
409 angles[1] = 135.0f;
410 }
412 {
413 angles[0] = 45.0f;
414 angles[1] = 135.0f;
415 }
416 else if(x == direction::LEFT_TOP_BACK)
417 {
418 angles[0] = 225.0f;
419 angles[1] = 45.0f;
420 }
421 else if(x == direction::RIGHT_TOP_BACK)
422 {
423 angles[0] = 135.0f;
424 angles[1] = 45.0f;
425 }
426 else if(x == direction::LEFT_BOTTOM_BACK)
427 {
428 angles[0] = 225.0f;
429 angles[1] = 135.0f;
430 }
431 else if(x == direction::RIGHT_BOTTOM_BACK)
432 {
433 angles[0] = 135.0f;
434 angles[1] = 135.0f;
435 }
436 }
437 }
438
440 {
441 if(has_dimensions(x) and get_nd() == x.get_nd())
442 {
443 if(is_nd(1))
444 {
446 }
447 else if(is_nd(2))
448 {
449 float new_x = float(x_projection() + x.x_projection());
450 float new_y = float(y_projection() + x.y_projection());
453 }
454 else if(is_nd(3))
455 {
456 float new_x = float(x_projection() + x.x_projection());
457 float new_y = float(y_projection() + x.y_projection());
458 float new_z = float(z_projection() + x.z_projection());
462 }
463 }
464 else
465 {
466 cerr << "Cannot sum vectors of different dimensions" << endl;
467 }
468 }
469
471 {
472 if(has_dimensions(x))
473 {
474 x.invert();
475 *this += x;
476 }
477 else
478 {
479 cerr << "Cannot substract vectors of different dimensions" << endl;
480 }
481 }
482
484 {
485 if(has_dimensions(x))
486 {
487 if(is_nd(1))
488 {
491 }
492 else if(is_nd(2))
493 {
494 float new_x = float(x_projection() + x.x_projection());
495 float new_y = float(y_projection() + x.y_projection());
500 }
501 else if(is_nd(3))
502 {
503 float new_x = float(x_projection() + x.x_projection());
504 float new_y = float(y_projection() + x.y_projection());
505 float new_z = float(z_projection() + x.z_projection());
511 }
512 else
513 {
514 return vector_unit_nd();
515 }
516 }
517 else
518 {
519 cerr << "Cannot sum vectors of different dimensions" << endl;
520 return vector_unit_nd();
521 }
522 }
523
525 {
526 if(has_dimensions(x))
527 {
528 if(is_nd(1))
529 {
532 }
533 else if(is_nd(2))
534 {
535 x.invert();
536 float new_x = float(x_projection() + x.x_projection());
537 float new_y = float(y_projection() + x.y_projection());
542 }
543 else if(is_nd(3))
544 {
545 x.invert();
546 float new_x = float(x_projection() + x.x_projection());
547 float new_y = float(y_projection() + x.y_projection());
548 float new_z = float(z_projection() + x.z_projection());
554 }
555 else
556 {
557 return vector_unit_nd();
558 }
559 }
560 else
561 {
562 cerr << "Cannot sum vectors of different dimensions" << endl;
563 return vector_unit_nd();
564 }
565 }
566
568 {
569 long double new_value = scalar_unit::value * x.get_value();
571 if(is_nd(1))
572 {
574 }
575 else if(is_nd(2))
576 {
577 return vector_unit_nd(float(new_value), new_dimensions, {angles[0]});
578 }
579 else if(is_nd(3))
580 {
581 return vector_unit_nd(float(new_value), new_dimensions, {angles[0], angles[1]});
582 }
583 else
584 {
586 }
587 }
588
590 {
591 long double new_value = scalar_unit::value / x.get_value();
593 if(is_nd(1))
594 {
596 }
597 else if(is_nd(2))
598 {
599 return vector_unit_nd(float(new_value), new_dimensions, {angles[0]});
600 }
601 else if(is_nd(3))
602 {
603 return vector_unit_nd(float(new_value), new_dimensions, {angles[0], angles[1]});
604 }
605 else
606 {
608 }
609 }
610
612 {
614 {
616 if(is_nd(1))
617 {
618 return vector_unit_nd(new_unit);
619 }
620 else if(is_nd(2))
621 {
622 return vector_unit_nd(new_unit, {angles[0]});
623 }
624 else if(is_nd(3))
625 {
626 return vector_unit_nd(new_unit, {angles[0], angles[1]});
627 }
628 else
629 {
631 }
632 }
633 else
634 {
635 cerr << "Cannot power with as exponent a unit with dimensions" << endl;
636 return vector_unit_nd();
637 }
638 }
639
641 {
642 if (i == 1)
643 {
644 return x_projection();
645 }
646 else if (i == 2)
647 {
648 return y_projection();
649 }
650 else if (i == 3)
651 {
652 return z_projection();
653 }
654 else
655 {
656 return scalar_unit();
657 }
658 }
659
661 {
662 if (is_nd(1))
663 {
665 }
666 else if (is_nd(2))
667 {
669 }
670 else if (is_nd(3))
671 {
673 }
674 else
675 {
676 return scalar_unit();
677 }
678 }
679
681 {
682 if (is_nd(1))
683 {
684 return scalar_unit();
685 }
686 else if (is_nd(2))
687 {
689 }
690 else if (is_nd(3))
691 {
693 }
694 else
695 {
696 return scalar_unit();
697 }
698 }
699
701 {
702 if (is_nd(1))
703 {
704 return scalar_unit();
705 }
706 else if (is_nd(2))
707 {
708 return scalar_unit();
709 }
710 else if (is_nd(3))
711 {
713 }
714 else
715 {
716 return scalar_unit();
717 }
718 }
719
721 {
722 if (is_nd(2))
723 {
724 angles[0].invert();
725 }
726 else if (is_nd(3))
727 {
728 angles[0].invert();
729 angles[1] = 180.0f - angles[1];
730 }
731 }
732
734 {
737 for (const angle& x_angle : angles)
738 {
739 out << " " << x_angle.display(number_of_decimals);
740 }
741 return out.str();
742 }
743
745 {
748 for (const angle& x_angle : angles)
749 {
750 out << " " << x_angle.display(number_of_decimals);
751 }
752 return out.str();
753 }
754
756 {
759 for (const angle& x_angle : angles)
760 {
761 out << " " << x_angle.display(number_of_decimals);
762 }
763 return out.str();
764 }
765
767 {
768 vector<string> values;
769 boost::split(values,init_vector_nd,boost::is_any_of(" "));
770 scalar_unit::initialize_from_string(values[0] + " " + values[1],vector<dimension>());
771 if (values.size() > 2)
772 {
773 angles.clear();
774 for (unsigned int i = 2; i < values.size(); i++)
775 {
776 angles.push_back(angle(values[i]));
777 }
778 }
779 }
780
781 string to_string(const vector_unit_nd& x)
782 {
783 return x.vectorial_display(2);
784 }
785
787 {
788 return scalar_unit(std::abs(x.get_value()),x.get_dimensions());
789 }
790
796
798 {
801 }
802
809
811 {
812 if(x.is_nd(3) and y.is_nd(3))
813 {
814 long double new_value;
817 if(y.angles[0] == x.angles[0] and y.angles[1] == x.angles[1])
818 {
819 new_value = 0.0l;
820 }
821 else
822 {
823 float new_x = float(x.y_projection() * y.z_projection() - x.z_projection() * y.y_projection());
824 float new_y = float(x.z_projection() * y.x_projection() - x.x_projection() * y.z_projection());
825 float new_z = float(x.x_projection() * y.y_projection() - x.y_projection() * y.x_projection());
829 }
832 vector<angle> angles;
833 angles.push_back(new_theta);
834 angles.push_back(new_phi);
835 return vector_unit_nd(new_unit, angles);
836 }
837 else
838 {
839 return vector_unit_nd();
840 }
841 }
842
844 {
845 return scifir::acos(float(dot_product(x,y)/(norm(x) * norm(y))));
846 }
847
848 bool same_nd(const vector_unit_nd& x, const vector_unit_nd& y)
849 {
850 if(x.angles.size() == y.angles.size())
851 {
852 return true;
853 }
854 else
855 {
856 return false;
857 }
858 }
859
861 {
862 if (same_nd(x,y))
863 {
864 for(unsigned int i = 0; i < x.angles.size(); i++)
865 {
866 if(x.angles[i] != y.angles[i])
867 {
868 return false;
869 }
870 }
871 return true;
872 }
873 return false;
874 }
875
876 bool parallel(const vector_unit_nd& x, const vector_unit_nd& y)
877 {
878 if (same_nd(x,y))
879 {
880 if (x.get_nd() == 1)
881 {
882 return true;
883 }
884 else if (x.get_nd() == 2)
885 {
886 return scifir::parallel(x.angles[0],y.angles[0]);
887 }
888 else if (x.get_nd() == 3)
889 {
890 if ((x.angles[0] == y.angles[0] and x.angles[1] == y.angles[1]) or (x.angles[0] == (180.0f + y.angles[0]) and x.angles[1] == (180.0f - y.angles[1])))
891 {
892 return true;
893 }
894 else
895 {
896 return false;
897 }
898 }
899 }
900 return false;
901 }
902
904 {
905 if (same_nd(x,y))
906 {
907 if (x.get_nd() == 1)
908 {
909 return false;
910 }
911 else if (x.get_nd() == 2)
912 {
913 return scifir::orthogonal(x.angles[0],y.angles[0]);
914 }
915 else if (x.get_nd() == 3)
916 {
918 return (x_angle == 90.0f);
919 }
920 }
921 return false;
922 }
923}
924
926{
927 long double new_value = y.get_value() * x.get_value();
928 vector<scifir::dimension> new_dimensions = multiply_dimensions(y.get_dimensions(), x.get_dimensions(),new_value);
929 if(y.is_nd(1))
930 {
931 return scifir::vector_unit_nd(float(new_value), new_dimensions);
932 }
933 else if(y.is_nd(2))
934 {
935 return scifir::vector_unit_nd(float(new_value), new_dimensions, {y.angles[0]});
936 }
937 else if(y.is_nd(3))
938 {
939 return scifir::vector_unit_nd(float(new_value), new_dimensions, {y.angles[0], y.angles[1]});
940 }
941 else
942 {
943 return scifir::vector_unit_nd(float(new_value), new_dimensions, y.angles);
944 }
945}
946
948{
949 return !(x == y);
950}
951
952bool operator ==(const scifir::vector_unit_nd& x, const string& init_vector_nd)
953{
954 scifir::vector_unit_nd y(init_vector_nd);
955 return (x == y);
956}
957
958bool operator !=(const scifir::vector_unit_nd& x, const string& init_vector_nd)
959{
960 return !(x == init_vector_nd);
961}
962
963bool operator ==(const string& init_vector_nd, const scifir::vector_unit_nd& x)
964{
965 scifir::vector_unit_nd y(init_vector_nd);
966 return (y == x);
967}
968
969bool operator !=(const string& init_vector_nd, const scifir::vector_unit_nd& x)
970{
971 return !(init_vector_nd == x);
972}
973
974void operator +=(string& x, const scifir::vector_unit_nd& y)
975{
976 ostringstream output;
977 output << y;
978 x += output.str();
979}
980
981string operator +(const string& x, const scifir::vector_unit_nd& y)
982{
983 ostringstream output;
984 output << x;
985 output << y;
986 return output.str();
987}
988
989string operator +(const scifir::vector_unit_nd& y, const string& x)
990{
991 ostringstream output;
992 output << y;
993 output << x;
994 return output.str();
995}
996
997ostream& operator <<(ostream& os, const scifir::vector_unit_nd& x)
998{
999 ostringstream angles_text;
1000 if (!x.is_nd(1))
1001 {
1002 for(const auto& x_angle : x.angles)
1003 {
1004 angles_text << " ";
1005 angles_text << x_angle;
1006 }
1007 }
1008 return os << x.get_value() << " " << x.display_dimensions() << angles_text.str();
1009}
1010
1011istream& operator >>(istream& is, scifir::vector_unit_nd& x)
1012{
1013 char a[256];
1014 is.getline(a, 256);
1015 string b(a);
1016 boost::trim(b);
1018 return is;
1019}
1020
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
Definition angle.hpp:77
position
Represents the position of the dimension, which can be at the numerator or at the denominator....
Definition dimension.hpp:38
type
Represents a dimension of the SI system of units. All the dimensions of the SI system of units are su...
Definition dimension.hpp:34
type
Represents a prefix of the SI system of units. All the prefixes of the SI system of units are support...
Definition prefix.hpp:16
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
bool has_empty_dimensions() const
Checks if there aren't base dimensions.
string display_dimensions() const
Generates an string of the dimensions of the scalar_unit, with the same format as the initialization ...
scalar_unit & operator=(const scalar_unit &x)
Copy assignment, it assigns a copy of the scalar_unit.
const vector< dimension > & get_dimensions() const
Read-only getter of the dimensions.
bool has_dimensions(const string &init_dimensions) const
Checks if the basic dimensions are the same as the initialization string of dimensions.
string display(int number_of_decimals=2, bool with_brackets=false, bool use_close_prefix=false) const
Generates a string representation of the scalar_unit, with the value and the dimensions....
float value
Value of the scalar_unit. It changes automatically when the dimensions change.
void change_dimensions(const string &init_dimensions)
Changes the dimensions to the dimensions specified by the initialization string of dimensions.
scalar_unit()
Default constructor, the value is 0 and the dimensions are empty.
void initialize_from_string(string init_scalar, const vector< dimension > &real_dimensions)
Internal function. It sets the value and the dimensions of the scalar_unit to the value and dimension...
string custom_display(const string &init_dimensions, int number_of_decimals=2, bool with_brackets=false) const
Generates a string representation of the scalar_unit, with the dimensions changed to any set of dimen...
string base_display(int number_of_decimals=2, bool with_brackets=false, bool use_close_prefix=false) const
Generates a string representation of the scalar_unit, with its dimensions converted to their base cou...
const float & get_value() const
Read-only getter of the value.
scalar_unit operator^(const scalar_unit &x) const
Power operator, it powers a scalar_unit class with another, if that second scalar_unit class,...
Class that creates a vector in ND, which means a variable number of dimensions. A vector_unit_nd can ...
vector_unit_nd()
Default constructor. The value is 0, the dimensions are empty and the angles are empty.
scalar_unit n_projection(int i) const
Returns the x projection, the y projection or the z projection, depending if i is 1 (it returns x),...
string vectorial_display(int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also all the angles.
vector_unit_nd & operator=(const vector_unit_nd &x)
Copy assignment. The member-variables are copied from vector_unit_nd x.
void operator+=(const vector_unit_nd &x)
The vector_unit_nd is summed as vector in 2D, 3D, or more coordinates. It's summed as scalar in 1D.
int get_nd() const
Returns the number of dimensions.
bool is_nd(unsigned int i) const
Returns true if the vector is at the same number of dimensions as i.
bool operator==(vector_unit_nd x) const
Comparison operator. Two vector_unit_nd are equal if their value, dimensions and angles are the same.
vector< angle > angles
The angles. A total of one angle means the vector is in 2D in polar coordinates, two angles means it'...
string vectorial_base_display(int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also all the angles....
scalar_unit x_projection() const
It creates the x projection of the vector, returning it as a scalar_unit of the same dimensions,...
vector_unit_nd operator+(const vector_unit_nd &x) const
Addition of vectors in 2D, 3D, or more coordinates. It's an addition of scalars in 1D....
scalar_unit y_projection() const
It creates the y projection of the vector, returning it as a scalar_unit of the same dimensions,...
vector_unit_nd operator/(const scalar_unit &x) const
It creates a new vector_unit_3d scaling a vector_unit_3d by the inverse of the scalar_unit x.
void operator-=(vector_unit_nd x)
The vector_unit_nd is substracted as vector in 2D, 3D, or more coordinates. It's substracted as scala...
vector_unit_nd operator-(vector_unit_nd x) const
Substraction of vectors in 2D, 3D, or more coordinates. It's a substraction of scalars in 1D....
void point_to(direction::name x)
The angles are set to the direction specified in 1D, 2D or 3D, depending on the current ND of vector_...
vector_unit_nd operator*(const scalar_unit &x) const
It creates a new vector_unit_nd scaling a vector_unit_nd by the scalar_unit x.
scalar_unit z_projection() const
It creates the z projection of the vector, returning it as a scalar_unit of the same dimensions,...
string vectorial_custom_display(const string &init_dimensions, int number_of_decimals=2) const
Displays the vector as the string representation of the scalar unit adding also all the angles....
vector_unit_nd operator^(const scalar_unit &x) const
It powers a vector by a scalar_unit x if that scalar_unit has empty dimensions.
void initialize_from_string(string init_vector_nd)
Initializes the member-variables with the initialization string of vector_unit_nd init_vector_nd.
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
Definition address.cpp:6
angle 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.
angle sqrt_nth(const angle &x, int index)
Calculates the nth root of the angle x and returns that new angle.
Definition angle.cpp:421
bool same_direction(const vector_unit_2d &x, const vector_unit_2d &y)
Checks if two vectors x and y have the same direction.
vector< dimension > divide_dimensions(vector< dimension > x, const vector< dimension > &y, long double &value)
Divides the first vector of dimensions with the other. The result is normalized after,...
angle cartesian_3d_to_spherical_theta(const scalar_unit &x, scalar_unit y, const scalar_unit &z)
Returns the theta coordinate of the spherical coordinates given the x, y and z of cartesian coordinat...
float cos(const angle &x)
Calculates the cos of angle x. It uses the cos() function of the standard library of C++,...
Definition angle.cpp:431
angle cartesian_2d_to_polar_theta(const scalar_unit &x, scalar_unit y)
bool orthogonal(const angle &x, const angle &y)
Checks if two angles in a 2D correspond to orthogonal lines (or orthogonal vectors).
Definition angle.cpp:403
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
bool same_nd(const vector_unit_nd &x, const vector_unit_nd &y)
Checks if two vectors have the same number of dimensions.
scalar_unit cartesian_2d_to_polar_p(const scalar_unit &x, scalar_unit y)
scalar_unit 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.
scalar_unit cartesian_3d_to_spherical_r(const scalar_unit &x, scalar_unit y, scalar_unit z)
Returns the r coordinate of the spherical coordinates given the x, y and z of cartesian coordinates i...
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...
angle cartesian_3d_to_spherical_phi(const scalar_unit &x, scalar_unit y, scalar_unit z)
Returns the phi coordinate of the spherical coordinates given the x, y and z of cartesian coordinates...
vector_unit_3d 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.
scalar_unit norm(const vector_unit_2d &x)
It returns the value of the vector in polar coordinates, p.
angle acos(float x)
Calculates the acos of some value x and returns the result as angle in degrees.
Definition angle.cpp:446
float sin(const angle &x)
Calculates the sin of angle x. It uses the sin() function of the standard library of C++,...
Definition angle.cpp:426
angle sqrt(const angle &x)
Calculates the square root of the angle x and returns that new angle.
Definition angle.cpp:416
bool parallel(const angle &x, const angle &y)
Checks if two angles in a 2D correspond to parallel lines (or parallel vectors).
Definition angle.cpp:391
bool operator!=(const scifir::vector_unit_nd &x, const scifir::vector_unit_nd &y)
Comparison operator. Two vector_unit_nd are not equal if their value, dimensions or angles are differ...
istream & operator>>(istream &is, scifir::vector_unit_nd &x)
Allows that an istream initializes by string a vector_unit_nd x.
bool operator==(const scifir::vector_unit_nd &x, const string &init_vector_nd)
Returns true if x is equal to the vector_unit_nd initialized with the string being compared....
scifir::vector_unit_nd operator*(const scifir::scalar_unit &x, const scifir::vector_unit_nd &y)
It creates a new vector_unitn3d scaling a vector_unit_nd by the scalar_unit x.
ostream & operator<<(ostream &os, const scifir::vector_unit_nd &x)
Adds the string representation of the vector_unit_nd x to an output stream os.
void operator+=(string &x, const scifir::vector_unit_nd &y)
Concatenates the string representation of the vector_unit_nd y to the string x.
string operator+(const string &x, const scifir::vector_unit_nd &y)
Creates a new string as the concatenation of the string x with the representation string of the vecto...