7#include "../numeric_array.hpp"
23 static_assert(D == 2 || D == 3,
"Only 2D or 3D points are supported");
25 constexpr point(
point const &)
noexcept =
default;
27 constexpr point &operator=(
point const &)
noexcept =
default;
28 constexpr point &operator=(
point &&)
noexcept =
default;
33 requires(E < D) [[nodiscard]]
constexpr point(
point<E> const &other) noexcept : _v(
static_cast<f32x4>(other))
40 [[nodiscard]]
constexpr explicit operator f32x4() const noexcept
48 [[nodiscard]]
constexpr explicit point(
f32x4 const &other) noexcept : _v(other)
55 [[nodiscard]]
constexpr point() noexcept : _v(0.0, 0.0, 0.0, 1.0) {}
61 [[nodiscard]]
constexpr point(
float x,
float y)
noexcept requires(D == 2) : _v(
x,
y, 0.0, 1.0) {}
68 [[nodiscard]]
constexpr point(
float x,
float y,
float z = 0.0) noexcept requires(D == 3) : _v(
x,
y,
z, 1.0) {}
73 [[nodiscard]]
constexpr float &
x() noexcept
81 [[nodiscard]]
constexpr float &
y() noexcept
89 [[nodiscard]]
constexpr float &
z() noexcept requires(D == 3)
97 [[nodiscard]]
constexpr float const &
x() const noexcept
105 [[nodiscard]]
constexpr float const &
y() const noexcept
113 [[nodiscard]]
constexpr float const &
z() const noexcept requires(D == 3)
126 tt_axiom(lhs.is_valid() && rhs.is_valid());
138 tt_axiom(lhs.is_valid() && rhs.is_valid());
150 tt_axiom(lhs.is_valid() && rhs.is_valid());
161 tt_axiom(lhs.is_valid() && rhs.is_valid());
172 tt_axiom(lhs.is_valid() && rhs.is_valid());
173 return lhs._v == rhs._v;
177 [[nodiscard]]
friend constexpr auto midpoint(
point const &lhs,
point<E> const &rhs)
noexcept
183 [[nodiscard]]
friend constexpr auto reflect(
point const &lhs, point<E>
const &rhs)
noexcept
185 return point<
std::max(D, E)>{reflect_point(
static_cast<f32x4
>(lhs),
static_cast<f32x4
>(rhs))};
191 [[nodiscard]]
constexpr bool is_valid() const noexcept
193 return _v.w() != 0.0f && (D == 3 || _v.z() == 0.0f);
202using point2 = geo::point<2>;
203using point3 = geo::point<3>;
A high-level geometric point Part of the high-level vec, point, mat and color types.
Definition point.hpp:21
constexpr friend point< std::max(D, E)> operator+(vector< E > const &rhs, point const &lhs) noexcept
Move a point along a vector.
Definition point.hpp:136
constexpr float & x() noexcept
Access the x element from the point.
Definition point.hpp:73
constexpr float const & y() const noexcept
Access the y element from the point.
Definition point.hpp:105
constexpr point(float x, float y) noexcept
Construct a 2D point from x and y elements.
Definition point.hpp:61
constexpr friend point< std::max(D, E)> operator+(point const &lhs, vector< E > const &rhs) noexcept
Move a point along a vector.
Definition point.hpp:124
constexpr point(float x, float y, float z=0.0) noexcept
Construct a 3D point from x, y and z elements.
Definition point.hpp:68
constexpr point(point< E > const &other) noexcept
Construct a point from a lower dimension point.
Definition point.hpp:33
constexpr point(f32x4 const &other) noexcept
Construct a point from a f32x4-numeric_array.
Definition point.hpp:48
constexpr float const & z() const noexcept
Access the z element from the point.
Definition point.hpp:113
constexpr friend vector< D > operator-(point const &lhs, point const &rhs) noexcept
Find the vector between two points.
Definition point.hpp:159
constexpr point() noexcept
Construct a point at the origin of the coordinate system.
Definition point.hpp:55
constexpr friend bool operator==(point const &lhs, point const &rhs) noexcept
Compare if two points are equal.
Definition point.hpp:170
constexpr bool is_valid() const noexcept
Check if the point is valid.
Definition point.hpp:191
constexpr friend point< std::max(D, E)> operator-(point const &lhs, vector< E > const &rhs) noexcept
Move a point backward along the vector.
Definition point.hpp:148
constexpr float const & x() const noexcept
Access the x element from the point.
Definition point.hpp:97
constexpr float & z() noexcept
Access the z element from the point.
Definition point.hpp:89
constexpr float & y() noexcept
Access the y element from the point.
Definition point.hpp:81
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector.hpp:20