6namespace fishnet::geometry::__impl{
14 using numeric_type = T;
15 constexpr static GeometryType type = GeometryType::POINT;
16 constexpr PointStub(T x, T y) : x(x), y(y) {}
17 T getX() const noexcept{
20 T getY() const noexcept{
23 PointStub operator-() const noexcept{
24 return PointStub(-x, -y);
26 PointStub operator+(
const PointStub & other)
const noexcept{
27 return PointStub(x + other.x, y + other.y);
29 PointStub operator-(
const PointStub & other)
const noexcept{
30 return PointStub(x - other.x, y - other.y);
32 PointStub operator*(T scalar)
const noexcept{
33 return PointStub(x * scalar, y * scalar);
35 PointStub operator/(T scalar)
const noexcept{
36 return PointStub(x / scalar, y / scalar);
38 bool operator==(
const PointStub & other)
const noexcept{
39 return x == other.x && y == other.y;
41 double dot(
const PointStub & other)
const noexcept{
44 double cross(
const PointStub & other)
const noexcept{
47 bool isParallel(
const PointStub & other)
const noexcept{
50 bool isOrthogonal(
const PointStub & other)
const noexcept{
53 double length() const noexcept{
56 double distance(
const PointStub & other)
const noexcept{
59 PointStub orthogonal() const noexcept{
60 return PointStub(0,0);
62 PointStub normalize() const noexcept{
63 return PointStub(0,0);
71 size_t hash() const noexcept {
74 std::string toString() const noexcept {
78template<fishnet::math::Number T>
79constexpr auto operator*(T scalar,
const PointStub<T> & point)
noexcept{
80 return point * scalar;
93 const typename std::remove_cvref_t<P> & constPoint,
94 const __impl::PointStub<typename std::remove_cvref_t<P>::numeric_type> & otherPoint,
95 typename std::remove_cvref_t<P>::numeric_type number
97 {constPoint.getX()} -> std::convertible_to<typename std::remove_cvref_t<P>::numeric_type>;
98 {constPoint.getY()} -> std::convertible_to<typename std::remove_cvref_t<P>::numeric_type>;
99 {std::remove_cvref_t<P>(number, number)} -> std::same_as<std::remove_cvref_t<P>>;
100 {-constPoint} -> std::same_as<std::remove_cvref_t<P>>;
101 {constPoint + otherPoint} -> std::same_as<std::remove_cvref_t<P>>;
102 {constPoint - otherPoint} -> std::same_as<std::remove_cvref_t<P>>;
103 {constPoint * number} -> std::same_as<std::remove_cvref_t<P>>;
104 {constPoint / number} -> std::convertible_to<std::remove_cvref_t<P>>;
105 {constPoint.dot(otherPoint)} -> std::convertible_to<typename std::remove_cvref_t<P>::numeric_type>;
106 {constPoint.cross(otherPoint)} -> std::convertible_to<typename std::remove_cvref_t<P>::numeric_type>;
107 {constPoint.isParallel(otherPoint)} -> std::same_as<bool>;
108 {constPoint.isOrthogonal(otherPoint)} -> std::same_as<bool>;
109 {constPoint.length()} -> std::convertible_to<double>;
110 {constPoint.distance(otherPoint)} -> std::convertible_to<double>;
111 {constPoint.orthogonal()} -> std::same_as<std::remove_cvref_t<P>>;
112 {constPoint.normalize()} -> std::convertible_to<std::remove_cvref_t<P>>;
113 {constPoint.angle(otherPoint)} -> std::same_as<fishnet::math::Radians>;
126template<fishnet::math::Number T, fishnet::math::Number U>
128 return vector * scalar;
131static_assert(IPoint<__impl::PointStub<double>>,
"PointStub<double> does not satisfy IPoint concept");
132static_assert(IPoint<__impl::PointStub<int>>,
"PointStub<int> does not satisfy IPoint concept");
IPolygon implementation backed by an OGRPolygon.
Definition OGRPolygonAdapter.hpp:22
Radians implementation of Angle.
Definition Radians.hpp:11
static const Radians PI
Definition Radians.hpp:20
Definition GeometryBase.hpp:11
Definition IPoint.hpp:135
Interface for a point.
Definition IPoint.hpp:92
Definition IPoint.hpp:138
Definition BoundingBoxWrapper.hpp:5
constexpr auto operator*(U scalar, const IPoint auto &vector) noexcept
Reversed multiplication operator, allowing commutative behavior: e.g.: Vec2D(1,1) * 2 == 2 * Vec2D(1,...
Definition IPoint.hpp:127