GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 4 / 0 / 4
Functions: 100.0% 4 / 0 / 4
Branches: 100.0% 4 / 0 / 4

src/utilities/geometry/Vector3d.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef UTILITIES_GEOMETRY_VECTOR3D_HPP
7 #define UTILITIES_GEOMETRY_VECTOR3D_HPP
8
9 #include "../UtilitiesAPI.hpp"
10 #include "../data/Vector.hpp"
11 #include "../core/Logger.hpp"
12
13 #include <vector>
14 #include <boost/optional.hpp>
15
16 namespace openstudio {
17
18 class UTILITIES_API Vector3d
19 {
20 public:
21 /// default constructor creates vector with 0, 0, 0
22 Vector3d();
23
24 /// constructor with x, y, z
25 Vector3d(double x, double y, double z);
26
27 // Copy and move operators are implicitly declared (Rule of 1), but we want the copy ctor for SWIG so we have to define all of them
28 3818772 Vector3d(const Vector3d& other) = default;
29 141857 Vector3d(Vector3d&& other) noexcept = default;
30
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 Vector3d& operator=(const Vector3d&) = default;
31
2/2
✓ Branch 1 taken 165413 times.
✓ Branch 4 taken 165413 times.
165413 Vector3d& operator=(Vector3d&&) noexcept = default;
32 // ~Vector3d() noexcept = default;
33
34 /// get x
35 double x() const;
36
37 /// get y
38 double y() const;
39
40 /// get z
41 double z() const;
42
43 /// addition
44 Vector3d operator+(const Vector3d& other) const;
45
46 /// addition
47 Vector3d& operator+=(const Vector3d& other);
48
49 /// subtraction
50 Vector3d operator-(const Vector3d& other) const;
51
52 /// subtraction
53 Vector3d& operator-=(const Vector3d& other);
54
55 /// check equality
56 bool operator==(const Vector3d& other) const;
57
58 /// check inequality
59 bool operator!=(const Vector3d& other) const;
60
61 /// normalize to one
62 bool normalize();
63
64 /// get a vector which is the reverse of this
65 Vector3d reverseVector() const;
66
67 /// get length
68 double length() const;
69
70 /// set length
71 bool setLength(double newLength);
72
73 /// orthogonal right
74 Vector3d orthogonalRight() const;
75
76 /// orthogonal left
77 Vector3d orthogonalLeft() const;
78
79 /// dot product with another Vector3d
80 double dot(const Vector3d& other) const;
81
82 /// cross product with another Vector3d
83 Vector3d cross(const Vector3d& other) const;
84
85 /// get the Vector directly
86 Vector vector() const;
87
88 private:
89 REGISTER_LOGGER("utilities.Vector3d");
90
91 Vector m_storage;
92 };
93
94 /// ostream operator
95 UTILITIES_API std::ostream& operator<<(std::ostream& os, const Vector3d& vec);
96
97 /// ostream operator
98 UTILITIES_API std::ostream& operator<<(std::ostream& os, const std::vector<Vector3d>& vecVector);
99
100 /// negation
101 UTILITIES_API Vector3d operator-(const Vector3d& vec);
102
103 /// multiplication by a scalar
104 UTILITIES_API Vector3d operator*(double mult, const Vector3d& vec);
105
106 // optional Vector3d
107 using OptionalVector3d = boost::optional<Vector3d>;
108
109 // vector of Vector3d
110 using Vector3dVector = std::vector<Vector3d>;
111
112 } // namespace openstudio
113
114 #endif //UTILITIES_GEOMETRY_VECTOR3D_HPP
115