GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 80.2% 174 / 0 / 217
Functions: 81.5% 22 / 0 / 27
Branches: 73.7% 230 / 0 / 312

src/utilities/geometry/Transformation.cpp
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 #include "Transformation.hpp"
7 #include "Point3d.hpp"
8 #include "Vector3d.hpp"
9 #include "Plane.hpp"
10 #include "BoundingBox.hpp"
11 #include "EulerAngles.hpp"
12 #include "Geometry.hpp"
13 #include "../core/Assert.hpp"
14
15 #include <boost/math/constants/constants.hpp>
16
17 #include <algorithm>
18
19 #include <cmath>
20
21 using boost::numeric::ublas::identity_matrix;
22 using std::min;
23
24 namespace openstudio {
25
26 /// default constructor creates identity transformation
27
2/2
✓ Branch 1 taken 93314 times.
✓ Branch 4 taken 93314 times.
93314 Transformation::Transformation() : m_storage(identity_matrix<double>(4)) {}
28
29 /// constructor from storage, asserts matrix is 4x4
30 478708 Transformation::Transformation(const Matrix& matrix) : m_storage(matrix) {
31
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 478708 times.
✗ Branch 4 not taken.
478708 OS_ASSERT(matrix.size1() == 4);
32
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 478708 times.
✗ Branch 4 not taken.
478708 OS_ASSERT(matrix.size2() == 4);
33 478708 }
34
35 /// constructor from storage, asserts vector is size 16
36 ✗ Transformation::Transformation(const Vector& vector) : m_storage(Matrix(4, 4)) {
37 ✗ OS_ASSERT(vector.size() == 16);
38
39 ✗ m_storage(0, 0) = vector[0];
40 ✗ m_storage(1, 0) = vector[1];
41 ✗ m_storage(2, 0) = vector[2];
42 ✗ m_storage(3, 0) = vector[3];
43 ✗ m_storage(0, 1) = vector[4];
44 ✗ m_storage(1, 1) = vector[5];
45 ✗ m_storage(2, 1) = vector[6];
46 ✗ m_storage(2, 1) = vector[7];
47 ✗ m_storage(0, 2) = vector[8];
48 ✗ m_storage(1, 2) = vector[9];
49 ✗ m_storage(2, 2) = vector[10];
50 ✗ m_storage(3, 2) = vector[11];
51 ✗ m_storage(0, 3) = vector[12];
52 ✗ m_storage(1, 3) = vector[13];
53 ✗ m_storage(2, 3) = vector[14];
54 ✗ m_storage(3, 3) = vector[15];
55 ✗ }
56
57 /// rotation about origin defined by axis and angle (radians)
58 12277 Transformation Transformation::rotation(const Vector3d& axis, double radians) {
59
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Matrix storage = identity_matrix<double>(4);
60
61
1/1
✓ Branch 1 taken 12277 times.
12277 Vector3d temp = axis;
62
2/3
✓ Branch 1 taken 12277 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12277 times.
12277 if (!temp.normalize()) {
63 ✗ LOG(Error, "Could not normalize axis");
64 }
65
1/1
✓ Branch 1 taken 12277 times.
12277 Vector normalVector = temp.vector();
66
67 // Rodrigues' rotation formula / Rotation matrix from Euler axis/angle
68 // I*cos(radians) + I*(1-cos(radians))*axis*axis^T + Q*sin(radians)
69 // Q = [0, -axis[2], axis[1]; axis[2], 0, -axis[0]; -axis[1], axis[0], 0]
70
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Matrix P = outer_prod(normalVector, normalVector);
71
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Matrix I = identity_matrix<double>(3);
72
1/1
✓ Branch 1 taken 12277 times.
12277 Matrix Q(3, 3, 0.0);
73
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Q(0, 1) = -normalVector(2);
74
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Q(0, 2) = normalVector(1);
75
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Q(1, 0) = normalVector(2);
76
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Q(1, 2) = -normalVector(0);
77
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Q(2, 0) = -normalVector(1);
78
2/2
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
12277 Q(2, 1) = normalVector(0);
79
80 // rotation matrix
81
6/6
✓ Branch 1 taken 12277 times.
✓ Branch 4 taken 12277 times.
✓ Branch 7 taken 12277 times.
✓ Branch 10 taken 12277 times.
✓ Branch 13 taken 12277 times.
✓ Branch 16 taken 12277 times.
12277 Matrix R = I * std::cos(radians) + (1 - std::cos(radians)) * P + Q * std::sin(radians);
82
83
2/2
✓ Branch 0 taken 36831 times.
✓ Branch 1 taken 12277 times.
49108 for (unsigned i = 0; i < 3; ++i) {
84
2/2
✓ Branch 0 taken 110493 times.
✓ Branch 1 taken 36831 times.
147324 for (unsigned j = 0; j < 3; ++j) {
85
2/2
✓ Branch 1 taken 110493 times.
✓ Branch 4 taken 110493 times.
110493 storage(i, j) = R(i, j);
86 }
87 }
88
89
1/1
✓ Branch 1 taken 12277 times.
24554 return Transformation(storage);
90 12277 }
91
92 /// rotation about point defined by axis and angle (radians)
93 5 Transformation Transformation::rotation(const Point3d& origin, const Vector3d& axis, double radians) {
94
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
5 Vector3d temp(origin.x(), origin.y(), origin.z());
95
96 // translate point to origin, rotate, and then translate back
97
6/6
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
✓ Branch 13 taken 5 times.
✓ Branch 16 taken 5 times.
10 return translation(temp) * rotation(axis, radians) * translation(-temp);
98 5 }
99
100 /// rotation specified by Euler angles
101 314 Transformation Transformation::rotation(const EulerAngles& angles) {
102
7/7
✓ Branch 1 taken 314 times.
✓ Branch 4 taken 314 times.
✓ Branch 7 taken 314 times.
✓ Branch 10 taken 314 times.
✓ Branch 13 taken 314 times.
✓ Branch 16 taken 314 times.
✓ Branch 19 taken 314 times.
628 Transformation result = Transformation::rotation(Vector3d(0, 0, 1), angles.phi()) * Transformation::rotation(Vector3d(0, 1, 0), angles.theta())
103
4/4
✓ Branch 1 taken 314 times.
✓ Branch 4 taken 314 times.
✓ Branch 7 taken 314 times.
✓ Branch 10 taken 314 times.
942 * Transformation::rotation(Vector3d(1, 0, 0), angles.psi());
104 314 return result;
105 }
106
107 /// translation along vector
108 83574 Transformation Transformation::translation(const Vector3d& translation) {
109
2/2
✓ Branch 1 taken 83574 times.
✓ Branch 4 taken 83574 times.
83574 Matrix storage = identity_matrix<double>(4);
110
111
2/2
✓ Branch 1 taken 83574 times.
✓ Branch 4 taken 83574 times.
83574 storage(0, 3) = translation.x();
112
2/2
✓ Branch 1 taken 83574 times.
✓ Branch 4 taken 83574 times.
83574 storage(1, 3) = translation.y();
113
2/2
✓ Branch 1 taken 83574 times.
✓ Branch 4 taken 83574 times.
83574 storage(2, 3) = translation.z();
114
115
1/1
✓ Branch 1 taken 83574 times.
167148 return Transformation(storage);
116 83574 }
117
118 /// transforms system with z' to regular system
119 /// will try to align y' with z, but if that fails will align y' with y
120 74426 Transformation Transformation::alignZPrime(const Vector3d& zPrime) {
121
1/1
✓ Branch 1 taken 74426 times.
74426 Vector3d xp;
122
1/1
✓ Branch 1 taken 74426 times.
74426 Vector3d yp;
123
1/1
✓ Branch 1 taken 74426 times.
74426 Vector3d zp = zPrime;
124
2/3
✓ Branch 1 taken 74426 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74426 times.
74426 if (!zp.normalize()) {
125 ✗ LOG(Error, "Could not normalize zPrime");
126 }
127
128 // Vector3d xAxis(1, 0, 0);
129 // Vector3d yAxis(0, 1, 0);
130
1/1
✓ Branch 1 taken 74426 times.
74426 Vector3d zAxis(0, 0, 1);
131
1/1
✓ Branch 1 taken 74426 times.
74426 Vector3d negXAxis(-1, 0, 0);
132
133 // check if face normal is up or down
134
3/3
✓ Branch 1 taken 74426 times.
✓ Branch 3 taken 45351 times.
✓ Branch 4 taken 29075 times.
74426 if (std::fabs(zp.dot(zAxis)) < 0.99) {
135 // not facing up or down, set yPrime along zAxis
136
3/3
✓ Branch 1 taken 45351 times.
✓ Branch 4 taken 45351 times.
✓ Branch 7 taken 45351 times.
45351 yp = zAxis - (zp.dot(zAxis) * zp);
137
2/3
✓ Branch 1 taken 45351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45351 times.
45351 if (!yp.normalize()) {
138 ✗ LOG(Error, "Could not normalize axis");
139 }
140
1/1
✓ Branch 1 taken 45351 times.
45351 xp = yp.cross(zp);
141 } else {
142 // facing up or down, set xPrime along -xAxis
143
3/3
✓ Branch 1 taken 29075 times.
✓ Branch 4 taken 29075 times.
✓ Branch 7 taken 29075 times.
29075 xp = negXAxis - (zp.dot(negXAxis) * zp);
144
2/3
✓ Branch 1 taken 29075 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29075 times.
29075 if (!xp.normalize()) {
145 ✗ LOG(Error, "Could not normalize axis");
146 }
147
1/1
✓ Branch 1 taken 29075 times.
29075 yp = zp.cross(xp);
148 }
149
150
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 Matrix storage = identity_matrix<double>(4);
151
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(0, 0) = xp.x();
152
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(1, 0) = xp.y();
153
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(2, 0) = xp.z();
154
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(0, 1) = yp.x();
155
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(1, 1) = yp.y();
156
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(2, 1) = yp.z();
157
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(0, 2) = zp.x();
158
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(1, 2) = zp.y();
159
2/2
✓ Branch 1 taken 74426 times.
✓ Branch 4 taken 74426 times.
74426 storage(2, 2) = zp.z();
160
161
1/1
✓ Branch 1 taken 74426 times.
148852 return Transformation(storage);
162 74426 }
163
164 /// transforms face coordinates to regular system, face normal will be z'
165 /// will try to align y' with z, but if that fails will align y' with y
166 /// face origin will be minimum point in x', y' and z'=0
167 /// will return identity transformation if cannot compute plane for vertices
168 74422 Transformation Transformation::alignFace(const std::vector<Point3d>& vertices) {
169
1/1
✓ Branch 1 taken 74422 times.
74422 OptionalVector3d zPrime = getOutwardNormal(vertices);
170
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 74420 times.
74422 if (!zPrime) {
171
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
2 LOG(Error, "Cannot compute outward normal for vertices");
172
1/1
✓ Branch 1 taken 2 times.
2 return {};
173 }
174
175 // align z' with outward normal
176
2/2
✓ Branch 1 taken 74420 times.
✓ Branch 4 taken 74420 times.
74420 Transformation align = alignZPrime(*zPrime);
177
2/2
✓ Branch 1 taken 74420 times.
✓ Branch 4 taken 74420 times.
74420 Point3dVector alignedVertices = align.inverse() * vertices;
178
179 // compute translation to minimum in aligned system
180
1/1
✓ Branch 2 taken 74420 times.
74420 double minX = alignedVertices[0].x();
181
1/1
✓ Branch 2 taken 74420 times.
74420 double minY = alignedVertices[0].y();
182
1/1
✓ Branch 2 taken 74420 times.
74420 double minZ = alignedVertices[0].z();
183
184
2/2
✓ Branch 4 taken 335480 times.
✓ Branch 5 taken 74420 times.
409900 for (const Point3d& vertex : alignedVertices) {
185
1/1
✓ Branch 1 taken 335480 times.
335480 minX = min(minX, vertex.x());
186
1/1
✓ Branch 1 taken 335480 times.
335480 minY = min(minY, vertex.y());
187
1/1
✓ Branch 1 taken 335480 times.
335480 minZ = min(minZ, vertex.z());
188 }
189
2/2
✓ Branch 1 taken 74420 times.
✓ Branch 4 taken 74420 times.
74420 Transformation translate = translation(Vector3d(minX, minY, minZ));
190
191
1/1
✓ Branch 1 taken 74420 times.
74420 return align * translate;
192 74422 }
193
194 /// returns a transformation which is the inverse of this
195 175137 Transformation Transformation::inverse() const {
196
1/1
✓ Branch 1 taken 175137 times.
175137 Matrix matrix(4, 4);
197
1/1
✓ Branch 1 taken 175137 times.
175137 bool test = invert(m_storage, matrix);
198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175137 times.
175137 if (!test) {
199 // this should never happen
200 ✗ LOG_AND_THROW("Matrix inversion failed");
201 }
202
1/1
✓ Branch 1 taken 175137 times.
350274 return Transformation(matrix);
203 175137 }
204
205 /// get the matrix representation directly
206 64 Matrix Transformation::matrix() const {
207 64 return m_storage;
208 }
209
210 /// get the vector representation directly
211 11518 Vector Transformation::vector() const {
212 11518 openstudio::Vector result(16);
213
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[0] = m_storage(0, 0);
214
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[1] = m_storage(1, 0);
215
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[2] = m_storage(2, 0);
216
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[3] = m_storage(3, 0);
217
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[4] = m_storage(0, 1);
218
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[5] = m_storage(1, 1);
219
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[6] = m_storage(2, 1);
220
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[7] = m_storage(3, 1);
221
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[8] = m_storage(0, 2);
222
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[9] = m_storage(1, 2);
223
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[10] = m_storage(2, 2);
224
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[11] = m_storage(3, 2);
225
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[12] = m_storage(0, 3);
226
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[13] = m_storage(1, 3);
227
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[14] = m_storage(2, 3);
228
2/2
✓ Branch 1 taken 11518 times.
✓ Branch 4 taken 11518 times.
11518 result[15] = m_storage(3, 3);
229 11518 return result;
230 ✗ }
231
232 /// get the Euler angles for the transformation, does not include translation
233 905 EulerAngles Transformation::eulerAngles() const {
234 double psi;
235 double theta;
236 double phi;
237
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 905 times.
905 if (m_storage(2, 0) == 1.0) {
238 ✗ phi = 0;
239 ✗ theta = -boost::math::constants::pi<double>() / 2.0;
240 ✗ psi = std::atan2(-m_storage(0, 1), -m_storage(0, 2));
241
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 905 times.
905 } else if (m_storage(2, 0) == -1.0) {
242 ✗ phi = 0;
243 ✗ theta = boost::math::constants::pi<double>() / 2.0;
244 ✗ psi = std::atan2(m_storage(0, 1), m_storage(0, 2));
245 } else {
246 905 theta = -asin(m_storage(2, 0));
247 // theta = pi + asin(m_storage(2,0)); // alternate solution
248 905 psi = std::atan2(m_storage(2, 1) / std::cos(theta), m_storage(2, 2) / std::cos(theta));
249 905 phi = std::atan2(m_storage(1, 0) / std::cos(theta), m_storage(0, 0) / std::cos(theta));
250 }
251 905 EulerAngles result(psi, theta, phi);
252 905 return result;
253 }
254
255 /// get the rotation matrix for the transformation, does not include translation
256 5 Matrix Transformation::rotationMatrix() const {
257 5 Matrix result(3, 3);
258
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 5 times.
20 for (unsigned i = 0; i < 3; ++i) {
259
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 15 times.
60 for (unsigned j = 0; j < 3; ++j) {
260
2/2
✓ Branch 1 taken 45 times.
✓ Branch 4 taken 45 times.
45 result(i, j) = m_storage(i, j);
261 }
262 }
263 5 return result;
264 ✗ }
265
266 /// get the translation for the transformation, does not include rotation
267 896 Vector3d Transformation::translation() const {
268 896 Vector3d result(m_storage(0, 3), m_storage(1, 3), m_storage(2, 3));
269 896 return result;
270 }
271
272 /// apply the transformation to the point
273 6617088 Point3d Transformation::operator*(const Point3d& point) const {
274
1/1
✓ Branch 1 taken 6617088 times.
6617088 Vector temp(4);
275
2/2
✓ Branch 1 taken 6617088 times.
✓ Branch 4 taken 6617088 times.
6617088 temp(0) = point.x();
276
2/2
✓ Branch 1 taken 6617088 times.
✓ Branch 4 taken 6617088 times.
6617088 temp(1) = point.y();
277
2/2
✓ Branch 1 taken 6617088 times.
✓ Branch 4 taken 6617088 times.
6617088 temp(2) = point.z();
278
1/1
✓ Branch 1 taken 6617088 times.
6617088 temp(3) = 1.0;
279
2/2
✓ Branch 1 taken 6617088 times.
✓ Branch 4 taken 6617088 times.
6617088 temp = prod(m_storage, temp);
280
4/4
✓ Branch 1 taken 6617088 times.
✓ Branch 4 taken 6617088 times.
✓ Branch 7 taken 6617088 times.
✓ Branch 10 taken 6617088 times.
13234176 return {temp[0], temp[1], temp[2]};
281 6617088 }
282
283 /// apply the transformation to the vector
284 30 Vector3d Transformation::operator*(const Vector3d& vector) const {
285
1/1
✓ Branch 1 taken 30 times.
30 Vector temp(4);
286
2/2
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
30 temp(0) = vector.x();
287
2/2
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
30 temp(1) = vector.y();
288
2/2
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
30 temp(2) = vector.z();
289
1/1
✓ Branch 1 taken 30 times.
30 temp(3) = 1.0;
290
2/2
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
30 temp = prod(m_storage, temp);
291
4/4
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✓ Branch 10 taken 30 times.
60 return {temp[0], temp[1], temp[2]};
292 30 }
293
294 /// apply the transformation to the BoundingBox
295 38524 BoundingBox Transformation::operator*(const BoundingBox& boundingBox) const {
296 38524 BoundingBox result;
297
2/2
✓ Branch 1 taken 38524 times.
✓ Branch 4 taken 38524 times.
38524 std::vector<Point3d> transformedPoints = (*this) * boundingBox.corners();
298
1/1
✓ Branch 1 taken 38524 times.
38524 result.addPoints(transformedPoints);
299 77048 return result;
300 38524 }
301
302 /// apply the transformation to the plane
303 1043101 Plane Transformation::operator*(const Plane& plane) const {
304 // translate a point on the plane, just project (0,0,0)
305
2/2
✓ Branch 1 taken 1043101 times.
✓ Branch 4 taken 1043101 times.
1043101 Point3d point = plane.project(Point3d(0, 0, 0));
306
307 // get a point at outward normal
308
1/1
✓ Branch 1 taken 1043101 times.
1043101 Vector3d outwardNormal = plane.outwardNormal();
309
1/1
✓ Branch 1 taken 1043101 times.
1043101 Point3d refPoint = point + outwardNormal;
310
311 // translate the two points and recompute the normal
312
1/1
✓ Branch 1 taken 1043101 times.
1043101 Point3d newPoint = (*this) * point;
313
1/1
✓ Branch 1 taken 1043101 times.
1043101 Point3d newRefPoint = (*this) * refPoint;
314
1/1
✓ Branch 1 taken 1043101 times.
1043101 Vector3d newNormal = newRefPoint - newPoint;
315
316
1/1
✓ Branch 1 taken 1043101 times.
2086202 return Plane(newPoint, newNormal);
317 1043101 }
318
319 /// apply the transformation to a vector of points
320 995380 std::vector<Point3d> Transformation::operator*(const std::vector<Point3d>& points) const {
321
1/1
✓ Branch 2 taken 995380 times.
995380 std::vector<Point3d> result(points.size());
322
2/2
✓ Branch 1 taken 4515738 times.
✓ Branch 2 taken 995380 times.
5511118 for (unsigned i = 0; i < points.size(); ++i) {
323
1/1
✓ Branch 2 taken 4515738 times.
4515738 result[i] = (*this) * points[i];
324 }
325 995380 return result;
326 ✗ }
327
328 /// apply the transformation to a vector of vector
329 4 std::vector<Vector3d> Transformation::operator*(const std::vector<Vector3d>& vectors) const {
330
1/1
✓ Branch 2 taken 4 times.
4 std::vector<Vector3d> result(vectors.size());
331
2/2
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
16 for (unsigned i = 0; i < vectors.size(); ++i) {
332
1/1
✓ Branch 2 taken 12 times.
12 result[i] = (*this) * vectors[i];
333 }
334 4 return result;
335 ✗ }
336
337 /// apply the transformation to the other transformation
338 133293 Transformation Transformation::operator*(const Transformation& other) const {
339
2/2
✓ Branch 1 taken 133293 times.
✓ Branch 4 taken 133293 times.
133293 return Transformation(prod(m_storage, other.m_storage));
340 }
341
342 /// ostream operator
343 ✗ std::ostream& operator<<(std::ostream& os, const Transformation& t) {
344 ✗ os << t.matrix();
345 ✗ return os;
346 }
347
348 ✗ Transformation createRotation(const Vector3d& axis, double radians) {
349 ✗ return Transformation::rotation(axis, radians);
350 }
351
352 ✗ Transformation createRotation(const Point3d& origin, const Vector3d& axis, double radians) {
353 ✗ return Transformation::rotation(origin, axis, radians);
354 }
355
356 ✗ Transformation createRotation(const EulerAngles& angles) {
357 ✗ return Transformation::rotation(angles);
358 }
359
360 18 Transformation createTranslation(const Vector3d& translation) {
361 18 return Transformation::translation(translation);
362 }
363
364 } // namespace openstudio
365