13template<fishnet::math::Number T = fishnet::math::DEFAULT_NUMERIC>
18 constexpr static auto hasher = std::hash<fishnet::math::DEFAULT_FLOATING_POINT>{};
51 throw std::invalid_argument(
"Coinciding Points cannot define a Line");
61 template<fishnet::math::Number U,
typename = std::enable_if_t<!std::is_same_v<U,T> && std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
71 template<fishnet::math::Number U,
typename = std::enable_if_t<!std::is_same_v<U,T> && std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
87 template<fishnet::math::Number U,
typename = std::enable_if_t<!std::is_same_v<U,T> && std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
97 template<fishnet::math::Number U,
typename = std::enable_if_t<!std::is_same_v<U,T> && std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
126 [[likely]]
if (intersectionWithY){
134 return std::numeric_limits<fishnet::math::DEFAULT_FLOATING_POINT>::max();
142 return point.x == _p.
x;
145 return point.y == _p.
y;
147 FLOAT_TYPE lX = FLOAT_TYPE(point.x - this->_p.x) / FLOAT_TYPE(dir.x);
148 FLOAT_TYPE lY = FLOAT_TYPE(point.y - this->_p.y) / FLOAT_TYPE(dir.y);
168 template<fishnet::math::Number U>
172 return this->_p.
x == other.p().x;
183 constexpr size_t hash() const noexcept {
184 size_t slopeHash = hasher(this->
slope());
185 size_t yInterceptHash = hasher(this->
yIntercept().value_or(this->_p.
x));
199template<math::Number T>
Implementation of a line.
Definition Line.hpp:14
constexpr Line(U slope, T yIntercept)
Constructor of line using slope and y intercept with heterogenous type.
Definition Line.hpp:98
constexpr Vec2D< T > p() const noexcept
Definition Line.hpp:100
constexpr size_t hash() const noexcept
Definition Line.hpp:183
constexpr Vec2D< T > q() const noexcept
Definition Line.hpp:104
constexpr bool isRight(IPoint auto const &point) const noexcept
Definition Line.hpp:156
constexpr fishnet::math::DEFAULT_FLOATING_POINT slope() const noexcept
Definition Line.hpp:132
constexpr bool isVertical() const noexcept
Definition Line.hpp:116
constexpr Line(Vec2D< T > _p, Vec2D< U > _q)
Constructor for a line with heterogenous numeric types Construct new line by converting to the defaul...
Definition Line.hpp:62
constexpr Line(Vec2D< T > _p, Vec2D< T > _q)
Constructor for a line formed by two points.
Definition Line.hpp:49
static constexpr Line< T > verticalLine(T x) noexcept
Vertical line factory.
Definition Line.hpp:28
constexpr fishnet::Option< Vec2DReal > intersection(LinearGeometry auto const &other) const noexcept
Definition Line.hpp:179
constexpr std::string toString() const
Definition Line.hpp:189
static constexpr GeometryType type
Definition Line.hpp:43
T numeric_type
Definition Line.hpp:42
constexpr Vec2D< T > direction() const noexcept
Definition Line.hpp:112
constexpr bool contains(IPoint auto const &point) const noexcept
Definition Line.hpp:138
constexpr Line< T > toLine() const noexcept
Definition Line.hpp:108
constexpr fishnet::Option< fishnet::math::DEFAULT_FLOATING_POINT > yIntercept() const noexcept
Definition Line.hpp:124
constexpr bool isLeft(IPoint auto const &point) const noexcept
Definition Line.hpp:152
constexpr bool isHorizontal() const noexcept
Definition Line.hpp:120
constexpr bool isParallel(LinearGeometry auto const &other) const noexcept
Definition Line.hpp:160
constexpr bool intersects(LinearGeometry auto const &other) const noexcept
Definition Line.hpp:164
static constexpr Line< T > horizontalLine(T y) noexcept
Horizontal line factory.
Definition Line.hpp:38
constexpr Line(Vec2D< U > _p, Vec2D< T > _q)
Constructor for a line with heterogenous numeric types Construct new line by converting to the defaul...
Definition Line.hpp:72
constexpr Line(T slope, T yIntercept)
Constructor of line using slope and y intercept.
Definition Line.hpp:78
constexpr Line(T slope, U yIntercept)
Constructor of line using slope and y intercept with heterogenous type.
Definition Line.hpp:88
constexpr bool operator==(const Line< U > &other) const noexcept
Definition Line.hpp:169
Implementation of a two-dimensional vector.
Definition Vec2D.hpp:16
T y
Definition Vec2D.hpp:21
constexpr auto cross(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:130
T x
Definition Vec2D.hpp:20
Interface for a line A line is defined through two points p and q, defining a direction vector.
Definition ILine.hpp:76
Interface for a point.
Definition IPoint.hpp:92
Definition IGeometry.hpp:13
Definition BoundingBoxWrapper.hpp:5
static constexpr fishnet::Option< Vec2DReal > linearIntersection(ILine auto const &l, ILine auto const &r) noexcept
Computation of line intersection.
Definition LinearIntersection.hpp:15
static constexpr bool areParallel(LinearGeometry auto const &lhs, LinearGeometry auto const &rhs) noexcept
Definition LinearIntersection.hpp:41
static constexpr bool intersect(LinearGeometry auto const &lhs, LinearGeometry auto const &rhs) noexcept
Definition LinearIntersection.hpp:45
GeometryType
Definition GeometryBase.hpp:6
static const Line< double > Y_AXIS
Definition Line.hpp:203
static const Line< double > X_AXIS
Definition Line.hpp:202
constexpr size_t CantorPairing(size_t x, size_t y) noexcept
Definition CantorPairing.hpp:5
static constexpr DEFAULT_FLOATING_POINT EPSILON
Definition Constants.hpp:20
double DEFAULT_FLOATING_POINT
Definition NumericConcepts.hpp:12
Definition BFSClustering.hpp:5
static string to_string(fishnet::geometry::GeometryType type) noexcept
Definition GeometryBase.hpp:22