10 #include <gtest/gtest.h>    23 TEST(Geometry, Line2DIntersect)
    41 TEST(Geometry, Line2DAngle)
    58 TEST(Geometry, Line3DAngle)
    80 TEST(Geometry, Segment2DIntersect)
   105         bool do_inter = 
intersect(s1, s2, inter);
   107         EXPECT_FALSE(do_inter);
   116         bool do_inter = 
intersect(s1, s2, inter);
   119         EXPECT_FALSE(do_inter);
   126         TPolygon3D p3d({{1, 0, 0}, {0, 1, 0}, {0, 0, 1}});
   136         inter.getSegment(test);
   140         TPolygon3D p3d({{1, 0, 0}, {0, 1, 0}, {0, 0, 1}});
   180         inter.getPoint(test);
   185 TEST(Geometry, IntersectionPlanePlane)
   201         EXPECT_FALSE(
intersect(plane1, plane2, inter));
   257 TEST(Geometry, PolygonConvexContainsPoint)
   260     std::vector<TPoint2D> vs;
   261     vs.emplace_back(-1.0, -1.0);
   262     vs.emplace_back(0.0, 1.0);
   263     vs.emplace_back(1.0, -1.0);
   267     std::reverse(vs.begin(), vs.end());
   281 TEST(Geometry, PolygonConcaveContainsPoint)
   284     std::vector<TPoint2D> vs;
   285     vs.emplace_back(-2.0, 3.0);
   286     vs.emplace_back(2.0, 2.0);
   287     vs.emplace_back(3.0, -4.0);
   288     vs.emplace_back(0.1, -3.0);
   289     vs.emplace_back(0.1, -0.1);
   290     vs.emplace_back(-0.1, -0.1);
   291     vs.emplace_back(-0.1, -3.0);
   292     vs.emplace_back(-2.0, -2.0);
   297     std::reverse(vs.begin(), vs.end());
   304     const double default_val = 1e-5;
   313         const auto l1 = 
TLine2D({0.0, 0.0}, {1.0, 0.0});
   314         const auto l2 = 
TLine2D({0.0, 2.0}, {1.0, 2.0001});
   330         std::vector<TPoint3D> pts = {
   331             {0., 0., 0.}, {1., 0., 0.}, {1., 1., 0.}, {0., 1., 0.}};
   335         std::vector<TPoint3D> pts = {
   336             {0., 0., 0.}, {0., 0., 1.}, {0., 1., 1.}, {0., 1., 0.}};
   340         std::vector<TPoint3D> pts = {
   341             {0., 0., 0.}, {0., 0., 1.}, {0., 1., 1.}, {0.1, 1., 0.1}};
   345         std::vector<TPoint3D> pts = {{5.56496063, -2.30508217, 29.53900000},
   346                                      {5.87949871, 0.00000000, 29.53900000},
   347                                      {13.50000000, 0.00000000, 0.00000000},
   348                                      {12.50465807, -7.29433126, 0.00000000}};
   355     const auto r1_xmin = -1.0, r1_xmax = 1.0, r1_ymin = -1.0, r1_ymax = 1.0;
   356     const auto r2_xmin = -2.0, r2_xmax = 2.0, r2_ymin = -3.0, r2_ymax = 3.0;
   360     using tst_set_t = std::array<double, 4>;
   363     const std::vector<tst_set_t> tsts = {
   364         {0, 0, 0.0_deg,  1},  {3.1, 0, 0.0_deg,  0},
   365         {-3.1, 0, 0.0_deg,  0}, {2.9, 0, 0.0_deg,  1},
   366         {-2.9, 0, 0.0_deg,  1}, {0, 4.1, 0.0_deg,  0},
   367         {0, 3.9, 0.0_deg,  1},  {0, -4.1, 0.0_deg,  0},
   368         {0, -3.9, 0.0_deg,  1}, {3.1, 0, 0.0_deg,  0},
   369         {3.1, 0, 45.0_deg,  1}, {3.1, 0, -90.0_deg,  1}};
   371     for (
const auto& t : tsts)
   376                 r1_xmin, r1_xmax, r1_ymin, r1_ymax, r2_xmin, r2_xmax, r2_ymin,
   377                 r2_ymax, p.x, p.y, p.phi),
 bool RectanglesIntersection(double R1_x_min, double R1_x_max, double R1_y_min, double R1_y_max, double R2_x_min, double R2_x_max, double R2_y_min, double R2_y_max, double R2_pose_x, double R2_pose_y, double R2_pose_phi)
Returns whether two rotated rectangles intersect. 
 
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate. 
 
void myTestPolygonContainsPoint(std::vector< TPoint2D > &vs, bool convex)
 
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
 
TPoint2D_< double > TPoint2D
Lightweight 2D point. 
 
unsigned char getType() const
Gets content type. 
 
void setEpsilon(double nE)
Changes the value of the geometric epsilon (default = 1e-5) 
 
Standard type for storing any lightweight 2D type. 
 
A wrapper of a TPolygon2D class, implementing CSerializable. 
 
static constexpr unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D. 
 
Standard object for storing any 3D lightweight object. 
 
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge). 
 
bool conformAPlane(const std::vector< TPoint3D > &points)
Checks whether this polygon or set of points acceptably fits a plane. 
 
static constexpr unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane. 
 
TEST(Geometry, Line2DIntersect)
 
This base provides a set of functions for maths stuff. 
 
2D segment, consisting of two points. 
 
3D segment, consisting of two points. 
 
bool isConvex() const
Checks whether is convex. 
 
3D Plane, represented by its equation  
 
TPoint3D_< double > TPoint3D
Lightweight 3D point. 
 
double getAngle(const TPlane &p1, const TPlane &p2)
Computes the angle between two planes. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5) 
 
constexpr double RAD2DEG(const double x)
Radians to degrees. 
 
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
 
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D. 
 
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
 
void AddVertex(double x, double y)
Add a new vertex to polygon. 
 
bool intersect(const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
Gets the intersection between two 3D segments. 
 
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D. 
 
2D polygon, inheriting from std::vector<TPoint2D>. 
 
3D polygon, inheriting from std::vector<TPoint3D> 
 
3D line, represented by a base point and a director vector. 
 
2D line without bounds, represented by its equation .