MRPT  2.0.4
CDynamicGrid_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <CTraitsTest.h>
12 #include <mrpt/core/common.h>
13 
14 #include <gtest/gtest.h>
15 
16 template class mrpt::CTraitsTest<mrpt::containers::CDynamicGrid<double>>;
17 
19 
20 TEST(CDynamicGrid, GetSetAndResize)
21 {
22  CDynamicGrid<double> grid{-10.0, 10.0, -10.0, 10.0, 0.1};
23 
24  *grid.cellByPos(3.0, 4.0) = 8.0;
25  *grid.cellByPos(-2.0, -7.0) = 9.0;
26 
27  EXPECT_NEAR(*grid.cellByPos(3.0, 4.0), 8.0, 1e-10);
28  EXPECT_NEAR(*grid.cellByPos(-2.0, -7.0), 9.0, 1e-10);
29 
30  grid.resize(-20.0, 20.0, -20.0, 20.0, 0.0, 0.0);
31  EXPECT_NEAR(*grid.cellByPos(3.0, 4.0), 8.0, 1e-10);
32  EXPECT_NEAR(*grid.cellByPos(-2.0, -7.0), 9.0, 1e-10);
33 }
TEST(CDynamicGrid, GetSetAndResize)
A 2D grid of dynamic size which stores any kind of data at each cell.
Definition: CDynamicGrid.h:38
T * cellByPos(double x, double y)
Returns a pointer to the contents of a cell given by its coordinates, or nullptr if it is out of the ...
Definition: CDynamicGrid.h:201
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020