LARS
LARS (Light Augmented Reality System) is an open-source framework for light-based interaction and real-time tracking in multi-robot experiments. Inspired by ARK, LARS extends the augmented reality paradigm to robotic collectives by projecting dynamic visual cues and environments onto the arena, enabling new experimental possibilities for collective robotics research, education, and outreach. LARS features integrated tracking, light projection, and modular experiment control with a user-friendly Qt GUI.
Loading...
Searching...
No Matches
rcsc::Segment2D Class Reference

2d segment line class More...

#include <segment_2d.h>

Public Member Functions

 Segment2D (const Vector2D &origin, const Vector2D &terminal)
 construct from 2 points
 Segment2D (const double &origin_x, const double &origin_y, const double &terminal_x, const double &terminal_y)
 construct directly using raw coordinate values
 Segment2D (const Vector2D &origin, const double &length, const AngleDeg &dir)
 construct using origin, direction and length
const Segment2Dassign (const Vector2D &origin, const Vector2D &terminal)
 construct from 2 points
const Segment2Dassign (const double &origin_x, const double &origin_y, const double &terminal_x, const double &terminal_y)
 construct directly using raw coordinate values
const Segment2Dassign (const Vector2D &origin, const double &length, const AngleDeg &dir)
 construct using origin, direction and length
bool isValid () const
 check if this line segment is valid or not. origin's coodinates value have to be different from terminal's one.
const Vector2Dorigin () const
 get 1st point of segment edge
const Vector2Dterminal () const
 get 2nd point of segment edge
Line2D line () const
 get line generated from segment
double length () const
 get the length of this segment
AngleDeg direction () const
 get the direction angle of this line segment
const Segment2Dswap ()
 swap segment edge point
const Segment2Dreverse ()
 swap segment edge point. This method is equivalent to swap(), provided for convenience.
Segment2D reversedSegment () const
 get the reversed line segment.
Line2D perpendicularBisector () const
 make perpendicular bisector line from segment points
bool contains (const Vector2D &p) const
 check if the point is within the rectangle defined by this segment as a diagonal line.
bool equals (const Segment2D &other) const
 check if this line segment has completely same value as input line segment.
bool equalsWeakly (const Segment2D &other) const
 check if this line segment has weakly same value as input line segment.
Vector2D projection (const Vector2D &p) const
 calculates projection point from p
Vector2D intersection (const Segment2D &other, const bool allow_end_point) const
 check & get the intersection point with other line segment
Vector2D intersection (const Line2D &l) const
 check & get the intersection point with other line
bool existIntersection (const Segment2D &other) const
 check if segments cross each other or not.
bool intersects (const Segment2D &other) const
 check if segments cross each other or not.
bool existIntersectionExceptEndpoint (const Segment2D &other) const
 check if segments intersect each other on non terminal point.
bool intersectsExceptEndpoint (const Segment2D &other) const
 check if segments intersect each other on non terminal point.
bool existIntersection (const Line2D &l) const
 check if this line segment intersects with target line.
bool intersects (const Line2D &l) const
 check if this line segment intersects with target line.
Vector2D nearestPoint (const Vector2D &p) const
 get a point on segment where distance of point is minimal.
double dist (const Vector2D &p) const
 get minimum distance between this segment and point
double dist (const Segment2D &seg) const
 get minimum distance between 2 segments
double farthestDist (const Vector2D &p) const
 get maximum distance between this segment and point
bool onSegment (const Vector2D &p) const
 strictly check if point is on segment or not
bool onSegmentWeakly (const Vector2D &p) const
 weakly check if point is on segment or not
std::ostream & print (std::ostream &os) const
 print data to an output stream.

Detailed Description

2d segment line class

Constructor & Destructor Documentation

◆ Segment2D() [1/3]

rcsc::Segment2D::Segment2D ( const Vector2D & origin,
const Vector2D & terminal )
inline

construct from 2 points

Parameters
origin1st point of segment edge
terminal2nd point of segment edge

◆ Segment2D() [2/3]

rcsc::Segment2D::Segment2D ( const double & origin_x,
const double & origin_y,
const double & terminal_x,
const double & terminal_y )
inline

construct directly using raw coordinate values

Parameters
origin_x1st point x value of segment edge
origin_y1st point x value of segment edge
terminal_x2nd point y value of segment edge
terminal_y2nd point y value of segment edge

◆ Segment2D() [3/3]

rcsc::Segment2D::Segment2D ( const Vector2D & origin,
const double & length,
const AngleDeg & dir )
inline

construct using origin, direction and length

Parameters
originorigin point
lengthlength of line segment
dirline direction from origin point

Member Function Documentation

◆ assign() [1/3]

const Segment2D & rcsc::Segment2D::assign ( const double & origin_x,
const double & origin_y,
const double & terminal_x,
const double & terminal_y )
inline

construct directly using raw coordinate values

Parameters
origin_x1st point x value of segment edge
origin_y1st point x value of segment edge
terminal_x2nd point y value of segment edge
terminal_y2nd point y value of segment edge
Returns
const reference to this object

◆ assign() [2/3]

const Segment2D & rcsc::Segment2D::assign ( const Vector2D & origin,
const double & length,
const AngleDeg & dir )
inline

construct using origin, direction and length

Parameters
originorigin point
lengthlength of line segment
dirline direction from origin point
Returns
const reference to this object

◆ assign() [3/3]

const Segment2D & rcsc::Segment2D::assign ( const Vector2D & origin,
const Vector2D & terminal )
inline

construct from 2 points

Parameters
originfirst point
terminalsecond point
Returns
const reference to this object

◆ contains()

bool rcsc::Segment2D::contains ( const Vector2D & p) const
inline

check if the point is within the rectangle defined by this segment as a diagonal line.

Returns
true if rectangle contains p

◆ direction()

AngleDeg rcsc::Segment2D::direction ( ) const
inline

get the direction angle of this line segment

Returns
angle object

◆ dist() [1/2]

double rcsc::Segment2D::dist ( const Segment2D & seg) const

get minimum distance between 2 segments

Parameters
segsegment
Returns
minimum distance between 2 segments

◆ dist() [2/2]

double rcsc::Segment2D::dist ( const Vector2D & p) const

get minimum distance between this segment and point

Parameters
ppoint
Returns
minimum distance between this segment and point

◆ equals()

bool rcsc::Segment2D::equals ( const Segment2D & other) const
inline

check if this line segment has completely same value as input line segment.

Parameters
othercompared object.
Returns
checked result.

◆ equalsWeakly()

bool rcsc::Segment2D::equalsWeakly ( const Segment2D & other) const
inline

check if this line segment has weakly same value as input line segment.

Parameters
othercompared object.
Returns
checked result.

◆ existIntersection() [1/2]

bool rcsc::Segment2D::existIntersection ( const Line2D & l) const

check if this line segment intersects with target line.

Parameters
lchecked line
Returns
checked result

◆ existIntersection() [2/2]

bool rcsc::Segment2D::existIntersection ( const Segment2D & other) const

check if segments cross each other or not.

Parameters
othersegment for cross checking
Returns
true if this segment crosses, otherwise returns false.

◆ existIntersectionExceptEndpoint()

bool rcsc::Segment2D::existIntersectionExceptEndpoint ( const Segment2D & other) const

check if segments intersect each other on non terminal point.

Parameters
othersegment for cross checking
Returns
true if segments intersect and intersection point is not a terminal point of segment. false if segments do not intersect or intersect on terminal point of segment.

◆ farthestDist()

double rcsc::Segment2D::farthestDist ( const Vector2D & p) const

get maximum distance between this segment and point

Parameters
ppoint
Returns
maximum distance between this segment and point

◆ intersection() [1/2]

Vector2D rcsc::Segment2D::intersection ( const Line2D & l) const

check & get the intersection point with other line

Parameters
lchecked line object
Returns
intersection point. if it does not exist, the invalidated value vector is returned.

◆ intersection() [2/2]

Vector2D rcsc::Segment2D::intersection ( const Segment2D & other,
const bool allow_end_point ) const

check & get the intersection point with other line segment

Parameters
otherchecked line segment
allow_end_pointif this value is false, an end point is disallowed as an intersection.
Returns
intersection point. if it does not exist, the invalidated value vector is returned.

◆ intersects() [1/2]

bool rcsc::Segment2D::intersects ( const Line2D & l) const
inline

check if this line segment intersects with target line.

Parameters
lchecked line
Returns
checked result

◆ intersects() [2/2]

bool rcsc::Segment2D::intersects ( const Segment2D & other) const
inline

check if segments cross each other or not.

Parameters
othersegment for cross checking
Returns
true if this segment crosses, otherwise returns false.

◆ intersectsExceptEndpoint()

bool rcsc::Segment2D::intersectsExceptEndpoint ( const Segment2D & other) const
inline

check if segments intersect each other on non terminal point.

Parameters
othersegment for cross checking
Returns
true if segments intersect and intersection point is not a terminal point of segment. false if segments do not intersect or intersect on terminal point of segment.

◆ isValid()

bool rcsc::Segment2D::isValid ( ) const
inline

check if this line segment is valid or not. origin's coodinates value have to be different from terminal's one.

Returns
checked result.

◆ length()

double rcsc::Segment2D::length ( ) const
inline

get the length of this segment

Returns
distance value

◆ line()

Line2D rcsc::Segment2D::line ( ) const
inline

get line generated from segment

Returns
new line object

◆ nearestPoint()

Vector2D rcsc::Segment2D::nearestPoint ( const Vector2D & p) const

get a point on segment where distance of point is minimal.

Parameters
ppoint
Returns
nearest point on segment. if multiple nearest points found. returns one of them.

◆ onSegment()

bool rcsc::Segment2D::onSegment ( const Vector2D & p) const

strictly check if point is on segment or not

Parameters
pchecked point
Returns
true if point is on this segment

◆ onSegmentWeakly()

bool rcsc::Segment2D::onSegmentWeakly ( const Vector2D & p) const

weakly check if point is on segment or not

Parameters
pchecked point
Returns
true if point is on this segment

◆ origin()

const Vector2D & rcsc::Segment2D::origin ( ) const
inline

get 1st point of segment edge

Returns
const reference to the vector object

◆ perpendicularBisector()

Line2D rcsc::Segment2D::perpendicularBisector ( ) const
inline

make perpendicular bisector line from segment points

Returns
line object

◆ print()

std::ostream & rcsc::Segment2D::print ( std::ostream & os) const
inline

print data to an output stream.

Parameters
osreference to the output stream
Returns
reference to the output stream

◆ projection()

Vector2D rcsc::Segment2D::projection ( const Vector2D & p) const

calculates projection point from p

Parameters
pinput point
Returns
projection point from p. if it does not exist, the invalidated value vector is returned.

◆ reverse()

const Segment2D & rcsc::Segment2D::reverse ( )
inline

swap segment edge point. This method is equivalent to swap(), provided for convenience.

Returns
const reference to this object

◆ reversedSegment()

Segment2D rcsc::Segment2D::reversedSegment ( ) const
inline

get the reversed line segment.

Returns
const reference to this object

◆ swap()

const Segment2D & rcsc::Segment2D::swap ( )
inline

swap segment edge point

Returns
const reference to this object

◆ terminal()

const Vector2D & rcsc::Segment2D::terminal ( ) const
inline

get 2nd point of segment edge

Returns
const reference to the vector object

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