15template<fishnet::math::Number T=fishnet::math::DEFAULT_NUMERIC>
18 constexpr static auto hasher = std::hash<fishnet::math::DEFAULT_NUMERIC>{};
35 template<fishnet::math::Number U, fishnet::math::Number V>
37 if constexpr(std::is_same_v<U,V>){
39 }
else if constexpr(std::integral<U> && std::integral<V>){
40 if constexpr(
sizeof(U) >
sizeof(V)){
65 template<fishnet::math::Number U, fishnet::math::Number R,
typename = std::enable_if_t<(!std::is_same_v<U,T> || ! std::is_same_v<R,T>)&& std::is_same_v<T,fishnet::math::DEFAULT_NUMERIC>>>
80 template<fishnet::math::Number U>
82 return Vec2D<U>(
static_cast<U
>(
x),
static_cast<U
>(
y));
85 constexpr T
getX() const noexcept{
89 constexpr T
getY() const noexcept{
103 return construct(
x + other.getX(),
y + other.getY());
110 template<fishnet::math::Number U>
121 template<fishnet::math::Number U>
126 constexpr auto dot(
const IPoint auto & other)
const noexcept{
127 return x * other.getX() +
y * other.getY();
131 return x * other.getY() -
y * other.getX();
147 return (*
this-other).length();
164 auto dir = *
this - reference;
176 return angle(reference) + angleRotate;
179 constexpr size_t hash() const noexcept {
180 size_t xHash = hasher(this->x);
181 size_t yHash = hasher(this->y);
196 template<fishnet::math::Number T,fishnet::math::Number U>
199 return lhs.y < rhs.y;
200 return lhs.x < rhs.x;
208 template<fishnet::math::Number T,fishnet::math::Number U>
211 return lhs.x < rhs.x;
212 return lhs.y < rhs.y;
216static_assert(IPoint<Vec2D<double>>);
217static_assert(IPoint<Vec2D<int>>);
Implementation of a two-dimensional vector.
Definition Vec2D.hpp:16
constexpr auto operator/(fishnet::math::DEFAULT_NUMERIC scalar) const noexcept
Definition Vec2D.hpp:115
T y
Definition Vec2D.hpp:21
static constexpr GeometryType type
Definition Vec2D.hpp:24
constexpr auto operator*(U scalar) const noexcept
Definition Vec2D.hpp:111
constexpr auto cross(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:130
fishnet::math::Radians angle(const IPoint auto &reference) const
Definition Vec2D.hpp:163
constexpr auto operator-(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:106
constexpr bool operator==(const Vec2D< U > &other) const noexcept
Definition Vec2D.hpp:122
constexpr Vec2D()
Default construction to (0,0)
Definition Vec2D.hpp:72
constexpr bool isParallel(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:134
constexpr T getY() const noexcept
Definition Vec2D.hpp:89
T x
Definition Vec2D.hpp:20
static constexpr auto construct(U x, V y) noexcept
Helper factory method to construct the correct type of vector depending on the numeric types.
Definition Vec2D.hpp:36
constexpr fishnet::math::DEFAULT_FLOATING_POINT length() const
Definition Vec2D.hpp:142
constexpr T getX() const noexcept
Definition Vec2D.hpp:85
constexpr Vec2D(U x, R y)
Constructor for heterogenous types Converts to the default numeric type.
Definition Vec2D.hpp:66
constexpr size_t hash() const noexcept
Definition Vec2D.hpp:179
T numeric_type
Definition Vec2D.hpp:23
constexpr auto dot(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:126
constexpr std::string toString() const noexcept
Definition Vec2D.hpp:185
constexpr auto operator+(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:102
constexpr Vec2D(T x, T y)
Definition Vec2D.hpp:50
constexpr Vec2D< T > operator-() const
Negation operator e.g.: -Vec(2,1) => Vec(-2,-1)
Definition Vec2D.hpp:98
constexpr fishnet::math::DEFAULT_FLOATING_POINT distance(const IPoint auto &other) const
Definition Vec2D.hpp:146
constexpr Vec2D< T > orthogonal() const noexcept
Definition Vec2D.hpp:150
constexpr bool isOrthogonal(const IPoint auto &other) const noexcept
Definition Vec2D.hpp:138
fishnet::math::Radians angle(const IPoint auto &reference, fishnet::math::Radians angleRotate) const
Definition Vec2D.hpp:175
constexpr Vec2D< fishnet::math::DEFAULT_NUMERIC > normalize() const
Definition Vec2D.hpp:154
Radians implementation of Angle.
Definition Radians.hpp:11
static Radians atan2(double y, double x)
Definition Radians.cpp:46
Interface for a point.
Definition IPoint.hpp:92
Definition BoundingBoxWrapper.hpp:5
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_NUMERIC
Definition NumericConcepts.hpp:13
double DEFAULT_FLOATING_POINT
Definition NumericConcepts.hpp:12
constexpr bool isZero(T number) noexcept
Definition Constants.hpp:23
static string to_string(fishnet::geometry::GeometryType type) noexcept
Definition GeometryBase.hpp:22
Comparator for lexigraphically-ordering of Vec2D objects Compares first the x-Coordinate and then the...
Definition Vec2D.hpp:195
constexpr bool operator()(const Vec2D< T > &lhs, const Vec2D< U > &rhs) const noexcept
Definition Vec2D.hpp:197
Comparator for lexigraphically-ordering of Vec2D objects, with y Coordinate first.
Definition Vec2D.hpp:207
constexpr bool operator()(const Vec2D< T > &lhs, const Vec2D< U > &rhs) const noexcept
Definition Vec2D.hpp:209