12 #include <gtest/gtest.h> 19 TEST(Geometry, Line2DIntersect)
28 EXPECT_TRUE(do_inter);
33 EXPECT_NEAR(i.x, 0.5, 1e-9);
34 EXPECT_NEAR(i.y, 0.5, 1e-9);
37 TEST(Geometry, Segment2DIntersect)
47 EXPECT_TRUE(do_inter);
52 EXPECT_NEAR(i.x, 0.5, 1e-9);
53 EXPECT_NEAR(i.y, 0.5, 1e-9);
64 EXPECT_FALSE(do_inter);
75 EXPECT_FALSE(do_inter);
79 TEST(Geometry, Intersection3D)
96 inter.getSegment(test);
125 EXPECT_TRUE(
intersect(s3d1, s3d2, inter));
140 EXPECT_TRUE(
intersect(s3d1, s3d2, inter));
145 inter.getPoint(test);
146 EXPECT_EQ(expect, test);
150 TEST(Geometry, IntersectionPlanePlane)
166 EXPECT_FALSE(
intersect(plane1, plane2, inter));
182 EXPECT_TRUE(
intersect(plane1, plane2, inter));
199 EXPECT_TRUE(
intersect(plane1, plane2, inter));
222 TEST(Geometry, PolygonConvexContainsPoint)
225 std::vector<TPoint2D> vs;
232 std::reverse(vs.begin(), vs.end());
237 p.AddVertex(0, -0.322);
238 p.AddVertex(-0.644, -0.322);
239 p.AddVertex(-0.210377, -0.324673);
240 p.AddVertex(0.433623, -0.324673);
242 EXPECT_FALSE(
p.contains(
TPoint2D(0.73175, -0.325796)));
246 TEST(Geometry, PolygonConcaveContainsPoint)
249 std::vector<TPoint2D> vs;
262 std::reverse(vs.begin(), vs.end());
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)
static constexpr unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
unsigned char getType() const
Gets content type.
Standard type for storing any lightweight 2D type.
A wrapper of a TPolygon2D class, implementing CSerializable.
Standard object for storing any 3D lightweight object.
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
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.
3D Plane, represented by its equation
bool isConvex() const
Checks whether is convex.
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool intersect(const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
Gets the intersection between two 3D segments.
static constexpr unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
2D polygon, inheriting from std::vector<TPoint2D>.
3D polygon, inheriting from std::vector<TPoint3D>
2D line without bounds, represented by its equation .