LocalGuidance
A library that generates velocity references to follow a path.
robot_utils::geometry::Line Class Reference

#include <Line.hpp>

Inheritance diagram for robot_utils::geometry::Line:
Inheritance graph

Public Member Functions

 Line ()
 
 Line (const VertexList &vertices, robot_utils::geometry::VertexOrder vertexOrder=VertexOrder::CounterClockWise)
 
 Line (VertexList &&vertices, robot_utils::geometry::VertexOrder vertexOrder=VertexOrder::CounterClockWise)
 
 ~Line () override=default
 
double getArea () const override
 Get the area of the polygon (is negative if order is clock wise). More...
 
bool updateLineCoefficients () override
 Compute the line coefficients of all edges of the polygon. More...
 
bool isPointInPolygon (const Position2d &point, double tol=1e-6) const override
 Check if a point is in the polygon. More...
 
bool isPointInLHSPlane (const Position2d &point) const
 True if point is on the left hand side of the line. More...
 
double getLineLength () const
 
bool findIntersection (const Line &otherLine, Position2d &intersection) const
 
bool constructLargestConvexPolygonFromLines (const std::vector< Line > &lines, Polygon &convexHullPolygon)
 Given a set of lines, this function computes the vertices of the convex hull of all intersections. More...
 
bool isPolygonOnRHSOfLine (const Polygon &polygon) const
 True if the polygon lies completely on the RHS of the line. More...
 
bool isPolygonVertexOnRHSOfLine (const Polygon &polygon) const
 True if at least one vertex of the polygon lies on the RHS of the line. More...
 
bool doesPolygonIntersectLine (const Polygon &polygon) const
 True if line intersects the polygon. More...
 
- Public Member Functions inherited from robot_utils::geometry::Polygon
 Polygon ()
 
 Polygon (const VertexList &vertices, robot_utils::geometry::VertexOrder vertexOrder=robot_utils::geometry::VertexOrder::Undefined)
 
 Polygon (VertexList &&vertices, robot_utils::geometry::VertexOrder vertexOrder=robot_utils::geometry::VertexOrder::Undefined)
 
 Polygon (const Position2d &vertexCenter, unsigned int numOfVertices, double polygonSize)
 
 Polygon (const Position2d &vertexCenter, unsigned int numOfVertices, double polygonSize, const Eigen::Matrix2d &RotationMatrix2d)
 
 Polygon (const Polygon &polygon)
 
 Polygon (Polygon &&rhs)=default
 
Polygonoperator= (const Polygon &rhs)
 
Polygonoperator= (Polygon &&rhs)=default
 
virtual ~Polygon ()=default
 
double getPerimeter () const
 Get the perimeter of the polygon. More...
 
size_t getNumVertices () const
 Get the number of vertices. More...
 
void setVertex (const Position2d &vertex, unsigned int vertexId)
 Copy a vertex to the vertex list at a specific index. More...
 
const Position2dgetVertex (unsigned int vertexId) const
 Copy a vertex to the vertex list at a specific index. More...
 
void pushVertex (const Position2d &vertex)
 Add a vertex to the vertex list. More...
 
bool reorderVertices (VertexOrder vertexOrder)
 Reorder the vertices in clockwise or counter-clockwise order. More...
 
VertexOrder getVertexOrder () const
 Get the order in which the vertices are stored. More...
 
const LineCoefficientListgetLineCoefficients () const
 Get the set of line coefficients of all edges of the polygon. More...
 
const VertexListgetVertices () const
 Get the set of vertices. More...
 
bool resizePolygonTowardsInCenter (double lengthLineToLine)
 The edges of the polygon are moved with towards the incenter with a certain distance. More...
 
bool resizeVerticesTowardsCentroid (double percent)
 The polygon center is defined to be the centroid (average of all vertices). Vertices are. More...
 
bool resizeAreaTriangleBased (double percent)
 For each polygon, we extract one (random) triangle and move its vertices towards the incenter. More...
 
void resetVertices (unsigned int numOfVertices=0u)
 Emtpy the vertex list. More...
 
void print () const
 Print information about the polygon. More...
 
bool computePolygonCentroid (Eigen::Vector2d &center) const
 Compute centroid (polygon center). More...
 

Static Public Member Functions

static bool findIntersection (const Line &lineA, const Line &lineB, Position2d &intersection)
 
- Static Public Member Functions inherited from robot_utils::geometry::Polygon
static bool doPolygonsIntersect (const Polygon &polygonA, const Polygon &polygonB)
 
static void projectPolygonToRange (const Polygon &polygon, const Position2d &axisDirection, Eigen::Vector2d &range)
 Project the vertices of a polygon to a scalar range directed along an axis. More...
 
static bool doRangesOverlap (const Position2d &rangeA, const Position2d &rangeB)
 Check if two scalar ranges A = {a, b} and B = {c, d} overlap. More...
 

Additional Inherited Members

- Public Types inherited from robot_utils::geometry::Polygon
using VertexList = std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d >>
 
using LineCoefficientList = std::vector< std::vector< double >>
 
- Protected Attributes inherited from robot_utils::geometry::Polygon
VertexList vertices_
 A list of vertices. More...
 
robot_utils::geometry::VertexOrder vertexOrder_
 The order in which the vertices are stored. More...
 
LineCoefficientList lineCoefficients_
 The set of coefficients of the edges of the polygon. More...
 

Constructor & Destructor Documentation

robot_utils::geometry::Line::Line ( )
robot_utils::geometry::Line::Line ( const VertexList vertices,
robot_utils::geometry::VertexOrder  vertexOrder = VertexOrder::CounterClockWise 
)
explicit
robot_utils::geometry::Line::Line ( VertexList &&  vertices,
robot_utils::geometry::VertexOrder  vertexOrder = VertexOrder::CounterClockWise 
)
explicit
robot_utils::geometry::Line::~Line ( )
overridedefault

Member Function Documentation

bool robot_utils::geometry::Line::constructLargestConvexPolygonFromLines ( const std::vector< Line > &  lines,
Polygon convexHullPolygon 
)

Given a set of lines, this function computes the vertices of the convex hull of all intersections.

bool robot_utils::geometry::Line::doesPolygonIntersectLine ( const Polygon polygon) const

True if line intersects the polygon.

bool robot_utils::geometry::Line::findIntersection ( const Line otherLine,
Position2d intersection 
) const
static bool robot_utils::geometry::Line::findIntersection ( const Line lineA,
const Line lineB,
Position2d intersection 
)
static
double robot_utils::geometry::Line::getArea ( ) const
overridevirtual

Get the area of the polygon (is negative if order is clock wise).

Reimplemented from robot_utils::geometry::Polygon.

double robot_utils::geometry::Line::getLineLength ( ) const
bool robot_utils::geometry::Line::isPointInLHSPlane ( const Position2d point) const

True if point is on the left hand side of the line.

bool robot_utils::geometry::Line::isPointInPolygon ( const Position2d point,
double  tol = 1e-6 
) const
overridevirtual

Check if a point is in the polygon.

Reimplemented from robot_utils::geometry::Polygon.

bool robot_utils::geometry::Line::isPolygonOnRHSOfLine ( const Polygon polygon) const

True if the polygon lies completely on the RHS of the line.

bool robot_utils::geometry::Line::isPolygonVertexOnRHSOfLine ( const Polygon polygon) const

True if at least one vertex of the polygon lies on the RHS of the line.

bool robot_utils::geometry::Line::updateLineCoefficients ( )
overridevirtual

Compute the line coefficients of all edges of the polygon.

Reimplemented from robot_utils::geometry::Polygon.


The documentation for this class was generated from the following file: