10#include "../SIMD/module.hpp"
11#include "../utility/module.hpp"
15namespace hi::inline
v1 {
26 using array_type = simd<float, 4>;
27 using value_type = array_type::value_type;
31 constexpr point3& operator=(
point3 const&)
noexcept =
default;
32 constexpr point3& operator=(
point3&&)
noexcept =
default;
36 [[nodiscard]]
constexpr point3(
point2 const& other) noexcept : _v(
static_cast<array_type
>(other)) {}
38 [[nodiscard]]
constexpr explicit operator point2() const noexcept
47 [[nodiscard]]
constexpr point3(
point2 const& other,
float z) noexcept : _v(
static_cast<array_type
>(other))
54 [[nodiscard]]
constexpr explicit operator array_type() const noexcept
61 [[nodiscard]]
constexpr explicit point3(array_type
const& other) noexcept : _v(other)
68 [[nodiscard]]
constexpr point3() noexcept : _v(0.0f, 0.0f, 0.0f, 1.0f) {}
75 [[nodiscard]]
constexpr point3(
float x,
float y,
float z = 0.0f) noexcept : _v(x, y, z, 1.0f) {}
80 [[nodiscard]]
constexpr float&
x() noexcept
88 [[nodiscard]]
constexpr float&
y() noexcept
96 [[nodiscard]]
constexpr float&
z() noexcept
104 [[nodiscard]]
constexpr float x() const noexcept
112 [[nodiscard]]
constexpr float y() const noexcept
120 [[nodiscard]]
constexpr float z() const noexcept
125 constexpr point3& operator+=(vector3
const& rhs)
noexcept
127 return *
this = *
this + rhs;
130 constexpr point3& operator-=(vector3
const& rhs)
noexcept
132 return *
this = *
this - rhs;
142 return point3{lhs._v + array_type{rhs}};
152 return point3{array_type{lhs} + rhs._v};
162 return point3{lhs._v - array_type{rhs}};
172 return vector3{lhs._v - rhs._v};
182 return equal(lhs._v, rhs._v);
185 [[nodiscard]]
friend constexpr point3 midpoint(
point3 const& lhs,
point3 const& rhs)
noexcept
187 return point3{midpoint(lhs._v, rhs._v)};
190 [[nodiscard]]
friend constexpr point3 reflect(point3
const& lhs, point3
const& rhs)
noexcept
192 return point3{reflect_point(lhs._v, rhs._v)};
202 return point3{min(lhs._v, rhs._v)};
212 return point3{max(lhs._v, rhs._v)};
219 return point3{round(rhs._v)};
226 return point3{ceil(rhs._v)};
233 return point3{floor(rhs._v)};
240 hilet rhs_ = array_type{rhs}.xyz1();
241 return point3{ceil(lhs._v / rhs_) * rhs_};
248 hilet rhs_ = array_type{rhs}.xyz1();
249 return point3{floor(lhs._v / rhs_) * rhs_};
252 [[nodiscard]]
friend float distance(
point3 const& lhs,
point3 const& rhs)
noexcept
254 return hypot(rhs - lhs);
262 return _v.w() != 0.0f;
267 return std::format(
"<{}, {}, {}>", rhs._v.x(), rhs._v.y(), rhs._v.z());
272 return lhs << to_string(rhs);
279[[nodiscard]]
constexpr point3 operator+(point2
const& lhs, vector3
const& rhs)
noexcept
281 return point3{f32x4{lhs} + f32x4{rhs}};
284[[nodiscard]]
constexpr point3 operator+(vector3
const& lhs, point2
const& rhs)
noexcept
286 return point3{f32x4{lhs} + f32x4{rhs}};
289[[nodiscard]]
constexpr point3 operator-(point2
const& lhs, vector3
const& rhs)
noexcept
291 return point3{f32x4{lhs} - f32x4{rhs}};
299template<
typename CharT>
300struct std::formatter<
hi::point3, CharT> {
306 auto format(hi::point3
const& t,
auto& fc)
308 return std::vformat_to(fc.out(),
"<{}, {}, {}>", std::make_format_args(t.x(), t.y(), t.z()));
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
A high-level geometric point Part of the high-level vec, point, mat and color types.
Definition point3.hpp:24
constexpr point3(float x, float y, float z=0.0f) noexcept
Construct a 3D point from x, y and z elements.
Definition point3.hpp:75
constexpr friend bool operator==(point3 const &lhs, point3 const &rhs) noexcept
Compare if two points are equal.
Definition point3.hpp:180
constexpr point3(point2 const &other, float z) noexcept
Construct a point from a lower dimension point.
Definition point3.hpp:47
constexpr point3(point2 const &other) noexcept
Construct a point from a lower dimension point.
Definition point3.hpp:36
friend constexpr point3 ceil(point3 const &lhs, extent3 rhs) noexcept
Round the coordinates of a point toward the top-right with the given granularity.
Definition point3.hpp:238
constexpr point3() noexcept
Construct a point at the origin of the coordinate system.
Definition point3.hpp:68
constexpr float & z() noexcept
Access the z element from the point.
Definition point3.hpp:96
constexpr friend point3 operator+(vector3 const &lhs, point3 const &rhs) noexcept
Move a point along a vector.
Definition point3.hpp:150
constexpr float y() const noexcept
Access the y element from the point.
Definition point3.hpp:112
friend constexpr point3 floor(point3 const &lhs, extent3 rhs) noexcept
Round the coordinates of a point toward the left-bottom with the given granularity.
Definition point3.hpp:246
friend constexpr point3 max(point3 const &lhs, point3 const &rhs) noexcept
Mix the two points and get the highest value of each element.
Definition point3.hpp:210
constexpr bool holds_invariant() const noexcept
Check if the point is valid.
Definition point3.hpp:260
constexpr point3(array_type const &other) noexcept
Construct a point from a array_type-simd.
Definition point3.hpp:61
constexpr float & x() noexcept
Access the x element from the point.
Definition point3.hpp:80
constexpr float z() const noexcept
Access the z element from the point.
Definition point3.hpp:120
friend constexpr point3 min(point3 const &lhs, point3 const &rhs) noexcept
Mix the two points and get the lowest value of each element.
Definition point3.hpp:200
constexpr float & y() noexcept
Access the y element from the point.
Definition point3.hpp:88
constexpr friend vector3 operator-(point3 const &lhs, point3 const &rhs) noexcept
Find the vector between two points.
Definition point3.hpp:170
friend constexpr point3 round(point3 const &rhs) noexcept
Round the coordinates of a point toward nearest integer.
Definition point3.hpp:217
constexpr friend point3 operator+(point3 const &lhs, vector3 const &rhs) noexcept
Move a point along a vector.
Definition point3.hpp:140
friend constexpr point3 ceil(point3 const &rhs) noexcept
Round the coordinates of a point toward the right-top.
Definition point3.hpp:224
constexpr float x() const noexcept
Access the x element from the point.
Definition point3.hpp:104
constexpr friend point3 operator-(point3 const &lhs, vector3 const &rhs) noexcept
Move a point backward along the vector.
Definition point3.hpp:160
friend constexpr point3 floor(point3 const &rhs) noexcept
Round the coordinates of a point toward the left-bottom.
Definition point3.hpp:231