9#include "../SIMD/module.hpp"
10#include "../utility/module.hpp"
14namespace hi::inline
v1 {
25 using array_type = simd<float, 4>;
26 using value_type = array_type::value_type;
30 constexpr point2& operator=(
point2 const&)
noexcept =
default;
31 constexpr point2& operator=(
point2&&)
noexcept =
default;
35 [[nodiscard]]
constexpr explicit operator array_type() const noexcept
42 [[nodiscard]]
constexpr explicit point2(array_type
const& other) noexcept : _v(other)
49 [[nodiscard]]
constexpr point2() noexcept : _v(0.0f, 0.0f, 0.0f, 1.0f) {}
55 [[nodiscard]]
constexpr point2(
float x,
float y) noexcept : _v(x, y, 0.0f, 1.0f) {}
60 [[nodiscard]]
constexpr float&
x() noexcept
68 [[nodiscard]]
constexpr float&
y() noexcept
76 [[nodiscard]]
constexpr float x() const noexcept
84 [[nodiscard]]
constexpr float y() const noexcept
89 constexpr point2& operator+=(vector2
const& rhs)
noexcept
91 return *
this = *
this + rhs;
94 constexpr point2& operator-=(vector2
const& rhs)
noexcept
96 return *
this = *
this - rhs;
106 return point2{lhs._v + array_type{rhs}};
116 return point2{array_type{lhs} + rhs._v};
126 return point2{lhs._v - array_type{rhs}};
136 return vector2{lhs._v - rhs._v};
146 return equal(lhs._v, rhs._v);
149 [[nodiscard]]
friend constexpr point2 midpoint(
point2 const& lhs,
point2 const& rhs)
noexcept
151 return point2{midpoint(lhs._v, rhs._v)};
154 [[nodiscard]]
friend constexpr point2 reflect(point2
const& lhs, point2
const& rhs)
noexcept
156 return point2{reflect_point(lhs._v, rhs._v)};
166 return point2{min(lhs._v, rhs._v)};
176 return point2{max(lhs._v, rhs._v)};
183 return point2{round(rhs._v)};
190 return point2{ceil(rhs._v)};
197 return point2{floor(rhs._v)};
204 hilet rhs_ = array_type{rhs}.xy11();
205 return point2{ceil(lhs._v / rhs_) * rhs_};
212 hilet rhs_ = array_type{rhs}.xy11();
213 return point2{floor(lhs._v / rhs_) * rhs_};
216 [[nodiscard]]
friend float distance(
point2 const& lhs,
point2 const& rhs)
noexcept
218 return hypot(rhs - lhs);
226 return _v.z() == 0.0f and _v.w() != 0.0f;
231 return std::format(
"<{}, {}>", rhs._v.x(), rhs._v.y());
236 return lhs << to_string(rhs);
245template<
typename CharT>
246struct std::formatter<
hi::point2, CharT> {
252 auto format(hi::point2
const& t,
auto& fc)
254 return std::vformat_to(fc.out(),
"<{}, {}>", std::make_format_args(t.x(), t.y()));
Defined the geo::extent, extent2 and extent3 types.
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
A high-level geometric point Part of the high-level vec, point, mat and color types.
Definition point2.hpp:23
friend constexpr point2 min(point2 const &lhs, point2 const &rhs) noexcept
Mix the two points and get the lowest value of each element.
Definition point2.hpp:164
constexpr bool holds_invariant() const noexcept
Check if the point is valid.
Definition point2.hpp:224
constexpr friend vector2 operator-(point2 const &lhs, point2 const &rhs) noexcept
Find the vector between two points.
Definition point2.hpp:134
constexpr friend bool operator==(point2 const &lhs, point2 const &rhs) noexcept
Compare if two points are equal.
Definition point2.hpp:144
friend constexpr point2 ceil(point2 const &lhs, extent2 rhs) noexcept
Round the coordinates of a point toward the top-right with the given granularity.
Definition point2.hpp:202
constexpr float & y() noexcept
Access the y element from the point.
Definition point2.hpp:68
friend constexpr point2 floor(point2 const &lhs, extent2 rhs) noexcept
Round the coordinates of a point toward the left-bottom with the given granularity.
Definition point2.hpp:210
friend constexpr point2 round(point2 const &rhs) noexcept
Round the coordinates of a point toward nearest integer.
Definition point2.hpp:181
constexpr point2(float x, float y) noexcept
Construct a 3D point from x, y and z elements.
Definition point2.hpp:55
constexpr friend point2 operator-(point2 const &lhs, vector2 const &rhs) noexcept
Move a point backward along the vector.
Definition point2.hpp:124
constexpr float & x() noexcept
Access the x element from the point.
Definition point2.hpp:60
friend constexpr point2 max(point2 const &lhs, point2 const &rhs) noexcept
Mix the two points and get the highest value of each element.
Definition point2.hpp:174
friend constexpr point2 ceil(point2 const &rhs) noexcept
Round the coordinates of a point toward the right-top.
Definition point2.hpp:188
constexpr float y() const noexcept
Access the y element from the point.
Definition point2.hpp:84
constexpr point2(array_type const &other) noexcept
Construct a point from a array_type-simd.
Definition point2.hpp:42
constexpr friend point2 operator+(point2 const &lhs, vector2 const &rhs) noexcept
Move a point along a vector.
Definition point2.hpp:104
constexpr friend point2 operator+(vector2 const &lhs, point2 const &rhs) noexcept
Move a point along a vector.
Definition point2.hpp:114
friend constexpr point2 floor(point2 const &rhs) noexcept
Round the coordinates of a point toward the left-bottom.
Definition point2.hpp:195
constexpr float x() const noexcept
Access the x element from the point.
Definition point2.hpp:76
constexpr point2() noexcept
Construct a point at the origin of the coordinate system.
Definition point2.hpp:49