test_shapes.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2019, Czech Technical University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
37 #include "resources/config.h"
40 #include <gtest/gtest.h>
41 
42 using namespace shapes;
43 
44 TEST(Plane, ScaleAndPadd)
45 {
46  const Plane plane(1., 1., 1., 1.0);
47 
48  auto plane2 = plane;
49  EXPECT_EQ(plane2.a, plane.a);
50  EXPECT_EQ(plane2.b, plane.b);
51  EXPECT_EQ(plane2.c, plane.c);
52  EXPECT_EQ(plane2.d, plane.d);
53 
54  plane2.scale(2.0);
55  EXPECT_EQ(plane2.a, plane.a);
56  EXPECT_EQ(plane2.b, plane.b);
57  EXPECT_EQ(plane2.c, plane.c);
58  EXPECT_EQ(plane2.d, plane.d);
59 
60  plane2.padd(1.0);
61  EXPECT_EQ(plane2.a, plane.a);
62  EXPECT_EQ(plane2.b, plane.b);
63  EXPECT_EQ(plane2.c, plane.c);
64  EXPECT_EQ(plane2.d, plane.d);
65 
66  plane2.scaleAndPadd(2.0, 1.0);
67  EXPECT_EQ(plane2.a, plane.a);
68  EXPECT_EQ(plane2.b, plane.b);
69  EXPECT_EQ(plane2.c, plane.c);
70  EXPECT_EQ(plane2.d, plane.d);
71 }
72 
73 TEST(OcTree, ScaleAndPaddEmpty)
74 {
75  // just test that scaling/padding an empty octree doesn't throw
76  OcTree octree;
77  octree.scale(2.0);
78  octree.padd(1.0);
79  octree.scaleAndPadd(2.0, 1.0);
80 }
81 
82 TEST(Sphere, ScaleAndPadd)
83 {
84  const Sphere sphere(1.);
85 
86  auto sphere2 = sphere;
87  EXPECT_EQ(sphere2.radius, sphere.radius);
88 
89  sphere2.scale(2.0);
90  EXPECT_DOUBLE_EQ(sphere2.radius, 2.0);
91 
92  sphere2.padd(1.0);
93  EXPECT_DOUBLE_EQ(sphere2.radius, 3.0);
94 
95  sphere2.scaleAndPadd(2.0, 1.0);
96  EXPECT_DOUBLE_EQ(sphere2.radius, 7.0);
97 }
98 
99 TEST(Cylinder, ScaleAndPadd)
100 {
101  const Cylinder cylinder(1., 2.);
102 
103  auto cylinder2 = cylinder;
104  EXPECT_EQ(cylinder2.radius, cylinder.radius);
105  EXPECT_EQ(cylinder2.length, cylinder.length);
106 
107  cylinder2.scale(2.0);
108  EXPECT_DOUBLE_EQ(cylinder2.radius, 2.0);
109  EXPECT_DOUBLE_EQ(cylinder2.length, 4.0);
110 
111  cylinder2.padd(1.0);
112  EXPECT_DOUBLE_EQ(cylinder2.radius, 3.0);
113  EXPECT_DOUBLE_EQ(cylinder2.length, 6.0);
114 
115  cylinder2.scaleAndPadd(2.0, 1.0);
116  EXPECT_DOUBLE_EQ(cylinder2.radius, 7.0);
117  EXPECT_DOUBLE_EQ(cylinder2.length, 14.0);
118 
119  cylinder2.scaleAndPadd(1.0, 3.0, 1.0, 3.0);
120  EXPECT_DOUBLE_EQ(cylinder2.radius, 8.0);
121  EXPECT_DOUBLE_EQ(cylinder2.length, 48.0);
122 
123  cylinder2.scale(2.0, 1.5);
124  EXPECT_DOUBLE_EQ(cylinder2.radius, 16.0);
125  EXPECT_DOUBLE_EQ(cylinder2.length, 72.0);
126 
127  cylinder2.padd(2.0, 3.0);
128  EXPECT_DOUBLE_EQ(cylinder2.radius, 18.0);
129  EXPECT_DOUBLE_EQ(cylinder2.length, 78.0);
130 }
131 
132 TEST(Cone, ScaleAndPadd)
133 {
134  const Cone cone(1., 2.);
135 
136  auto cone2 = cone;
137  EXPECT_EQ(cone2.radius, cone.radius);
138  EXPECT_EQ(cone2.length, cone.length);
139 
140  cone2.scale(2.0);
141  EXPECT_DOUBLE_EQ(cone2.radius, 2.0);
142  EXPECT_DOUBLE_EQ(cone2.length, 4.0);
143 
144  cone2.padd(1.0);
145  EXPECT_DOUBLE_EQ(cone2.radius, 3.0);
146  EXPECT_DOUBLE_EQ(cone2.length, 6.0);
147 
148  cone2.scaleAndPadd(2.0, 1.0);
149  EXPECT_DOUBLE_EQ(cone2.radius, 7.0);
150  EXPECT_DOUBLE_EQ(cone2.length, 14.0);
151 
152  cone2.scaleAndPadd(1.0, 3.0, 1.0, 3.0);
153  EXPECT_DOUBLE_EQ(cone2.radius, 8.0);
154  EXPECT_DOUBLE_EQ(cone2.length, 48.0);
155 
156  cone2.scale(2.0, 1.5);
157  EXPECT_DOUBLE_EQ(cone2.radius, 16.0);
158  EXPECT_DOUBLE_EQ(cone2.length, 72.0);
159 
160  cone2.padd(2.0, 3.0);
161  EXPECT_DOUBLE_EQ(cone2.radius, 18.0);
162  EXPECT_DOUBLE_EQ(cone2.length, 78.0);
163 }
164 
165 TEST(Box, ScaleAndPadd)
166 {
167  const Box box(1., 2., 3.0);
168 
169  auto box2 = box;
170  EXPECT_EQ(box2.size[0], box.size[0]);
171  EXPECT_EQ(box2.size[1], box.size[1]);
172  EXPECT_EQ(box2.size[2], box.size[2]);
173 
174  box2.scale(2.0);
175  EXPECT_DOUBLE_EQ(box2.size[0], 2.0);
176  EXPECT_DOUBLE_EQ(box2.size[1], 4.0);
177  EXPECT_DOUBLE_EQ(box2.size[2], 6.0);
178 
179  box2.padd(1.0);
180  EXPECT_DOUBLE_EQ(box2.size[0], 4.0);
181  EXPECT_DOUBLE_EQ(box2.size[1], 6.0);
182  EXPECT_DOUBLE_EQ(box2.size[2], 8.0);
183 
184  box2.scaleAndPadd(2.0, 1.0);
185  EXPECT_DOUBLE_EQ(box2.size[0], 10.0);
186  EXPECT_DOUBLE_EQ(box2.size[1], 14.0);
187  EXPECT_DOUBLE_EQ(box2.size[2], 18.0);
188 
189  box2.scaleAndPadd(1.0, 2.0, 3.0, 1.0, 2.0, 3.0);
190  EXPECT_DOUBLE_EQ(box2.size[0], 12.0);
191  EXPECT_DOUBLE_EQ(box2.size[1], 32.0);
192  EXPECT_DOUBLE_EQ(box2.size[2], 60.0);
193 
194  box2.scale(1.0, 2.0, 3.0);
195  EXPECT_DOUBLE_EQ(box2.size[0], 12.0);
196  EXPECT_DOUBLE_EQ(box2.size[1], 64.0);
197  EXPECT_DOUBLE_EQ(box2.size[2], 180.0);
198 
199  box2.padd(1.0, 2.0, 3.0);
200  EXPECT_DOUBLE_EQ(box2.size[0], 14.0);
201  EXPECT_DOUBLE_EQ(box2.size[1], 68.0);
202  EXPECT_DOUBLE_EQ(box2.size[2], 186.0);
203 }
204 
205 TEST(Mesh, ScaleAndPadd)
206 {
207  std::string path = "file://" + std::string(TEST_RESOURCES_DIR) + "/box.dae";
208  const auto& mesh = shapes::createMeshFromResource(path);
209 
210  ASSERT_EQ(mesh->vertex_count, 8u);
211 
212  auto mesh2 = mesh;
213  EXPECT_DOUBLE_EQ(mesh2->vertices[0], 1.0);
214  EXPECT_DOUBLE_EQ(mesh2->vertices[1], 1.0);
215  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -1.0);
216 
217  EXPECT_DOUBLE_EQ(mesh2->vertices[3], 1.0);
218  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -1.0);
219  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -1.0);
220 
221  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -1.0);
222  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -1.0);
223  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -1.0);
224 
225  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -1.0);
226  EXPECT_DOUBLE_EQ(mesh2->vertices[10], 1.0);
227  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -1.0);
228 
229  EXPECT_DOUBLE_EQ(mesh2->vertices[12], 1.0);
230  EXPECT_DOUBLE_EQ(mesh2->vertices[13], 1.0);
231  EXPECT_DOUBLE_EQ(mesh2->vertices[14], 1.0);
232 
233  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -1.0);
234  EXPECT_DOUBLE_EQ(mesh2->vertices[16], 1.0);
235  EXPECT_DOUBLE_EQ(mesh2->vertices[17], 1.0);
236 
237  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -1.0);
238  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -1.0);
239  EXPECT_DOUBLE_EQ(mesh2->vertices[20], 1.0);
240 
241  EXPECT_DOUBLE_EQ(mesh2->vertices[21], 1.0);
242  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -1.0);
243  EXPECT_DOUBLE_EQ(mesh2->vertices[23], 1.0);
244 
245  mesh2->scale(2.0);
246 
247  EXPECT_DOUBLE_EQ(mesh2->vertices[0], 2.0);
248  EXPECT_DOUBLE_EQ(mesh2->vertices[1], 2.0);
249  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -2.0);
250 
251  EXPECT_DOUBLE_EQ(mesh2->vertices[3], 2.0);
252  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -2.0);
253  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -2.0);
254 
255  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -2.0);
256  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -2.0);
257  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -2.0);
258 
259  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -2.0);
260  EXPECT_DOUBLE_EQ(mesh2->vertices[10], 2.0);
261  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -2.0);
262 
263  EXPECT_DOUBLE_EQ(mesh2->vertices[12], 2.0);
264  EXPECT_DOUBLE_EQ(mesh2->vertices[13], 2.0);
265  EXPECT_DOUBLE_EQ(mesh2->vertices[14], 2.0);
266 
267  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -2.0);
268  EXPECT_DOUBLE_EQ(mesh2->vertices[16], 2.0);
269  EXPECT_DOUBLE_EQ(mesh2->vertices[17], 2.0);
270 
271  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -2.0);
272  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -2.0);
273  EXPECT_DOUBLE_EQ(mesh2->vertices[20], 2.0);
274 
275  EXPECT_DOUBLE_EQ(mesh2->vertices[21], 2.0);
276  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -2.0);
277  EXPECT_DOUBLE_EQ(mesh2->vertices[23], 2.0);
278 
279  // padding actually means extending each vertices' direction vector by the padding value,
280  // not extending it along each axis by the same amount
281  mesh2->padd(1.0);
282  const double pos = 2.0 * (1 + 1.0 / sqrt(12));
283 
284  EXPECT_DOUBLE_EQ(mesh2->vertices[0], pos);
285  EXPECT_DOUBLE_EQ(mesh2->vertices[1], pos);
286  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -pos);
287 
288  EXPECT_DOUBLE_EQ(mesh2->vertices[3], pos);
289  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -pos);
290  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -pos);
291 
292  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -pos);
293  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -pos);
294  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -pos);
295 
296  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -pos);
297  EXPECT_DOUBLE_EQ(mesh2->vertices[10], pos);
298  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -pos);
299 
300  EXPECT_DOUBLE_EQ(mesh2->vertices[12], pos);
301  EXPECT_DOUBLE_EQ(mesh2->vertices[13], pos);
302  EXPECT_DOUBLE_EQ(mesh2->vertices[14], pos);
303 
304  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -pos);
305  EXPECT_DOUBLE_EQ(mesh2->vertices[16], pos);
306  EXPECT_DOUBLE_EQ(mesh2->vertices[17], pos);
307 
308  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -pos);
309  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -pos);
310  EXPECT_DOUBLE_EQ(mesh2->vertices[20], pos);
311 
312  EXPECT_DOUBLE_EQ(mesh2->vertices[21], pos);
313  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -pos);
314  EXPECT_DOUBLE_EQ(mesh2->vertices[23], pos);
315 
316  mesh2->scaleAndPadd(2.0, 1.0);
317  const double pos2 = pos * (2.0 + 1.0 / sqrt(3 * pos * pos));
318 
319  EXPECT_DOUBLE_EQ(mesh2->vertices[0], pos2);
320  EXPECT_DOUBLE_EQ(mesh2->vertices[1], pos2);
321  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -pos2);
322 
323  EXPECT_DOUBLE_EQ(mesh2->vertices[3], pos2);
324  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -pos2);
325  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -pos2);
326 
327  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -pos2);
328  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -pos2);
329  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -pos2);
330 
331  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -pos2);
332  EXPECT_DOUBLE_EQ(mesh2->vertices[10], pos2);
333  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -pos2);
334 
335  EXPECT_DOUBLE_EQ(mesh2->vertices[12], pos2);
336  EXPECT_DOUBLE_EQ(mesh2->vertices[13], pos2);
337  EXPECT_DOUBLE_EQ(mesh2->vertices[14], pos2);
338 
339  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -pos2);
340  EXPECT_DOUBLE_EQ(mesh2->vertices[16], pos2);
341  EXPECT_DOUBLE_EQ(mesh2->vertices[17], pos2);
342 
343  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -pos2);
344  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -pos2);
345  EXPECT_DOUBLE_EQ(mesh2->vertices[20], pos2);
346 
347  EXPECT_DOUBLE_EQ(mesh2->vertices[21], pos2);
348  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -pos2);
349  EXPECT_DOUBLE_EQ(mesh2->vertices[23], pos2);
350 
351  mesh2->scaleAndPadd(1.0, 2.0, 3.0, 1.0, 2.0, 3.0);
352  const double pos3x = pos2 * (1.0 + 1.0 / sqrt(3 * pos2 * pos2));
353  const double pos3y = pos2 * (2.0 + 2.0 / sqrt(3 * pos2 * pos2));
354  const double pos3z = pos2 * (3.0 + 3.0 / sqrt(3 * pos2 * pos2));
355 
356  EXPECT_DOUBLE_EQ(mesh2->vertices[0], pos3x);
357  EXPECT_DOUBLE_EQ(mesh2->vertices[1], pos3y);
358  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -pos3z);
359 
360  EXPECT_DOUBLE_EQ(mesh2->vertices[3], pos3x);
361  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -pos3y);
362  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -pos3z);
363 
364  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -pos3x);
365  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -pos3y);
366  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -pos3z);
367 
368  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -pos3x);
369  EXPECT_DOUBLE_EQ(mesh2->vertices[10], pos3y);
370  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -pos3z);
371 
372  EXPECT_DOUBLE_EQ(mesh2->vertices[12], pos3x);
373  EXPECT_DOUBLE_EQ(mesh2->vertices[13], pos3y);
374  EXPECT_DOUBLE_EQ(mesh2->vertices[14], pos3z);
375 
376  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -pos3x);
377  EXPECT_DOUBLE_EQ(mesh2->vertices[16], pos3y);
378  EXPECT_DOUBLE_EQ(mesh2->vertices[17], pos3z);
379 
380  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -pos3x);
381  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -pos3y);
382  EXPECT_DOUBLE_EQ(mesh2->vertices[20], pos3z);
383 
384  EXPECT_DOUBLE_EQ(mesh2->vertices[21], pos3x);
385  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -pos3y);
386  EXPECT_DOUBLE_EQ(mesh2->vertices[23], pos3z);
387 
388  mesh2->scale(1.0, 2.0, 3.0);
389  const double pos4x = pos3x;
390  const double pos4y = 2 * pos3y;
391  const double pos4z = 3 * pos3z;
392 
393  EXPECT_DOUBLE_EQ(mesh2->vertices[0], pos4x);
394  EXPECT_DOUBLE_EQ(mesh2->vertices[1], pos4y);
395  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -pos4z);
396 
397  EXPECT_DOUBLE_EQ(mesh2->vertices[3], pos4x);
398  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -pos4y);
399  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -pos4z);
400 
401  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -pos4x);
402  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -pos4y);
403  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -pos4z);
404 
405  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -pos4x);
406  EXPECT_DOUBLE_EQ(mesh2->vertices[10], pos4y);
407  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -pos4z);
408 
409  EXPECT_DOUBLE_EQ(mesh2->vertices[12], pos4x);
410  EXPECT_DOUBLE_EQ(mesh2->vertices[13], pos4y);
411  EXPECT_DOUBLE_EQ(mesh2->vertices[14], pos4z);
412 
413  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -pos4x);
414  EXPECT_DOUBLE_EQ(mesh2->vertices[16], pos4y);
415  EXPECT_DOUBLE_EQ(mesh2->vertices[17], pos4z);
416 
417  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -pos4x);
418  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -pos4y);
419  EXPECT_DOUBLE_EQ(mesh2->vertices[20], pos4z);
420 
421  EXPECT_DOUBLE_EQ(mesh2->vertices[21], pos4x);
422  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -pos4y);
423  EXPECT_DOUBLE_EQ(mesh2->vertices[23], pos4z);
424 
425  mesh2->padd(1.0, 2.0, 3.0);
426  const double norm5 = sqrt(pos4x * pos4x + pos4y * pos4y + pos4z * pos4z);
427  const double pos5x = pos4x * (1.0 + 1.0 / norm5);
428  const double pos5y = pos4y * (1.0 + 2.0 / norm5);
429  const double pos5z = pos4z * (1.0 + 3.0 / norm5);
430 
431  EXPECT_DOUBLE_EQ(mesh2->vertices[0], pos5x);
432  EXPECT_DOUBLE_EQ(mesh2->vertices[1], pos5y);
433  EXPECT_DOUBLE_EQ(mesh2->vertices[2], -pos5z);
434 
435  EXPECT_DOUBLE_EQ(mesh2->vertices[3], pos5x);
436  EXPECT_DOUBLE_EQ(mesh2->vertices[4], -pos5y);
437  EXPECT_DOUBLE_EQ(mesh2->vertices[5], -pos5z);
438 
439  EXPECT_DOUBLE_EQ(mesh2->vertices[6], -pos5x);
440  EXPECT_DOUBLE_EQ(mesh2->vertices[7], -pos5y);
441  EXPECT_DOUBLE_EQ(mesh2->vertices[8], -pos5z);
442 
443  EXPECT_DOUBLE_EQ(mesh2->vertices[9], -pos5x);
444  EXPECT_DOUBLE_EQ(mesh2->vertices[10], pos5y);
445  EXPECT_DOUBLE_EQ(mesh2->vertices[11], -pos5z);
446 
447  EXPECT_DOUBLE_EQ(mesh2->vertices[12], pos5x);
448  EXPECT_DOUBLE_EQ(mesh2->vertices[13], pos5y);
449  EXPECT_DOUBLE_EQ(mesh2->vertices[14], pos5z);
450 
451  EXPECT_DOUBLE_EQ(mesh2->vertices[15], -pos5x);
452  EXPECT_DOUBLE_EQ(mesh2->vertices[16], pos5y);
453  EXPECT_DOUBLE_EQ(mesh2->vertices[17], pos5z);
454 
455  EXPECT_DOUBLE_EQ(mesh2->vertices[18], -pos5x);
456  EXPECT_DOUBLE_EQ(mesh2->vertices[19], -pos5y);
457  EXPECT_DOUBLE_EQ(mesh2->vertices[20], pos5z);
458 
459  EXPECT_DOUBLE_EQ(mesh2->vertices[21], pos5x);
460  EXPECT_DOUBLE_EQ(mesh2->vertices[22], -pos5y);
461  EXPECT_DOUBLE_EQ(mesh2->vertices[23], pos5z);
462 }
463 
464 int main(int argc, char** argv)
465 {
466  testing::InitGoogleTest(&argc, argv);
467  return RUN_ALL_TESTS();
468 }
shapes::Cone::radius
double radius
The radius of the cone.
Definition: shapes.h:221
shapes::Box::size
double size[3]
x, y, z dimensions of the box (axis-aligned)
Definition: shapes.h:270
shapes
Definition of various shapes. No properties such as position are included. These are simply the descr...
Definition: mesh_operations.h:47
shapes::Cone::length
double length
The length (height) of the cone.
Definition: shapes.h:218
shapes::Cylinder
Definition of a cylinder Length is along z axis. Origin is at center of mass.
Definition: shapes.h:127
shapes::OcTree::scaleAndPadd
void scaleAndPadd(double scale, double padd) override
Uniformly scale and padd this shape.
Definition: shapes.cpp:305
shapes::Shape::scale
void scale(double scale)
Uniformly scale this shape by a factor.
Definition: shapes.cpp:315
shapes::Mesh
Definition of a triangle mesh By convention the "center" of the shape is at the origin....
Definition: shapes.h:281
shapes::Shape::padd
void padd(double padding)
Add uniform padding to this shape.
Definition: shapes.cpp:320
shapes::Sphere::radius
double radius
The radius of the sphere.
Definition: shapes.h:122
shapes::Plane
Definition of a plane with equation ax + by + cz + d = 0.
Definition: shapes.h:366
shapes::Box
Definition of a box Aligned with the XYZ axes.
Definition: shapes.h:226
shapes::Sphere
Definition of a sphere.
Definition: shapes.h:106
main
int main(int argc, char **argv)
Definition: test_shapes.cpp:464
shapes::Plane::a
double a
The plane equation is ax + by + cz + d = 0.
Definition: shapes.h:381
shapes::createMeshFromResource
Mesh * createMeshFromResource(const std::string &resource)
Load a mesh from a resource that contains a mesh that can be loaded by assimp.
Definition: mesh_operations.cpp:234
shapes::Plane::d
double d
Definition: shapes.h:381
shapes::OcTree
Representation of an octomap::OcTree as a Shape.
Definition: shapes.h:385
TEST
TEST(Plane, ScaleAndPadd)
Definition: test_shapes.cpp:44
shape_operations.h
shapes.h
shapes::Plane::c
double c
Definition: shapes.h:381
shapes::Cylinder::radius
double radius
The radius of the cylinder.
Definition: shapes.h:172
shapes::Cylinder::length
double length
The length of the cylinder.
Definition: shapes.h:169
shapes::Cone
Definition of a cone Tip is on positive z axis. Center of base is on negative z axis....
Definition: shapes.h:178
shapes::Plane::b
double b
Definition: shapes.h:381
EXPECT_EQ
#define EXPECT_EQ(a, b)


geometric_shapes
Author(s): Ioan Sucan , Gil Jones
autogenerated on Sun Oct 1 2023 02:40:16