13 #include <gtest/gtest.h>
22 TEST(Geometry, Line2DIntersect)
31 EXPECT_TRUE(do_inter);
36 EXPECT_NEAR(i.
x, 0.5, 1e-9);
37 EXPECT_NEAR(i.
y, 0.5, 1e-9);
40 TEST(Geometry, Line2DAngle)
57 TEST(Geometry, Line3DAngle)
80 TEST(Geometry, Segment2DIntersect)
90 EXPECT_TRUE(do_inter);
95 EXPECT_NEAR(i.
x, 0.5, 1e-9);
96 EXPECT_NEAR(i.
y, 0.5, 1e-9);
105 bool do_inter =
intersect(s1, s2, inter);
107 EXPECT_FALSE(do_inter);
117 bool do_inter =
intersect(s1, s2, inter);
142 TEST(Geometry, PolygonConvexContainsPoint)
145 std::vector<TPoint2D> vs;
152 std::reverse(vs.begin(),vs.end());
157 p.AddVertex(0, -0.322);
158 p.AddVertex(-0.644, -0.322);
159 p.AddVertex(-0.210377, -0.324673);
160 p.AddVertex(0.433623, -0.324673);
162 EXPECT_FALSE (
p.contains(
TPoint2D(0.73175, -0.325796)));
166 TEST(Geometry, PolygonConcaveContainsPoint)
169 std::vector<TPoint2D> vs;
182 std::reverse(vs.begin(),vs.end());
A wrapper of a TPolygon2D class, implementing CSerializable.
2D polygon, inheriting from std::vector<TPoint2D>.
bool isConvex() const
Checks whether is convex.
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge). This works for concave...
TEST(Geometry, Line2DIntersect)
void myTestPolygonContainsPoint(std::vector< TPoint2D > &vs, bool convex)
const unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
const unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
bool BASE_IMPEXP intersect(const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
Gets the intersection between two 3D segments.
double BASE_IMPEXP getAngle(const TPlane &p1, const TPlane &p2)
Computes the angle between two planes.
This base provides a set of functions for maths stuff.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
double DEG2RAD(const double x)
Degrees to radians.
double RAD2DEG(const double x)
Radians to degrees.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
2D line without bounds, represented by its equation .
3D line, represented by a base point and a director vector.
Standard type for storing any lightweight 2D type.
unsigned char getType() const
Gets content type.
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate.
2D segment, consisting of two points.