32#ifndef RCSC_GEOM_SEGMENT2D_H
33#define RCSC_GEOM_SEGMENT2D_H
49 static const double EPSILON;
50 static const double CALC_ERROR;
58 bool checkIntersectsOnLine(
const Vector2D & p )
const;
80 const double & origin_y,
81 const double & terminal_x,
82 const double & terminal_y )
83 : M_origin( origin_x, origin_y ),
84 M_terminal( terminal_x, terminal_y )
124 Segment2D &
assign(
const double & origin_x,
125 const double & origin_y,
126 const double & terminal_x,
127 const double & terminal_y )
129 M_origin.
assign( origin_x, origin_y );
130 M_terminal.
assign( terminal_x, terminal_y );
219 M_origin = M_terminal;
240 return Segment2D( *this ).
reverse();
268 bool equals(
const Segment2D & other )
const
302 const bool allow_end_point )
const;
415 std::ostream &
print( std::ostream & os )
const
degree wrapper class
Definition angle_deg.h:45
2d straight line class
Definition line_2d.h:47
static Line2D perpendicular_bisector(const Vector2D &p1, const Vector2D &p2)
make perpendicular bisector line from twt points
Definition line_2d.cpp:69
2d segment line class
Definition segment_2d.h:46
const Segment2D & reverse()
swap segment edge point. This method is equivalent to swap(), provided for convenience.
Definition segment_2d.h:229
Segment2D(const Vector2D &origin, const double &length, const AngleDeg &dir)
construct using origin, direction and length
Definition segment_2d.h:93
Vector2D projection(const Vector2D &p) const
calculates projection point from p
Definition segment_2d.cpp:52
double dist(const Vector2D &p) const
get minimum distance between this segment and point
Definition segment_2d.cpp:312
double farthestDist(const Vector2D &p) const
get maximum distance between this segment and point
Definition segment_2d.cpp:366
bool contains(const Vector2D &p) const
check if the point is within the rectangle defined by this segment as a diagonal line.
Definition segment_2d.h:257
const Vector2D & terminal() const
get 2nd point of segment edge
Definition segment_2d.h:176
bool intersects(const Line2D &l) const
check if this line segment intersects with target line.
Definition segment_2d.h:362
bool isValid() const
check if this line segment is valid or not. origin's coodinates value have to be different from termi...
Definition segment_2d.h:156
const Segment2D & swap()
swap segment edge point
Definition segment_2d.h:215
bool onSegment(const Vector2D &p) const
strictly check if point is on segment or not
Definition segment_2d.cpp:377
double length() const
get the length of this segment
Definition segment_2d.h:194
Vector2D nearestPoint(const Vector2D &p) const
get a point on segment where distance of point is minimal.
Definition segment_2d.cpp:273
Segment2D reversedSegment() const
get the reversed line segment.
Definition segment_2d.h:238
bool existIntersection(const Segment2D &other) const
check if segments cross each other or not.
Definition segment_2d.cpp:190
AngleDeg direction() const
get the direction angle of this line segment
Definition segment_2d.h:203
bool onSegmentWeakly(const Vector2D &p) const
weakly check if point is on segment or not
Definition segment_2d.cpp:389
bool equals(const Segment2D &other) const
check if this line segment has completely same value as input line segment.
Definition segment_2d.h:268
Line2D perpendicularBisector() const
make perpendicular bisector line from segment points
Definition segment_2d.h:247
bool intersectsExceptEndpoint(const Segment2D &other) const
check if segments intersect each other on non terminal point.
Definition segment_2d.h:345
Line2D line() const
get line generated from segment
Definition segment_2d.h:185
std::ostream & print(std::ostream &os) const
print data to an output stream.
Definition segment_2d.h:415
Segment2D(const double &origin_x, const double &origin_y, const double &terminal_x, const double &terminal_y)
construct directly using raw coordinate values
Definition segment_2d.h:79
bool existIntersectionExceptEndpoint(const Segment2D &other) const
check if segments intersect each other on non terminal point.
Definition segment_2d.cpp:169
Segment2D(const Vector2D &origin, const Vector2D &terminal)
construct from 2 points
Definition segment_2d.h:66
Vector2D intersection(const Segment2D &other, const bool allow_end_point) const
check & get the intersection point with other line segment
Definition segment_2d.cpp:92
const Vector2D & origin() const
get 1st point of segment edge
Definition segment_2d.h:166
bool intersects(const Segment2D &other) const
check if segments cross each other or not.
Definition segment_2d.h:324
const Segment2D & assign(const double &origin_x, const double &origin_y, const double &terminal_x, const double &terminal_y)
construct directly using raw coordinate values
Definition segment_2d.h:124
const Segment2D & assign(const Vector2D &origin, const Vector2D &terminal)
construct from 2 points
Definition segment_2d.h:107
bool equalsWeakly(const Segment2D &other) const
check if this line segment has weakly same value as input line segment.
Definition segment_2d.h:279
const Segment2D & assign(const Vector2D &origin, const double &length, const AngleDeg &dir)
construct using origin, direction and length
Definition segment_2d.h:142
2D point vector class
Definition vector_2d.h:47
static Vector2D from_polar(const double &mag, const AngleDeg &theta)
get new Vector created by POLAR value.
Definition vector_2d.h:574
double dist(const Vector2D &p) const
get the distance from this to 'p'.
Definition vector_2d.h:366
double y
Y coordinate.
Definition vector_2d.h:65
double x
X coordinate.
Definition vector_2d.h:64
bool equals(const Vector2D &other) const
check if this vector is strictly same as given vector.
Definition vector_2d.h:531
bool equalsWeakly(const Vector2D &other) const
check if this vector is weakly same as given vector.
Definition vector_2d.h:542
2d vector class Header File.
2D straight line Header File.