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
coordinates_ndr.hpp
Go to the documentation of this file.
1#ifndef SCIFIR_UNITS_COORDINATES_COORDINATES_NDR_HPP_INCLUDED
2#define SCIFIR_UNITS_COORDINATES_COORDINATES_NDR_HPP_INCLUDED
3
5#include "../derived_units/physics_units.hpp"
6#include "../units/base_units.hpp"
7#include "../util/types.hpp"
8
9#include <iostream>
10#include <string>
11#include <vector>
12
13using namespace std;
14
15namespace scifir
16{
17 extern angle coordinates_ndr_no_angle;
18
19 template<typename T = length>
21 {
22 public:
25
27 {
28 if (x.values.size() == (x.angles.size() + 1))
29 {
30 values = x.values;
31 angles = x.angles;
32 }
33 }
34
36 {
37 if (x.values.size() == (x.angles.size() + 1))
38 {
39 values = std::move(x.values);
40 angles = std::move(x.angles);
41 }
42 }
43
44 template<typename U>
46 {
47 if (new_values.size() == (new_values.size() + 1))
48 {
49 for(const U& x_value : new_values)
50 {
51 values.push_back(T(x_value));
52 }
53 for(const float& x_angle : new_angles)
54 {
55 angles.push_back(angle(x_angle));
56 }
57 }
58 }
59
60 template<typename U>
62 {
63 if (new_values.size() == (new_angles.size() + 1))
64 {
65 for(const U& x_value : new_values)
66 {
67 values.push_back(T(x_value));
68 }
70 }
71 }
72
74 {
75 values.push_back(T(new_x));
76 }
77
79 {
80 values.push_back(T(new_x));
81 values.push_back(T(new_y));
82 angles.push_back(new_theta);
83 }
84
86 {
89 angles.push_back(new_theta);
90 }
91
93 {
94 values.push_back(T(new_x));
95 values.push_back(T(new_y));
96 values.push_back(T(new_z));
97 angles.push_back(new_theta);
98 angles.push_back(new_phi);
99 }
100
102 {
105 values.push_back(T(new_z));
106 angles.push_back(new_theta);
107 angles.push_back(new_phi);
108 }
109
118
127
128 template<typename U>
130 {
131 if (new_coordinates.values.size() == (new_angles.size() + 1))
132 {
133 for(const U& x_value : new_coordinates.values)
134 {
135 values.push_back(T(x_value));
136 }
137 for(const float& x_angle : new_angles)
138 {
139 angles.push_back(angle(x_angle));
140 }
141 }
142 }
143
144 template<typename U>
146 {
147 if (new_coordinates.values.size() == (new_angles.size() + 1))
148 {
149 for(const U& x_value : new_coordinates.values)
150 {
151 values.push_back(T(std::move(x_value)));
152 }
153 for(const float& x_angle : new_angles)
154 {
155 angles.push_back(angle(x_angle));
156 }
157 }
158 }
159
160 template<typename U>
162 {
163 if (new_coordinates.values.size() == (new_angles.size() + 1))
164 {
165 for(const U& x_value : new_coordinates.values)
166 {
167 values.push_back(T(x_value));
168 }
170 }
171 }
172
173 template<typename U>
175 {
176 if (new_coordinates.values.size() == (new_angles.size() + 1))
177 {
178 for(const U& x_value : new_coordinates.values)
179 {
180 values.push_back(T(std::move(x_value)));
181 }
183 }
184 }
185
190
192 {
193 if (x_coordinates.values.size() == (x_coordinates.angles.size() + 1))
194 {
195 values = x_coordinates.values;
196 angles = x_coordinates.angles;
197 }
198 return *this;
199 }
200
202 {
203 if (x_coordinates.values.size() == (x_coordinates.angles.size() + 1))
204 {
205 values = std::move(x_coordinates.values);
206 angles = std::move(x_coordinates.angles);
207 }
208 return *this;
209 }
210
211 template<typename U>
213 {
214 if (x_coordinates.values.size() == (angles.size() + 1))
215 {
216 values.clear();
217 for(const U& x_value : x_coordinates.values)
218 {
219 values.push_back(T(x_value));
220 }
221 }
222 return *this;
223 }
224
225 template<typename U>
227 {
228 if (x_coordinates.values.size() == (angles.size() + 1))
229 {
230 values.clear();
231 for(const U& x_value : x_coordinates.values)
232 {
233 values.push_back(T(std::move(x_value)));
234 }
235 }
236 return *this;
237 }
238
244
246 {
248 for (unsigned int i = 0; i < coordinates.values.size(); i++)
249 {
250 new_coordinates.get_value(i) += coordinates.get_value(i);
251 }
252 return new_coordinates;
253 }
254
255 bool is_nd(int i) const
256 {
257 return values.size() == i;
258 }
259
260 int get_nd() const
261 {
262 return values.size();
263 }
264
266 {
267 if (new_values.size() == (new_angles.size() + 1))
268 {
269 values.clear();
270 for(const scalar_unit& x_value : new_values)
271 {
272 values.push_back(T(x_value));
273 }
274 angles.clear();
275 for(const float& x_angle : new_angles)
276 {
277 angles.push_back(angle(x_angle));
278 }
279 }
280 }
281
283 {
284 if (new_values.size() == (new_angles.size() + 1))
285 {
286 values.clear();
287 for(const scalar_unit& x_value : new_values)
288 {
289 values.push_back(T(x_value));
290 }
292 }
293 }
294
295 const vector<T>& get_values() const
296 {
297 return values;
298 }
299
301 {
302 if (values.size() == new_values.size())
303 {
304 values.clear();
305 for(const scalar_unit& x_value : new_values)
306 {
307 values.push_back(T(x_value));
308 }
309 }
310 }
311
312 const T& get_value(int i) const
313 {
314 if (i < (values.size()))
315 {
316 return values[i];
317 }
318 else
319 {
320 return no_value;
321 }
322 }
323
325 {
326 if (i < (values.size()))
327 {
328 return values[i];
329 }
330 else
331 {
332 return no_value;
333 }
334 }
335
337 {
338 return angles;
339 }
340
342 {
343 if (values.size() == (new_angles.size() + 1))
344 {
345 angles.clear();
346 for(const float& x_angle : new_angles)
347 {
348 angles.push_back(angle(x_angle));
349 }
350 }
351 }
352
354 {
355 if (values.size() == (new_angles.size() + 1))
356 {
358 }
359 }
360
361 const angle& get_angle(int i) const
362 {
363 if (i < (values.size() - 1))
364 {
365 return angles[i];
366 }
367 else
368 {
370 }
371 }
372
374 {
375 if (i < (values.size() - 1))
376 {
377 return angles[i];
378 }
379 else
380 {
382 }
383 }
384
385 T get_p() const
386 {
387 if (get_nd() == 2 or get_nd() == 3)
388 {
389 return T(scifir::sqrt(scifir::pow(values[0],2) + scifir::pow(values[1],2)));
390 }
391 else
392 {
393 return T();
394 }
395 }
396
398 {
399 if (get_nd() == 2 or get_nd() == 3)
400 {
401 return angle(scifir::atan_degree(float(values[1]/values[0])));
402 }
403 else
404 {
405 return angle();
406 }
407 }
408
409 T get_r() const
410 {
411 if (get_nd() == 2 or get_nd() == 3)
412 {
413 return T(scifir::sqrt(scifir::pow(values[0],2) + scifir::pow(values[1],2) + scifir::pow(values[2],2)));
414 }
415 else
416 {
417 return T();
418 }
419 }
420
422 {
423 if (get_nd() == 3)
424 {
426 }
427 else
428 {
429 return angle();
430 }
431 }
432
434 {
435 if (get_nd() == 3)
436 {
437 return ECEF_to_LLA_latitude(values[0],values[1],values[2]);
438 }
439 else
440 {
441 return latitude();
442 }
443 }
444
446 {
447 if (get_nd() == 3)
448 {
449 return ECEF_to_LLA_longitude(values[0],values[1],values[2]);
450 }
451 else
452 {
453 return longitude();
454 }
455 }
456
458 {
459 if (get_nd() == 3)
460 {
461 return ECEF_to_LLA_altitude(values[0],values[1],values[2]);
462 }
463 else
464 {
465 return scalar_unit();
466 }
467 }
468
470 {
471 if (is_nd(1))
472 {
473 if (x == direction::LEFT)
474 {
475 if (values[0] > 0)
476 {
477 values[0] *= -1;
478 }
479 }
480 else if(x == direction::RIGHT)
481 {
482 if (values[0] < 0)
483 {
484 values[0] *= -1;
485 }
486 }
487 }
488 else if (is_nd(2))
489 {
490 if (x == direction::LEFT)
491 {
492 angles[0] = 180.0f;
493 }
494 else if(x == direction::RIGHT)
495 {
496 angles[0] = 0.0f;
497 }
498 else if(x == direction::TOP)
499 {
500 angles[0] = 90.0f;
501 }
502 else if(x == direction::BOTTOM)
503 {
504 angles[0] = 270.0f;
505 }
506 else if(x == direction::LEFT_TOP)
507 {
508 angles[0] = 135.0f;
509 }
510 else if(x == direction::RIGHT_TOP)
511 {
512 angles[0] = 45.0f;
513 }
514 else if(x == direction::RIGHT_BOTTOM)
515 {
516 angles[0] = 315.0f;
517 }
518 else if(x == direction::LEFT_BOTTOM)
519 {
520 angles[0] = 225.0f;
521 }
522 }
523 else if (is_nd(3))
524 {
525 if (x == direction::LEFT)
526 {
527 angles[0] = 270.0f;
528 angles[1] = 90.0f;
529 }
530 else if(x == direction::RIGHT)
531 {
532 angles[0] = 90.0f;
533 angles[1] = 90.0f;
534 }
535 else if(x == direction::TOP)
536 {
537 angles[0] = 0.0f;
538 angles[1] = 0.0f;
539 }
540 else if(x == direction::BOTTOM)
541 {
542 angles[0] = 0.0f;
543 angles[1] = 180.0f;
544 }
545 else if(x == direction::LEFT_TOP)
546 {
547 angles[0] = 270.0f;
548 angles[1] = 45.0f;
549 }
550 else if(x == direction::RIGHT_TOP)
551 {
552 angles[0] = 90.0f;
553 angles[1] = 45.0f;
554 }
555 else if(x == direction::RIGHT_BOTTOM)
556 {
557 angles[0] = 90.0f;
558 angles[1] = 135.0f;
559 }
560 else if(x == direction::LEFT_BOTTOM)
561 {
562 angles[0] = 270.0f;
563 angles[1] = 135.0f;
564 }
565 else if(x == direction::FRONT)
566 {
567 angles[0] = 0.0f;
568 angles[1] = 90.0f;
569 }
570 else if(x == direction::BACK)
571 {
572 angles[0] = 180.0f;
573 angles[1] = 90.0f;
574 }
575 else if(x == direction::LEFT_FRONT)
576 {
577 angles[0] = 315.0f;
578 angles[1] = 90.0f;
579 }
580 else if(x == direction::RIGHT_FRONT)
581 {
582 angles[0] = 45.0f;
583 angles[1] = 90.0f;
584 }
585 else if(x == direction::TOP_FRONT)
586 {
587 angles[0] = 0.0f;
588 angles[1] = 45.0f;
589 }
590 else if(x == direction::BOTTOM_FRONT)
591 {
592 angles[0] = 0.0f;
593 angles[1] = 135.0f;
594 }
595 else if(x == direction::LEFT_BACK)
596 {
597 angles[0] = 225.0f;
598 angles[1] = 90.0f;
599 }
600 else if(x == direction::RIGHT_BACK)
601 {
602 angles[0] = 135.0f;
603 angles[1] = 90.0f;
604 }
605 else if(x == direction::TOP_BACK)
606 {
607 angles[0] = 180.0f;
608 angles[1] = 45.0f;
609 }
610 else if(x == direction::BOTTOM_BACK)
611 {
612 angles[0] = 180.0f;
613 angles[1] = 135.0f;
614 }
615 else if(x == direction::LEFT_TOP_FRONT)
616 {
617 angles[0] = 315.0f;
618 angles[1] = 45.0f;
619 }
620 else if(x == direction::RIGHT_TOP_FRONT)
621 {
622 angles[0] = 45.0f;
623 angles[1] = 45.0f;
624 }
625 else if(x == direction::LEFT_BOTTOM_FRONT)
626 {
627 angles[0] = 315.0f;
628 angles[1] = 135.0f;
629 }
631 {
632 angles[0] = 45.0f;
633 angles[1] = 135.0f;
634 }
635 else if(x == direction::LEFT_TOP_BACK)
636 {
637 angles[0] = 225.0f;
638 angles[1] = 45.0f;
639 }
640 else if(x == direction::RIGHT_TOP_BACK)
641 {
642 angles[0] = 135.0f;
643 angles[1] = 45.0f;
644 }
645 else if(x == direction::LEFT_BOTTOM_BACK)
646 {
647 angles[0] = 225.0f;
648 angles[1] = 135.0f;
649 }
650 else if(x == direction::RIGHT_BOTTOM_BACK)
651 {
652 angles[0] = 135.0f;
653 angles[1] = 135.0f;
654 }
655 }
656 }
657
659 {
660 if (values.size() == 1 and angles.size() == 0)
661 {
662 values.clear();
663 values.push_back(new_x);
664 }
665 }
666
668 {
669 if (values.size() == 2 and angles.size() == 1)
670 {
671 values.clear();
672 values.push_back(new_x);
673 values.push_back(new_y);
674 }
675 }
676
678 {
679 if (values.size() == 2 and angles.size() == 1)
680 {
681 values.clear();
682 values.push_back(T(new_p * scifir::cos(new_theta)));
683 values.push_back(T(new_p * scifir::sin(new_theta)));
684 }
685 }
686
688 {
689 if (values.size() == 3 and angles.size() == 2)
690 {
691 values.clear();
692 values.push_back(T(new_x));
693 values.push_back(T(new_y));
694 values.push_back(T(new_z));
695 }
696 }
697
699 {
700 if (values.size() == 3 and angles.size() == 2)
701 {
702 values.clear();
703 new_z.change_dimensions(new_p);
704 values.push_back(T(new_p * scifir::cos(new_theta)));
705 values.push_back(T(new_p * scifir::sin(new_theta)));
706 values.push_back(T(new_z));
707 }
708 }
709
711 {
712 if (values.size() == 3 and angles.size() == 2)
713 {
714 values.clear();
717 values.push_back(T(new_r * scifir::cos(new_phi)));
718 }
719 }
720
722 {
723 if (values.size() == 3 and angles.size() == 2)
724 {
725 values.clear();
729 }
730 }
731
733 {
734 if (values.size() == new_values.size() and new_values.size() == (angles.size() + 1))
735 {
736 values.clear();
738 }
739 }
740
742 {
743 if (get_nd() == 2)
744 {
745 T x_coord = values[0];
746 T y_coord = values[1];
749 }
750 }
751
753 {
754 if (get_nd() == 3)
755 {
756 if (axis == 1)
757 {
758 T y_coord = values[1];
759 T z_coord = values[2];
762 }
763 else if (axis == 2)
764 {
765 T x_coord = values[0];
766 T z_coord = values[2];
769 }
770 else if (axis == 3)
771 {
772 T x_coord = values[0];
773 T y_coord = values[1];
776 }
777 }
778 }
779
780 void move(const scalar_unit& new_x)
781 {
782 if (values.size() == 1 and angles.size() == 0)
783 {
784 values[0] += new_x;
785 }
786 }
787
789 {
790 if (values.size() == 2 and angles.size() == 1)
791 {
792 values[0] += x_displacement.x_projection();
793 values[1] += x_displacement.y_projection();
794 }
795 }
796
798 {
799 if (values.size() == 2 and angles.size() == 1)
800 {
801 values[0] += new_x;
802 values[1] += new_y;
803 }
804 }
805
807 {
808 if (values.size() == 2 and angles.size() == 1)
809 {
812 }
813 }
814
816 {
817 if (values.size() == 3 and angles.size() == 2)
818 {
819 values[0] += x_displacement.x_projection();
820 values[1] += x_displacement.y_projection();
821 values[2] += x_displacement.z_projection();
822 }
823 }
824
826 {
827 if (values.size() == 3 and angles.size() == 2)
828 {
829 values[0] += new_x;
830 values[1] += new_y;
831 values[2] += new_z;
832 }
833 }
834
836 {
837 if (values.size() == 3 and angles.size() == 2)
838 {
839 new_z.change_dimensions(new_p);
842 values[2] += new_z;
843 }
844 }
845
846 void move(const scalar_unit& new_r,const angle& new_theta,const angle& new_phi)
847 {
848 if (values.size() == 3 and angles.size() == 2)
849 {
852 values[2] += T(new_r * scifir::cos(new_phi));
853 }
854 }
855
857 {
858 if (x_displacement.get_nd() == get_nd())
859 {
860 for (int i = 0; i < x_displacement.get_nd(); i++)
861 {
862 values[i] += x_displacement.n_projection(i);
863 }
864 }
865 }
866
872
874 {
875 scalar_unit x_T = scalar_unit(0.0f,"m2");
876 for (int i = 0; i < values.size(); i++)
877 {
878 x_T += scifir::pow(values[i],2);
879 }
880 return T(scifir::sqrt(x_T));
881 }
882
883 string display_cartesian_2d() const
884 {
885 if (values.size() == 2 and angles.size() == 1)
886 {
888 out << "(";
889 if (get_nd() == 2)
890 {
891 out << values[0] << "," << values[1] << ";" << angles[0];
892 }
893 out << ")";
894 return out.str();
895 }
896 else
897 {
898 return "[no-2d]";
899 }
900 }
901
902 string display_polar() const
903 {
904 if (values.size() == 2 and angles.size() == 1)
905 {
907 out << "(";
908 if (get_nd() == 2)
909 {
910 out << get_p() << "," << get_spherical_theta() << ";" << angles[0];
911 }
912 out << ")";
913 return out.str();
914 }
915 else
916 {
917 return "[no-2d]";
918 }
919 }
920
921 string display_cartesian_3d() const
922 {
923 if (values.size() == 3 and angles.size() == 2)
924 {
926 out << "(";
927 if (get_nd() == 3)
928 {
929 out << values[0] << "," << values[1] << "," << values[2] << ";" << angles[0] << "," << angles[1];
930 }
931 out << ")";
932 return out.str();
933 }
934 else
935 {
936 return "[no-3d]";
937 }
938 }
939
940 string display_cylindrical() const
941 {
942 if (values.size() == 3 and angles.size() == 2)
943 {
945 out << "(";
946 if (get_nd() == 3)
947 {
948 out << get_p() << "," << get_spherical_theta() << "," << values[2] << ";" << angles[0] << "," << angles[1];
949 }
950 out << ")";
951 return out.str();
952 }
953 else
954 {
955 return "[no-3d]";
956 }
957 }
958
959 string display_spherical() const
960 {
961 if (values.size() == 3 and angles.size() == 2)
962 {
964 out << "(";
965 if (get_nd() == 3)
966 {
967 out << get_r() << "," << get_spherical_theta() << "," << get_spherical_phi() << ";" << angles[0] << "," << angles[1];
968 }
969 out << ")";
970 return out.str();
971 }
972 else
973 {
974 return "[no-3d]";
975 }
976 }
977
978 string display_geographical() const
979 {
980 if (values.size() == 3 and angles.size() == 2)
981 {
983 out << "(";
984 if (get_nd() == 3)
985 {
986 out << get_latitude() << "," << get_longitude() << "," << get_altitude() << ";" << angles[0] << "," << angles[1];
987 }
988 out << ")";
989 return out.str();
990 }
991 else
992 {
993 return "[no-3d]";
994 }
995 }
996
997 private:
1000 static T no_value;
1001
1003 {
1007 if (init_coordinates_ndr.front() == '(')
1008 {
1009 init_coordinates_ndr.erase(0,1);
1010 }
1011 if (init_coordinates_ndr.back() == ')')
1012 {
1014 }
1015 boost::split(init_coordinates,init_coordinates_ndr,boost::is_any_of(";"));
1016 if (init_coordinates.size() > 0)
1017 {
1018 boost::split(init_values,init_coordinates[0],boost::is_any_of(","));
1019 }
1020 if (init_coordinates.size() > 1)
1021 {
1022 boost::split(init_angles,init_coordinates[1],boost::is_any_of(","));
1023 }
1024 for (const string& x_value : init_values)
1025 {
1026 if (x_value == "")
1027 {
1028 return;
1029 }
1030 }
1031 for (const string& x_value : init_angles)
1032 {
1033 if (x_value == "")
1034 {
1035 return;
1036 }
1037 }
1038 if (init_values.size() == 2 and init_angles.size() == 1)
1039 {
1040 if (is_angle(init_values[1]))
1041 {
1042 values.push_back(T(T(init_values[0]) * scifir::cos(angle(init_values[1]))));
1043 values.push_back(T(T(init_values[0]) * scifir::sin(angle(init_values[1]))));
1044 }
1045 else
1046 {
1047 values.push_back(T(init_values[0]));
1048 values.push_back(T(init_values[1]));
1049 }
1050 angles.push_back(angle(init_angles[0]));
1051 }
1052 else if (init_values.size() == 3 and init_angles.size() == 2)
1053 {
1054 if (is_latitude(init_values[0]))
1055 {
1056 if (is_longitude(init_values[1]))
1057 {
1058 if (!is_angle(init_values[2]))
1059 {
1062 values.push_back(T(T(init_values[2]) * scifir::sin(angle(init_values[0]))));
1063 }
1064 }
1065 }
1066 else
1067 {
1068 if (is_angle(init_values[1]))
1069 {
1070 if (is_angle(init_values[2]))
1071 {
1074 values.push_back(T(T(init_values[0]) * scifir::cos(angle(init_values[2]))));
1075 }
1076 else
1077 {
1078 values.push_back(T(T(init_values[0]) * scifir::cos(angle(init_values[1]))));
1079 values.push_back(T(T(init_values[0]) * scifir::sin(angle(init_values[1]))));
1080 values.push_back(T(init_values[2]));
1081 }
1082 }
1083 else
1084 {
1085 if (!is_angle(init_values[2]))
1086 {
1087 values.push_back(T(init_values[0]));
1088 values.push_back(T(init_values[1]));
1089 values.push_back(T(init_values[2]));
1090 }
1091 }
1092 }
1093 angles.push_back(angle(init_angles[0]));
1094 angles.push_back(angle(init_angles[1]));
1095 }
1096 else
1097 {
1098 if (init_values.size() == (init_angles.size() + 1))
1099 {
1100 for (int i = 0; i < init_values.size(); i++)
1101 {
1102 values.push_back(T(init_values[i]));
1103 }
1104 for (int i = 0; i < init_angles.size(); i++)
1105 {
1106 angles.push_back(angle(init_angles[i]));
1107 }
1108 }
1109 }
1110 }
1111 };
1112
1113 template<typename T>
1115
1116 template<>
1118 {
1119 public:
1122
1124 {
1125 if (x.values.size() == (x.angles.size() + 1))
1126 {
1127 values = x.values;
1128 angles = x.angles;
1129 }
1130 }
1131
1133 {
1134 if (x.values.size() == (x.angles.size() + 1))
1135 {
1136 values = std::move(x.values);
1137 angles = std::move(x.angles);
1138 }
1139 }
1140
1142 {
1143 if (new_values.size() == (new_angles.size() + 1))
1144 {
1146 for(const float& x_angle : new_angles)
1147 {
1148 angles.push_back(angle(x_angle));
1149 }
1150 }
1151 }
1152
1154 {
1155 if (new_values.size() == (new_angles.size() + 1))
1156 {
1159 }
1160 }
1161
1162 explicit coordinates_ndr(float new_x) : values(),angles()
1163 {
1164 values.push_back(new_x);
1165 }
1166
1167 explicit coordinates_ndr(float new_x,float new_y,const angle& new_theta) : values(),angles()
1168 {
1169 values.push_back(new_x);
1170 values.push_back(new_y);
1171 angles.push_back(new_theta);
1172 }
1173
1175 {
1178 angles.push_back(new_theta);
1179 }
1180
1181 explicit coordinates_ndr(float new_x,float new_y,float new_z,const angle& new_theta,const angle& new_phi) : values(),angles()
1182 {
1183 values.push_back(new_x);
1184 values.push_back(new_y);
1185 values.push_back(new_z);
1186 angles.push_back(new_theta);
1187 angles.push_back(new_phi);
1188 }
1189
1191 {
1194 values.push_back(new_z);
1195 angles.push_back(new_theta);
1196 angles.push_back(new_phi);
1197 }
1198
1207
1216
1218 {
1219 if (new_coordinates.values.size() == (new_angles.size() + 1))
1220 {
1221 values = new_coordinates.values;
1222 for(const float& x_angle : new_angles)
1223 {
1224 angles.push_back(angle(x_angle));
1225 }
1226 }
1227 }
1228
1230 {
1231 if (new_coordinates.values.size() == (new_angles.size() + 1))
1232 {
1233 values = std::move(new_coordinates.values);
1234 for(const float& x_angle : new_angles)
1235 {
1236 angles.push_back(angle(x_angle));
1237 }
1238 }
1239 }
1240
1242 {
1243 if (new_coordinates.values.size() == (new_angles.size() + 1))
1244 {
1245 values = new_coordinates.values;
1247 }
1248 }
1249
1251 {
1252 if (new_coordinates.values.size() == (new_angles.size() + 1))
1253 {
1254 values = std::move(new_coordinates.values);
1256 }
1257 }
1258
1263
1265 {
1266 if (x_coordinates.values.size() == (x_coordinates.angles.size() + 1))
1267 {
1268 values = x_coordinates.values;
1269 angles = x_coordinates.angles;
1270 }
1271 return *this;
1272 }
1273
1275 {
1276 if (x_coordinates.values.size() == (x_coordinates.angles.size() + 1))
1277 {
1278 values = std::move(x_coordinates.values);
1279 angles = std::move(x_coordinates.angles);
1280 }
1281 return *this;
1282 }
1283
1285 {
1286 if (x_coordinates.values.size() == (angles.size() + 1))
1287 {
1288 values = x_coordinates.values;
1289 }
1290 return *this;
1291 }
1292
1294 {
1295 if (x_coordinates.values.size() == (angles.size() + 1))
1296 {
1297 values = std::move(x_coordinates.values);
1298 }
1299 return *this;
1300 }
1301
1307
1308 bool is_nd(unsigned int i) const
1309 {
1310 return values.size() == i;
1311 }
1312
1313 int get_nd() const
1314 {
1315 return values.size();
1316 }
1317
1319 {
1320 if (new_values.size() == (new_angles.size() + 1))
1321 {
1323 angles.clear();
1324 for(const float& x_angle : new_angles)
1325 {
1326 angles.push_back(angle(x_angle));
1327 }
1328 }
1329 }
1330
1332 {
1333 if (new_values.size() == (new_angles.size() + 1))
1334 {
1337 }
1338 }
1339
1341 {
1342 return values;
1343 }
1344
1346 {
1347 if (values.size() == new_values.size())
1348 {
1350 }
1351 }
1352
1353 const float& get_value(unsigned int i) const
1354 {
1355 if (i < (values.size()))
1356 {
1357 return values[i];
1358 }
1359 else
1360 {
1361 return no_value;
1362 }
1363 }
1364
1365 float& get_value(unsigned int i)
1366 {
1367 if (i < (values.size()))
1368 {
1369 return values[i];
1370 }
1371 else
1372 {
1373 return no_value;
1374 }
1375 }
1376
1378 {
1379 return angles;
1380 }
1381
1383 {
1384 if (values.size() == (new_angles.size() + 1))
1385 {
1386 angles.clear();
1387 for(const float& x_angle : new_angles)
1388 {
1389 angles.push_back(angle(x_angle));
1390 }
1391 }
1392 }
1393
1395 {
1396 if (values.size() == (new_angles.size() + 1))
1397 {
1399 }
1400 }
1401
1402 const angle& get_angle(unsigned int i) const
1403 {
1404 if (i < (values.size() - 1))
1405 {
1406 return angles[i];
1407 }
1408 else
1409 {
1411 }
1412 }
1413
1414 angle& get_angle(unsigned int i)
1415 {
1416 if (i < (values.size() - 1))
1417 {
1418 return angles[i];
1419 }
1420 else
1421 {
1423 }
1424 }
1425
1426 float get_p() const
1427 {
1428 if (get_nd() == 2 or get_nd() == 3)
1429 {
1430 return float(std::sqrt(std::pow(values[0],2) + std::pow(values[1],2)));
1431 }
1432 else
1433 {
1434 return float();
1435 }
1436 }
1437
1439 {
1440 if (get_nd() == 2 or get_nd() == 3)
1441 {
1442 return angle(scifir::atan_degree(float(values[1]/values[0])));
1443 }
1444 else
1445 {
1446 return angle();
1447 }
1448 }
1449
1450 float get_r() const
1451 {
1452 if (get_nd() == 2 or get_nd() == 3)
1453 {
1454 return float(std::sqrt(std::pow(values[0],2) + std::pow(values[1],2) + std::pow(values[2],2)));
1455 }
1456 else
1457 {
1458 return float();
1459 }
1460 }
1461
1463 {
1464 if (get_nd() == 3)
1465 {
1466 return angle(scifir::acos_degree(float(values[2]/std::sqrt(std::pow(values[0],2) + std::pow(values[1],2) + std::pow(values[2],2)))));
1467 }
1468 else
1469 {
1470 return angle();
1471 }
1472 }
1473
1475 {
1476 if (get_nd() == 3)
1477 {
1478 return ECEF_to_LLA_latitude(values[0],values[1],values[2]);
1479 }
1480 else
1481 {
1482 return latitude();
1483 }
1484 }
1485
1487 {
1488 if (get_nd() == 3)
1489 {
1490 return ECEF_to_LLA_longitude(values[0],values[1],values[2]);
1491 }
1492 else
1493 {
1494 return longitude();
1495 }
1496 }
1497
1498 float get_altitude() const
1499 {
1500 if (get_nd() == 3)
1501 {
1502 return ECEF_to_LLA_altitude(values[0],values[1],values[2]);
1503 }
1504 else
1505 {
1506 return 0.0f;
1507 }
1508 }
1509
1511 {
1512 if (is_nd(1))
1513 {
1514 if (x == direction::LEFT)
1515 {
1516 if (values[0] > 0)
1517 {
1518 values[0] *= -1;
1519 }
1520 }
1521 else if(x == direction::RIGHT)
1522 {
1523 if (values[0] < 0)
1524 {
1525 values[0] *= -1;
1526 }
1527 }
1528 }
1529 else if (is_nd(2))
1530 {
1531 if (x == direction::LEFT)
1532 {
1533 angles[0] = 180.0f;
1534 }
1535 else if(x == direction::RIGHT)
1536 {
1537 angles[0] = 0.0f;
1538 }
1539 else if(x == direction::TOP)
1540 {
1541 angles[0] = 90.0f;
1542 }
1543 else if(x == direction::BOTTOM)
1544 {
1545 angles[0] = 270.0f;
1546 }
1547 else if(x == direction::LEFT_TOP)
1548 {
1549 angles[0] = 135.0f;
1550 }
1551 else if(x == direction::RIGHT_TOP)
1552 {
1553 angles[0] = 45.0f;
1554 }
1555 else if(x == direction::RIGHT_BOTTOM)
1556 {
1557 angles[0] = 315.0f;
1558 }
1559 else if(x == direction::LEFT_BOTTOM)
1560 {
1561 angles[0] = 225.0f;
1562 }
1563 }
1564 else if (is_nd(3))
1565 {
1566 if (x == direction::LEFT)
1567 {
1568 angles[0] = 270.0f;
1569 angles[1] = 90.0f;
1570 }
1571 else if(x == direction::RIGHT)
1572 {
1573 angles[0] = 90.0f;
1574 angles[1] = 90.0f;
1575 }
1576 else if(x == direction::TOP)
1577 {
1578 angles[0] = 0.0f;
1579 angles[1] = 0.0f;
1580 }
1581 else if(x == direction::BOTTOM)
1582 {
1583 angles[0] = 0.0f;
1584 angles[1] = 180.0f;
1585 }
1586 else if(x == direction::LEFT_TOP)
1587 {
1588 angles[0] = 270.0f;
1589 angles[1] = 45.0f;
1590 }
1591 else if(x == direction::RIGHT_TOP)
1592 {
1593 angles[0] = 90.0f;
1594 angles[1] = 45.0f;
1595 }
1596 else if(x == direction::RIGHT_BOTTOM)
1597 {
1598 angles[0] = 90.0f;
1599 angles[1] = 135.0f;
1600 }
1601 else if(x == direction::LEFT_BOTTOM)
1602 {
1603 angles[0] = 270.0f;
1604 angles[1] = 135.0f;
1605 }
1606 else if(x == direction::FRONT)
1607 {
1608 angles[0] = 0.0f;
1609 angles[1] = 90.0f;
1610 }
1611 else if(x == direction::BACK)
1612 {
1613 angles[0] = 180.0f;
1614 angles[1] = 90.0f;
1615 }
1616 else if(x == direction::LEFT_FRONT)
1617 {
1618 angles[0] = 315.0f;
1619 angles[1] = 90.0f;
1620 }
1621 else if(x == direction::RIGHT_FRONT)
1622 {
1623 angles[0] = 45.0f;
1624 angles[1] = 90.0f;
1625 }
1626 else if(x == direction::TOP_FRONT)
1627 {
1628 angles[0] = 0.0f;
1629 angles[1] = 45.0f;
1630 }
1631 else if(x == direction::BOTTOM_FRONT)
1632 {
1633 angles[0] = 0.0f;
1634 angles[1] = 135.0f;
1635 }
1636 else if(x == direction::LEFT_BACK)
1637 {
1638 angles[0] = 225.0f;
1639 angles[1] = 90.0f;
1640 }
1641 else if(x == direction::RIGHT_BACK)
1642 {
1643 angles[0] = 135.0f;
1644 angles[1] = 90.0f;
1645 }
1646 else if(x == direction::TOP_BACK)
1647 {
1648 angles[0] = 180.0f;
1649 angles[1] = 45.0f;
1650 }
1651 else if(x == direction::BOTTOM_BACK)
1652 {
1653 angles[0] = 180.0f;
1654 angles[1] = 135.0f;
1655 }
1656 else if(x == direction::LEFT_TOP_FRONT)
1657 {
1658 angles[0] = 315.0f;
1659 angles[1] = 45.0f;
1660 }
1661 else if(x == direction::RIGHT_TOP_FRONT)
1662 {
1663 angles[0] = 45.0f;
1664 angles[1] = 45.0f;
1665 }
1666 else if(x == direction::LEFT_BOTTOM_FRONT)
1667 {
1668 angles[0] = 315.0f;
1669 angles[1] = 135.0f;
1670 }
1671 else if(x == direction::RIGHT_BOTTOM_FRONT)
1672 {
1673 angles[0] = 45.0f;
1674 angles[1] = 135.0f;
1675 }
1676 else if(x == direction::LEFT_TOP_BACK)
1677 {
1678 angles[0] = 225.0f;
1679 angles[1] = 45.0f;
1680 }
1681 else if(x == direction::RIGHT_TOP_BACK)
1682 {
1683 angles[0] = 135.0f;
1684 angles[1] = 45.0f;
1685 }
1686 else if(x == direction::LEFT_BOTTOM_BACK)
1687 {
1688 angles[0] = 225.0f;
1689 angles[1] = 135.0f;
1690 }
1691 else if(x == direction::RIGHT_BOTTOM_BACK)
1692 {
1693 angles[0] = 135.0f;
1694 angles[1] = 135.0f;
1695 }
1696 }
1697 }
1698
1700 {
1701 if (values.size() == 1 and angles.size() == 0)
1702 {
1703 values.clear();
1704 values.push_back(new_x);
1705 }
1706 }
1707
1708 void set_position(float new_x,float new_y)
1709 {
1710 if (values.size() == 2 and angles.size() == 1)
1711 {
1712 values.clear();
1713 values.push_back(new_x);
1714 values.push_back(new_y);
1715 }
1716 }
1717
1719 {
1720 if (values.size() == 2 and angles.size() == 1)
1721 {
1722 values.clear();
1723 values.push_back(new_p * scifir::cos(new_theta));
1724 values.push_back(new_p * scifir::sin(new_theta));
1725 }
1726 }
1727
1728 void set_position(float new_x,float new_y,float new_z)
1729 {
1730 if (values.size() == 3 and angles.size() == 2)
1731 {
1732 values.clear();
1733 values.push_back(new_x);
1734 values.push_back(new_y);
1735 values.push_back(new_z);
1736 }
1737 }
1738
1739 void set_position(float new_p,const angle& new_theta,float new_z)
1740 {
1741 if (values.size() == 3 and angles.size() == 2)
1742 {
1743 values.clear();
1744 values.push_back(new_p * scifir::cos(new_theta));
1745 values.push_back(new_p * scifir::sin(new_theta));
1746 values.push_back(new_z);
1747 }
1748 }
1749
1750 void set_position(float new_r,const angle& new_theta,const angle& new_phi)
1751 {
1752 if (values.size() == 3 and angles.size() == 2)
1753 {
1754 values.clear();
1757 values.push_back(new_r * scifir::cos(new_phi));
1758 }
1759 }
1760
1762 {
1763 if (values.size() == 3 and angles.size() == 2)
1764 {
1765 values.clear();
1769 }
1770 }
1771
1773 {
1774 values.clear();
1776 }
1777
1779 {
1780 if (get_nd() == 2)
1781 {
1782 float x_coord = values[0];
1783 float y_coord = values[1];
1786 }
1787 }
1788
1790 {
1791 if (get_nd() == 3)
1792 {
1793 if (axis == 1)
1794 {
1795 float y_coord = values[1];
1796 float z_coord = values[2];
1799 }
1800 else if (axis == 2)
1801 {
1802 float x_coord = values[0];
1803 float z_coord = values[2];
1806 }
1807 else if (axis == 3)
1808 {
1809 float x_coord = values[0];
1810 float y_coord = values[1];
1813 }
1814 }
1815 }
1816
1817 void move(float new_x)
1818 {
1819 if (values.size() == 1 and angles.size() == 0)
1820 {
1821 values[0] += new_x;
1822 }
1823 }
1824
1826 {
1827 if (values.size() == 2 and angles.size() == 1)
1828 {
1829 values[0] += float(x_displacement.x_projection());
1830 values[1] += float(x_displacement.y_projection());
1831 }
1832 }
1833
1834 void move(float new_x,float new_y)
1835 {
1836 if (values.size() == 2 and angles.size() == 1)
1837 {
1838 values[0] += new_x;
1839 values[1] += new_y;
1840 }
1841 }
1842
1843 void move(float new_p,const angle& new_theta)
1844 {
1845 if (values.size() == 2 and angles.size() == 1)
1846 {
1849 }
1850 }
1851
1853 {
1854 if (values.size() == 3 and angles.size() == 2)
1855 {
1856 values[0] += float(x_displacement.x_projection());
1857 values[1] += float(x_displacement.y_projection());
1858 values[2] += float(x_displacement.z_projection());
1859 }
1860 }
1861
1862 void move(float new_x,float new_y,float new_z)
1863 {
1864 if (values.size() == 3 and angles.size() == 2)
1865 {
1866 values[0] += new_x;
1867 values[1] += new_y;
1868 values[2] += new_z;
1869 }
1870 }
1871
1872 void move(float new_p,const angle& new_theta,float new_z)
1873 {
1874 if (values.size() == 3 and angles.size() == 2)
1875 {
1878 values[2] += new_z;
1879 }
1880 }
1881
1882 void move(float new_r,const angle& new_theta,const angle& new_phi)
1883 {
1884 if (values.size() == 3 and angles.size() == 2)
1885 {
1889 }
1890 }
1891
1893 {
1894 if (x_displacement.get_nd() == get_nd())
1895 {
1896 for (int i = 0; i < x_displacement.get_nd(); i++)
1897 {
1898 values[i] += float(x_displacement.n_projection(i));
1899 }
1900 }
1901 }
1902
1908
1910 {
1911 float x_T = 0;
1912 for (unsigned int i = 0; i < values.size(); i++)
1913 {
1914 x_T += float(std::pow(values[i],2));
1915 }
1916 return std::sqrt(x_T);
1917 }
1918
1920 {
1921 if (values.size() == 2 and angles.size() == 1)
1922 {
1924 out << "(";
1925 if (get_nd() == 2)
1926 {
1927 out << display_float(values[0]) << "," << display_float(values[1]) << ";" << angles[0];
1928 }
1929 out << ")";
1930 return out.str();
1931 }
1932 else
1933 {
1934 return "[no-2d]";
1935 }
1936 }
1937
1938 string display_polar() const
1939 {
1940 if (values.size() == 2 and angles.size() == 1)
1941 {
1943 out << "(";
1944 if (get_nd() == 2)
1945 {
1946 out << display_float(get_p()) << "," << get_spherical_theta() << ";" << angles[0];
1947 }
1948 out << ")";
1949 return out.str();
1950 }
1951 else
1952 {
1953 return "[no-2d]";
1954 }
1955 }
1956
1958 {
1959 if (values.size() == 3 and angles.size() == 2)
1960 {
1962 out << "(";
1963 if (get_nd() == 3)
1964 {
1965 out << display_float(values[0]) << "," << display_float(values[1]) << "," << display_float(values[2]) << ";" << angles[0] << "," << angles[1];
1966 }
1967 out << ")";
1968 return out.str();
1969 }
1970 else
1971 {
1972 return "[no-3d]";
1973 }
1974 }
1975
1976 string display_cylindrical() const
1977 {
1978 if (values.size() == 3 and angles.size() == 2)
1979 {
1981 out << "(";
1982 if (get_nd() == 3)
1983 {
1984 out << display_float(get_p()) << "," << get_spherical_theta() << "," << display_float(values[2]) << ";" << angles[0] << "," << angles[1];
1985 }
1986 out << ")";
1987 return out.str();
1988 }
1989 else
1990 {
1991 return "[no-3d]";
1992 }
1993 }
1994
1995 string display_spherical() const
1996 {
1997 if (values.size() == 3 and angles.size() == 2)
1998 {
2000 out << "(";
2001 if (get_nd() == 3)
2002 {
2003 out << display_float(get_r()) << "," << get_spherical_theta() << "," << get_spherical_phi() << ";" << angles[0] << "," << angles[1];
2004 }
2005 out << ")";
2006 return out.str();
2007 }
2008 else
2009 {
2010 return "[no-3d]";
2011 }
2012 }
2013
2015 {
2016 if (values.size() == 3 and angles.size() == 2)
2017 {
2019 out << "(";
2020 if (get_nd() == 3)
2021 {
2022 out << get_latitude() << "," << get_longitude() << "," << display_float(get_altitude()) << ";" << angles[0] << "," << angles[1];
2023 }
2024 out << ")";
2025 return out.str();
2026 }
2027 else
2028 {
2029 return "[no-3d]";
2030 }
2031 }
2032
2033 private:
2036 static float no_value;
2037
2039 {
2043 if (init_coordinates_ndr.front() == '(')
2044 {
2045 init_coordinates_ndr.erase(0,1);
2046 }
2047 if (init_coordinates_ndr.back() == ')')
2048 {
2050 }
2051 boost::split(init_coordinates,init_coordinates_ndr,boost::is_any_of(";"));
2052 if (init_coordinates.size() > 0)
2053 {
2054 boost::split(init_values,init_coordinates[0],boost::is_any_of(","));
2055 }
2056 if (init_coordinates.size() > 1)
2057 {
2058 boost::split(init_angles,init_coordinates[1],boost::is_any_of(","));
2059 }
2060 for (const string& x_value : init_values)
2061 {
2062 if (x_value == "")
2063 {
2064 return;
2065 }
2066 }
2067 for (const string& x_value : init_angles)
2068 {
2069 if (x_value == "")
2070 {
2071 return;
2072 }
2073 }
2074 if (init_values.size() == 2 and init_angles.size() == 1)
2075 {
2076 if (is_angle(init_values[1]))
2077 {
2078 values.push_back(stof(init_values[0]) * scifir::cos(angle(init_values[1])));
2079 values.push_back(stof(init_values[0]) * scifir::sin(angle(init_values[1])));
2080 }
2081 else
2082 {
2083 values.push_back(stof(init_values[0]));
2084 values.push_back(stof(init_values[1]));
2085 }
2086 angles.push_back(angle(init_angles[0]));
2087 }
2088 else if (init_values.size() == 3 and init_angles.size() == 2)
2089 {
2090 if (is_latitude(init_values[0]))
2091 {
2092 if (is_longitude(init_values[1]))
2093 {
2094 if (!is_angle(init_values[2]))
2095 {
2098 values.push_back(stof(init_values[2]) * scifir::sin(angle(init_values[0])));
2099 }
2100 }
2101 }
2102 else
2103 {
2104 if (is_angle(init_values[1]))
2105 {
2106 if (is_angle(init_values[2]))
2107 {
2110 values.push_back(stof(init_values[0]) * scifir::cos(angle(init_values[2])));
2111 }
2112 else
2113 {
2114 values.push_back(stof(init_values[0]) * scifir::cos(angle(init_values[1])));
2115 values.push_back(stof(init_values[0]) * scifir::sin(angle(init_values[1])));
2116 values.push_back(stof(init_values[2]));
2117 }
2118 }
2119 else
2120 {
2121 if (!is_angle(init_values[2]))
2122 {
2123 values.push_back(stof(init_values[0]));
2124 values.push_back(stof(init_values[1]));
2125 values.push_back(stof(init_values[2]));
2126 }
2127 }
2128 }
2129 angles.push_back(angle(init_angles[0]));
2130 angles.push_back(angle(init_angles[1]));
2131 }
2132 else
2133 {
2134 if (init_values.size() == (init_angles.size() + 1))
2135 {
2136 for (int i = 0; i < init_values.size(); i++)
2137 {
2138 values.push_back(stof(init_values[i]));
2139 }
2140 for (int i = 0; i < init_angles.size(); i++)
2141 {
2142 angles.push_back(angle(init_angles[i]));
2143 }
2144 }
2145 }
2146 }
2147 };
2148
2149 template<typename T>
2151 {
2152 if (x.get_values().size() > 0)
2153 {
2155 out << "(";
2156 if (x.get_values().size() > 0)
2157 {
2158 for (int i = 0; i < x.get_values().size(); i++)
2159 {
2160 out << x.get_value(i);
2161 if ((i + 1) != x.get_values().size())
2162 {
2163 out << ",";
2164 }
2165 }
2166 }
2167 if (x.get_angles().size() > 0)
2168 {
2169 out << ";";
2170 for (int i = 0; i < x.get_angles().size(); i++)
2171 {
2172 out << x.get_angle(i);
2173 if ((i + 1) != x.get_angles().size())
2174 {
2175 out << ",";
2176 }
2177 }
2178 }
2179 out << ")";
2180 return out.str();
2181 }
2182 else
2183 {
2184 return "[empty]";
2185 }
2186 }
2187
2188 string to_string(const coordinates_ndr<float>& x);
2189
2190 template<typename T,typename U>
2192 {
2193 if (x.get_nd() == y.get_nd())
2194 {
2195 scalar_unit x_length = scalar_unit(0.0f,"m2");
2196 for (int i = 0; i < x.get_values().size(); i++)
2197 {
2198 x_length += scifir::pow(x.get_value(i) - y.get_value(i),2);
2199 }
2200 return T(scifir::sqrt(x_length));
2201 }
2202 else
2203 {
2204 return T();
2205 }
2206 }
2207
2208 float distance(const coordinates_ndr<float>& x,const coordinates_ndr<float>& y);
2209
2210 template<typename T,typename U>
2212 {
2213 if (x.get_nd() == y.get_nd())
2214 {
2215 scalar_unit x_length = scalar_unit(0.0f,"m2");
2216 for (int i = 0; i < x.get_values().size(); i++)
2217 {
2218 x_length += scifir::pow(x.get_value(i) - y.values[i],2);
2219 }
2220 return T(scifir::sqrt(x_length));
2221 }
2222 else
2223 {
2224 return T();
2225 }
2226 }
2227
2228 float distance(const coordinates_ndr<float>& x,const coordinates_nd<float>& y);
2229
2230 template<typename T,typename U>
2232 {
2233 if (x.get_nd() == y.get_nd())
2234 {
2235 scalar_unit x_length = scalar_unit(0.0f,"m2");
2236 for (int i = 0; i < x.values.size(); i++)
2237 {
2238 x_length += scifir::pow(x.values[i] - y.get_value(i),2);
2239 }
2240 return T(scifir::sqrt(x_length));
2241 }
2242 else
2243 {
2244 return T();
2245 }
2246 }
2247
2248 float distance(const coordinates_nd<float>& x,const coordinates_ndr<float>& y);
2249}
2250
2251template<typename T,typename U>
2253{
2254 for (int i = 0; i < x.get_values().size(); i++)
2255 {
2256 if (x.get_value(i) != y.get_value(i))
2257 {
2258 return false;
2259 }
2260 }
2261 for (int i = 0; i < x.get_angles().size(); i++)
2262 {
2263 if (x.get_angle(i) != y.get_angle(i))
2264 {
2265 return false;
2266 }
2267 }
2268 return true;
2269}
2270
2271template<typename T,typename U>
2273{
2274 return !(x == y);
2275}
2276
2277template<typename T,typename U>
2279{
2280 if (x.get_values().size() == y.values.size())
2281 {
2282 for (int i = 0 ; i < x.get_values().size(); i++)
2283 {
2284 if (x.get_value(i) != y.values[i])
2285 {
2286 return false;
2287 }
2288 }
2289 return true;
2290 }
2291 else
2292 {
2293 return false;
2294 }
2295}
2296
2297template<typename T,typename U>
2299{
2300 return !(x == y);
2301}
2302
2303template<typename T,typename U>
2305{
2306 if (x.values.size() == y.get_values().size())
2307 {
2308 for (int i = 0 ; i < x.values.size(); i++)
2309 {
2310 if (x.values[i] != y.get_value(i))
2311 {
2312 return false;
2313 }
2314 }
2315 return true;
2316 }
2317 else
2318 {
2319 return false;
2320 }
2321}
2322
2323template<typename T,typename U>
2325{
2326 return !(x == y);
2327}
2328
2329template<typename T>
2330bool operator ==(const scifir::coordinates_ndr<T>& x, const string& init_coordinates_ndr)
2331{
2332 scifir::coordinates_ndr<T> y(init_coordinates_ndr);
2333 return (x == y);
2334}
2335
2336template<typename T>
2337bool operator !=(const scifir::coordinates_ndr<T>& x, const string& init_coordinates_ndr)
2338{
2339 return !(x == init_coordinates_ndr);
2340}
2341
2342template<typename T>
2343bool operator ==(const string& init_coordinates_ndr, const scifir::coordinates_ndr<T>& x)
2344{
2345 scifir::coordinates_ndr<T> y(init_coordinates_ndr);
2346 return (x == y);
2347}
2348
2349template<typename T>
2350bool operator !=(const string& init_coordinates_ndr, const scifir::coordinates_ndr<T>& x)
2351{
2352 return !(init_coordinates_ndr == x);
2353}
2354
2355template<typename T>
2357{
2358 x += to_string(y);
2359}
2360
2361template<typename T>
2362string operator +(const string& x,const scifir::coordinates_ndr<T>& y)
2363{
2364 return x + to_string(y);
2365}
2366
2367template<typename T>
2368string operator +(const scifir::coordinates_ndr<T>& x,const string& y)
2369{
2370 return to_string(x) + y;
2371}
2372
2373template<typename T>
2374ostream& operator <<(ostream& os,const scifir::coordinates_ndr<T>& x)
2375{
2376 return os << to_string(x);
2377}
2378
2379ostream& operator <<(ostream& os,const scifir::coordinates_ndr<float>& x);
2380
2381template<typename T>
2383{
2384 char a[256];
2385 is.getline(a, 256);
2386 string b(a);
2387 boost::trim(b);
2389 return is;
2390}
2391
2392#endif // SCIFIR_UNITS_COORDINATES_COORDINATES_NDR_HPP_INCLUDED
Class that allows to work with angles. Each angle sizes 4 bytes. Initialization string example: "20°"...
Definition angle.hpp:77
coordinates_ndr(const vector< float > &new_values, const vector< angle > &new_angles)
void rotate_in_2d(const angle &new_theta)
void move(float new_x, float new_y)
coordinates_ndr(coordinates_nd< float > &&new_coordinates, const vector< angle > &new_angles)
const angle & get_angle(unsigned int i) const
void change_nd(const vector< float > &new_values, const vector< float > &new_angles)
void set_position(float new_p, const angle &new_theta)
coordinates_ndr(float new_r, const angle &new_spherical_theta, const angle &new_spherical_phi, const angle &new_theta, const angle &new_phi)
coordinates_ndr(coordinates_nd< float > &&new_coordinates, const vector< float > &new_angles)
coordinates_ndr(const coordinates_nd< float > &new_coordinates, const vector< angle > &new_angles)
coordinates_ndr(const vector< float > &new_values, const vector< float > &new_angles)
const vector< float > & get_values() const
coordinates_ndr(float new_p, const angle &new_polar_theta, const angle &new_theta)
void set_values(const vector< float > &new_values)
void move(float new_r, const vector< angle > &new_angles)
coordinates_ndr(const angle &new_latitude, const angle &new_longitude, float new_altitude, const angle &new_theta, const angle &new_phi)
void move(float new_r, const angle &new_theta, const angle &new_phi)
void set_angles(const vector< float > &new_angles)
void set_position(float new_x, float new_y)
coordinates_ndr(const string &init_coordinates_ndr)
const vector< angle > & get_angles() const
void set_angles(const vector< angle > &new_angles)
coordinates_ndr(float new_x, float new_y, float new_z, const angle &new_theta, const angle &new_phi)
void initialize_from_string(string init_coordinates_ndr)
const float & get_value(unsigned int i) const
void change_nd(const vector< float > &new_values, const vector< angle > &new_angles)
coordinates_ndr(const coordinates_nd< float > &new_coordinates, const vector< float > &new_angles)
coordinates_ndr(float new_p, const angle &new_cylindrical_theta, float new_z, const angle &new_theta, const angle &new_phi)
void set_position(float new_p, const angle &new_theta, float new_z)
void set_position(float new_x, float new_y, float new_z)
void move(float new_p, const angle &new_theta, float new_z)
void move(float new_p, const angle &new_theta)
coordinates_ndr(coordinates_ndr< float > &&x)
void move(float new_x, float new_y, float new_z)
void set_position(const angle &new_latitude, const angle &new_longitude, float new_altitude)
bool is_nd(unsigned int i) const
coordinates_ndr(const coordinates_ndr< float > &x)
void move(const displacement_3d &x_displacement)
coordinates_ndr(float new_x, float new_y, const angle &new_theta)
void move(const displacement_2d &x_displacement)
void move(const displacement_nd &x_displacement)
void set_position(const vector< float > &new_values)
void set_position(float new_r, const angle &new_theta, const angle &new_phi)
void rotate_in_3d(int axis, const angle &new_theta)
coordinates_ndr(const vector< U > &new_values, const vector< angle > &new_angles)
void change_nd(const vector< scalar_unit > &new_values, const vector< angle > &new_angles)
coordinates_ndr(const scalar_unit &new_p, const angle &new_polar_theta, const angle &new_theta)
void move(const displacement_nd &x_displacement)
void initialize_from_string(string init_coordinates_ndr)
const angle & get_angle(int i) const
void set_position(const scalar_unit &new_x)
coordinates_ndr(coordinates_nd< U > &&new_coordinates, const vector< float > &new_angles)
coordinates_ndr(const coordinates_nd< U > &new_coordinates, const vector< angle > &new_angles)
string display_geographical() const
const vector< angle > & get_angles() const
coordinates_ndr(const scalar_unit &new_x, const scalar_unit &new_y, const angle &new_theta)
coordinates_ndr(const vector< U > &new_values, const vector< float > &new_angles)
void set_position(const scalar_unit &new_p, const angle &new_theta)
string display_cylindrical() const
coordinates_ndr(coordinates_ndr< T > &&x)
coordinates_ndr(const scalar_unit &new_p, const angle &new_cylindrical_theta, scalar_unit new_z, const angle &new_theta, const angle &new_phi)
void set_position(const scalar_unit &new_p, const angle &new_theta, scalar_unit new_z)
void move(const scalar_unit &new_p, const angle &new_theta, scalar_unit new_z)
coordinates_ndr(const coordinates_nd< U > &new_coordinates, const vector< float > &new_angles)
void move(const scalar_unit &new_r, const vector< angle > &new_angles)
coordinates_ndr< T > & operator=(const coordinates_ndr< T > &x_coordinates)
string display_cartesian_3d() const
void move(const scalar_unit &new_x)
void move(const displacement_3d &x_displacement)
void point_to(direction::name x)
scalar_unit get_altitude() const
void rotate_in_3d(int axis, const angle &new_theta)
static coordinates_ndr< T > origin(const coordinates_ndr< T > &origin, const coordinates_ndr< T > &coordinates)
void set_angles(const vector< angle > &new_angles)
void set_position(const angle &new_latitude, const angle &new_longitude, const scalar_unit &new_altitude)
void change_nd(const vector< scalar_unit > &new_values, const vector< float > &new_angles)
latitude get_latitude() const
coordinates_ndr(const scalar_unit &new_x, const scalar_unit &new_y, const scalar_unit &new_z, const angle &new_theta, const angle &new_phi)
coordinates_ndr(const angle &new_latitude, const angle &new_longitude, const scalar_unit &new_altitude, const angle &new_theta, const angle &new_phi)
void set_position(const scalar_unit &new_x, const scalar_unit &new_y, const scalar_unit &new_z)
coordinates_ndr(coordinates_nd< U > &&new_coordinates, const vector< angle > &new_angles)
void move(const displacement_2d &x_displacement)
void set_angles(const vector< float > &new_angles)
coordinates_ndr(const string &init_coordinates_ndr)
coordinates_ndr(const scalar_unit &new_x)
void rotate_in_2d(const angle &new_theta)
void move(const scalar_unit &new_x, const scalar_unit &new_y, const scalar_unit &new_z)
void move(const scalar_unit &new_r, const angle &new_theta, const angle &new_phi)
coordinates_ndr(const scalar_unit &new_r, const angle &new_spherical_theta, const angle &new_spherical_phi, const angle &new_theta, const angle &new_phi)
void move(const scalar_unit &new_x, const scalar_unit &new_y)
coordinates_ndr(const coordinates_ndr< T > &x)
void set_values(const vector< scalar_unit > &new_values)
void set_position(const vector< scalar_unit > &new_values)
void set_position(const scalar_unit &new_r, const angle &new_theta, const angle &new_phi)
string display_cartesian_2d() const
const vector< T > & get_values() const
longitude get_longitude() const
void move(const scalar_unit &new_p, const angle &new_theta)
void set_position(const scalar_unit &new_x, const scalar_unit &new_y)
const T & get_value(int i) const
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
void operator+=(string &x, const scifir::coordinates_ndr< T > &y)
istream & operator>>(istream &is, scifir::coordinates_ndr< T > &x)
bool operator!=(const scifir::coordinates_ndr< T > &x, const scifir::coordinates_ndr< U > &y)
bool operator==(const scifir::coordinates_ndr< T > &x, const scifir::coordinates_ndr< U > &y)
ostream & operator<<(ostream &os, const scifir::coordinates_ndr< T > &x)
string operator+(const string &x, const scifir::coordinates_ndr< T > &y)
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
Definition address.cpp:6
bool is_latitude(const string &init_latitude)
Definition latitude.cpp:199
scalar_unit ECEF_to_LLA_altitude(const scalar_unit &x, scalar_unit y, const scalar_unit &z)
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
scalar_unit pow(const scalar_unit &x, int exponent)
Exponentiates a scalar_unit to some numeric type, the dimensions are also exponentiated.
bool is_longitude(const string &init_longitude)
float atan_degree(float x)
Calculates the atan receiving x in degrees. It uses the atan() function of the standard library of C+...
Definition angle.hpp:252
longitude ECEF_to_LLA_longitude(const scalar_unit &x, scalar_unit y, const scalar_unit &z)
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
float distance(const coordinates_1d< float > &x, const coordinates_1d< float > &y)
string display_float(const float &value, int number_of_decimals)
Definition types.cpp:36
float acos_degree(float x)
Calculates the acos receiving x in degrees. It uses the acos() function of the standard library of C+...
Definition angle.hpp:247
angle coordinates_ndr_no_angle
latitude ECEF_to_LLA_latitude(const scalar_unit &x, scalar_unit y, const scalar_unit &z)
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 is_angle(const string &init_angle)
Checks if some string is an initialization string of an angle.
Definition angle.cpp:336