12template<fishnet::math::Number T>
39 throw std::invalid_argument(
"Zero Vector not valid for the direction of a Ray");
42 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>>>
45 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>>>
49 return this->directionVector;
53 return this->originPoint;
57 return Line<T>(originPoint,originPoint+directionVector);
61 return Ray(originPoint, -directionVector);
78 if(point==originPoint)
80 if(directionVector.
x == 0){
81 return fishnet::math::areEqual(point.x,originPoint.
x) and (directionVector.
y > 0 ? point.y > originPoint.
y : point.y < originPoint.
y);
83 if(directionVector.
y == 0){
84 return fishnet::math::areEqual(point.y,originPoint.
y) and (directionVector.
x > 0 ? point.x > originPoint.
x : point.x < originPoint.
x);
86 FLOAT_TYPE lX = FLOAT_TYPE(point.x - originPoint.
x) / FLOAT_TYPE(directionVector.
x);
87 FLOAT_TYPE lY = FLOAT_TYPE(point.y - originPoint.
y) / FLOAT_TYPE(directionVector.
y);
91 template<fishnet::math::Number U>
100 constexpr size_t hash() const noexcept {
105 return "Ray "+this->originPoint.
toString()+
" + k * "+this->directionVector.
toString();
110template class Ray<fishnet::math::DEFAULT_NUMERIC>;
111static_assert(IRay<Ray<double>>);
112static_assert(LinearGeometry<Ray<double>>);
Implementation of a line.
Definition Line.hpp:14
Implementation of a ray A ray consist of an origin and the direction of the ray.
Definition Ray.hpp:13
constexpr Ray(Vec2D< U > origin, Vec2D< T > direction)
Definition Ray.hpp:46
constexpr Vec2D< T > direction() const noexcept
Definition Ray.hpp:48
constexpr std::optional< Vec2DReal > intersection(LinearGeometry auto const &other) const noexcept
Definition Ray.hpp:96
constexpr Ray(Vec2D< T > origin, Vec2D< U > direction)
Definition Ray.hpp:43
constexpr Ray< T > oppositeRay() const noexcept
Definition Ray.hpp:60
constexpr Line< T > toLine() const noexcept
Definition Ray.hpp:56
constexpr bool intersects(LinearGeometry auto const &other) const noexcept
Definition Ray.hpp:72
constexpr size_t hash() const noexcept
Definition Ray.hpp:100
constexpr Ray(Vec2D< T > origin, Vec2D< T > direction)
Definition Ray.hpp:37
constexpr Vec2D< T > origin() const noexcept
Definition Ray.hpp:52
T numeric_type
Definition Ray.hpp:18
constexpr bool isParallel(LinearGeometry auto const &other) const noexcept
Definition Ray.hpp:68
static constexpr Ray< T > down(Vec2D< T > origin) noexcept
Definition Ray.hpp:25
constexpr Ray< T > operator-() const
Definition Ray.hpp:64
constexpr bool contains(IPoint auto const &point) const noexcept
Definition Ray.hpp:76
static constexpr Ray< T > right(Vec2D< T > origin) noexcept
Definition Ray.hpp:29
constexpr bool operator==(const Ray< U > &other) const noexcept
Definition Ray.hpp:92
constexpr std::string toString() const
Definition Ray.hpp:104
static constexpr Ray< T > left(Vec2D< T > origin) noexcept
Definition Ray.hpp:33
static constexpr GeometryType type
Definition Ray.hpp:19
static constexpr Ray< T > up(Vec2D< T > origin) noexcept
Definition Ray.hpp:21
Implementation of a two-dimensional vector.
Definition Vec2D.hpp:16
T y
Definition Vec2D.hpp:21
T x
Definition Vec2D.hpp:20
constexpr size_t hash() const noexcept
Definition Vec2D.hpp:179
constexpr std::string toString() const noexcept
Definition Vec2D.hpp:185
constexpr Vec2D< fishnet::math::DEFAULT_NUMERIC > normalize() const
Definition Vec2D.hpp:154
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
constexpr bool areEqual(T lhs, U rhs) noexcept
Definition Constants.hpp:31
constexpr size_t CantorPairing(size_t x, size_t y) noexcept
Definition CantorPairing.hpp:5
double DEFAULT_FLOATING_POINT
Definition NumericConcepts.hpp:12