13#include "../SIMD/module.hpp"
14#include "../utility/module.hpp"
18namespace hi {
inline namespace v1 {
29 using array_type = simd<float, 4>;
30 using value_type = array_type::value_type;
44 [[nodiscard]]
constexpr explicit operator extent2() const noexcept
53 [[nodiscard]]
constexpr explicit operator array_type() const noexcept
58 [[nodiscard]]
constexpr explicit extent3(array_type
const&
other) noexcept : _v(
other)
63 [[nodiscard]]
constexpr explicit operator bool() const noexcept
65 return _v.x() != 0.0f or _v.y() != 0.0f or _v.z() != 0.0f;
68 [[nodiscard]]
constexpr explicit operator vector3() const noexcept
70 return vector3{
static_cast<array_type
>(*this)};
75 [[nodiscard]]
constexpr extent3() noexcept : _v(0.0f, 0.0f, 0.0f, 0.0f) {}
87 [[nodiscard]]
static constexpr extent3 infinity() noexcept
95 [[nodiscard]]
static constexpr extent3 large() noexcept
97 return extent3{large_number_v<float>, large_number_v<float>, large_number_v<float>};
100 [[nodiscard]]
static constexpr extent3 nan() noexcept
115 [[nodiscard]]
constexpr float&
width() noexcept
126 [[nodiscard]]
constexpr float&
height() noexcept
137 [[nodiscard]]
constexpr float&
depth() noexcept
148 [[nodiscard]]
constexpr float width() const noexcept
159 [[nodiscard]]
constexpr float height() const noexcept
170 [[nodiscard]]
constexpr float depth() const noexcept
175 [[nodiscard]]
constexpr vector3 right() const noexcept
180 [[nodiscard]]
constexpr vector3 up() const noexcept
182 return vector3{_v._0y00()};
187 return *
this = *
this + rhs;
197 return extent3{lhs._v + rhs._v};
207 return extent3{lhs._v - rhs._v};
222 return extent3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
227 return extent3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
230 [[nodiscard]]
constexpr friend vector3
operator+(vector3
const& lhs,
extent3 const& rhs)
noexcept
232 return vector3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
244 r._v[i] = lhs._v[i] + rhs;
267 return equal(lhs._v, rhs._v);
270 [[nodiscard]]
constexpr friend std::partial_ordering operator<=>(
extent3 const& lhs,
extent3 const& rhs)
noexcept
274 hilet equal = (lhs._v == rhs._v).mask() & mask;
277 return std::partial_ordering::equivalent;
280 hilet less = (lhs._v < rhs._v).mask() & mask;
281 if ((less | equal) == mask) {
283 return std::partial_ordering::less;
286 hilet greater = (lhs._v < rhs._v).mask() & mask;
287 if ((greater | equal) == mask) {
289 return std::partial_ordering::greater;
293 return std::partial_ordering::unordered;
302 return squared_hypot<0b0111>(rhs._v);
311 return hypot<0b0111>(rhs._v);
320 return rcp_hypot<0b0111>(rhs._v);
329 return extent3{normalize<0b0111>(rhs._v)};
332 [[nodiscard]]
constexpr friend extent3 ceil(
extent3 const& rhs)
noexcept
334 return extent3{ceil(array_type{rhs})};
337 [[nodiscard]]
constexpr friend extent3 floor(
extent3 const& rhs)
noexcept
339 return extent3{floor(
static_cast<array_type
>(rhs))};
342 [[nodiscard]]
constexpr friend extent3 round(
extent3 const& rhs)
noexcept
344 return extent3{round(
static_cast<array_type
>(rhs))};
349 return extent3{min(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
354 return extent3{max(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
359 return extent3{clamp(
static_cast<array_type
>(value),
static_cast<array_type
>(min),
static_cast<array_type
>(max))};
368 return _v.x() >= 0.0f and _v.y() >= 0.0f and _v.z() >= 0.0f and _v.w() == 0.0f;
373 return std::format(
"[{}, {}, {}]", rhs._v.x(), rhs._v.y(), rhs._v.z());
378 return lhs << to_string(rhs);
387template<
typename CharT>
388struct std::formatter<
hi::extent3, CharT> {
396 return std::vformat_to(fc.out(),
"[{}, {}, {}]", std::make_format_args(t.
width(), t.
height(), t.
depth()));
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
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
A high-level geometric extent.
Definition extent2.hpp:26
A high-level geometric extent.
Definition extent3.hpp:27
constexpr extent3(extent2 const &other) noexcept
Construct a extent from a lower dimension extent.
Definition extent3.hpp:39
constexpr friend extent3 operator+(extent3 const &lhs, float const &rhs) noexcept
Add a scaler to the extent.
Definition extent3.hpp:240
constexpr float height() const noexcept
Access the y-as-height element from the extent.
Definition extent3.hpp:159
constexpr friend float rcp_hypot(extent3 const &rhs) noexcept
Get the length of the extent.
Definition extent3.hpp:318
constexpr extent3(float width, float height, float depth=0.0f) noexcept
Construct a 3D extent from width, height and depth.
Definition extent3.hpp:82
constexpr friend extent3 normalize(extent3 const &rhs) noexcept
Normalize a extent to a unit extent.
Definition extent3.hpp:327
constexpr friend extent3 operator-(extent3 const &lhs, extent3 const &rhs) noexcept
Subtract two extents from each other.
Definition extent3.hpp:205
constexpr friend extent3 operator*(extent3 const &lhs, float const &rhs) noexcept
Scale the extent by a scaler.
Definition extent3.hpp:215
constexpr float depth() const noexcept
Access the z-as-depth element from the extent.
Definition extent3.hpp:170
constexpr float & height() noexcept
Access the y-as-height element from the extent.
Definition extent3.hpp:126
constexpr float & depth() noexcept
Access the z-as-depth element from the extent.
Definition extent3.hpp:137
constexpr float width() const noexcept
Access the x-as-width element from the extent.
Definition extent3.hpp:148
constexpr friend bool operator==(extent3 const &lhs, extent3 const &rhs) noexcept
Compare if two extents are equal.
Definition extent3.hpp:265
constexpr extent3() noexcept
Construct a empty extent / zero length.
Definition extent3.hpp:75
constexpr bool holds_invariant() const noexcept
Check if the extent is valid.
Definition extent3.hpp:366
constexpr friend extent3 operator*(float const &lhs, extent3 const &rhs) noexcept
Scale the extent by a scaler.
Definition extent3.hpp:255
friend float hypot(extent3 const &rhs) noexcept
Get the length of the extent.
Definition extent3.hpp:309
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent3.hpp:115
hi_force_inline constexpr friend float squared_hypot(extent3 const &rhs) noexcept
Get the squared length of the extent.
Definition extent3.hpp:300
constexpr friend extent3 operator+(extent3 const &lhs, extent3 const &rhs) noexcept
Add two extents from each other.
Definition extent3.hpp:195
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:18
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:19
T signaling_NaN(T... args)