17#include <teiacare/sdk/geometry/point.hpp>
37 constexpr line() =
default;
77 return (_start ==
other._start && _end ==
other._end) ||
78 (_start ==
other._end && _end ==
other._start);
97 return _start == _end;
106 return _start.x() == _end.x();
115 return _start.y() == _end.y();
172 return 0.0 <= value && value <= 1.0;
175 const double x_A =
static_cast<double>(_start.x());
176 const double y_A =
static_cast<double>(_start.y());
178 const double x_B =
static_cast<double>(_end.x());
179 const double y_B =
static_cast<double>(_end.y());
181 const double x_C =
static_cast<double>(
other._start.x());
182 const double y_C =
static_cast<double>(
other._start.y());
184 const double x_D =
static_cast<double>(
other._end.x());
185 const double y_D =
static_cast<double>(
other._end.y());
209 return std::string(
"(" + _start.to_string() +
" : " + _end.to_string() +
")");
220 return stream <<
l.to_string();
Thread safe, blocking queue.
2D line specified by a pair of start/end points.
constexpr tc::sdk::point< T > start() const noexcept
Start point getter.
constexpr bool is_null() const noexcept
Check if the line is a point.
constexpr bool operator!=(const line &other) const noexcept
Inequality operator.
constexpr line(const line &)=default
Copy Constructor. Copy a tc::sdk::line instance into another one.
constexpr line()=default
Default Constructor. Creates a default tc::sdk::line instance.
friend std::ostream & operator<<(std::ostream &stream, const line &l)
Output stream operator.
constexpr tc::sdk::point< T > end() const noexcept
End point getter.
constexpr std::string to_string() const
Get the line string representation.
void set_end(tc::sdk::point< T > end) noexcept
End point setter. Set the end point of the line.
constexpr line(line &&)=default
Move Constructor. Copy a tc::sdk::line instance into another one.
constexpr line(tc::sdk::point< T > start, tc::sdk::point< T > end) noexcept
Constructor. Creates tc::sdk::line instance with given start and end points.
line & operator=(line &&)=default
Move assignment operator. Assign a tc::sdk::line instance to another one.
std::optional< tc::sdk::point< double > > get_intersection(tc::sdk::line< T > other) const noexcept
Computes the intersection between the given line and the current one.
bool is_vertical() const noexcept
Check if the line is vertical.
void set_start(tc::sdk::point< T > start) noexcept
Start point setter. Set the start point of the line.
constexpr bool operator==(const line &other) const noexcept
Equality operator.
bool intersects(tc::sdk::line< T > other) const noexcept
Check if the given line segments intersects the current instance.
bool is_horizontal() const noexcept
Check if the line is horizontal.
line & operator=(const line &)=default
Assignment operator. Assign a tc::sdk::line instance to another one.