13#include "../SIMD/module.hpp"
14#include "../utility/utility.hpp"
15#include "../macros.hpp"
21namespace hi {
inline namespace v1 {
32 using array_type = simd<float, 4>;
33 using value_type = array_type::value_type;
47 [[nodiscard]]
constexpr explicit operator extent2() const noexcept
56 [[nodiscard]]
constexpr explicit operator array_type() const noexcept
61 [[nodiscard]]
constexpr explicit extent3(array_type
const&
other) noexcept : _v(
other)
66 [[nodiscard]]
constexpr explicit operator bool() const noexcept
68 return _v.x() != 0.0f or _v.y() != 0.0f or _v.z() != 0.0f;
71 [[nodiscard]]
constexpr explicit operator vector3() const noexcept
73 return vector3{
static_cast<array_type
>(*this)};
78 [[nodiscard]]
constexpr extent3() noexcept : _v(0.0f, 0.0f, 0.0f, 0.0f) {}
90 [[nodiscard]]
constexpr static extent3 infinity() noexcept
98 [[nodiscard]]
constexpr static extent3 large() noexcept
100 return extent3{large_number_v<float>, large_number_v<float>, large_number_v<float>};
103 [[nodiscard]]
constexpr static extent3 nan() noexcept
118 [[nodiscard]]
constexpr float&
width() noexcept
129 [[nodiscard]]
constexpr float&
height() noexcept
140 [[nodiscard]]
constexpr float&
depth() noexcept
151 [[nodiscard]]
constexpr float width() const noexcept
162 [[nodiscard]]
constexpr float height() const noexcept
173 [[nodiscard]]
constexpr float depth() const noexcept
178 [[nodiscard]]
constexpr vector3 right() const noexcept
183 [[nodiscard]]
constexpr vector3 up() const noexcept
185 return vector3{_v._0y00()};
188 constexpr extent3& operator+=(extent3
const& rhs)
noexcept
190 return *
this = *
this + rhs;
198 [[nodiscard]]
constexpr friend extent3
operator+(extent3
const& lhs, extent3
const& rhs)
noexcept
200 return extent3{lhs._v + rhs._v};
208 [[nodiscard]]
constexpr friend extent3
operator-(extent3
const& lhs, extent3
const& rhs)
noexcept
210 return extent3{lhs._v - rhs._v};
218 [[nodiscard]]
constexpr friend extent3
operator*(extent3
const& lhs,
float const& rhs)
noexcept
220 return extent3{lhs._v * rhs};
225 return extent3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
230 return extent3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
233 [[nodiscard]]
constexpr friend vector3
operator+(vector3
const& lhs, extent3
const& rhs)
noexcept
235 return vector3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
243 [[nodiscard]]
constexpr friend extent3
operator+(extent3
const& lhs,
float const& rhs)
noexcept
247 r._v[i] = lhs._v[i] + rhs;
258 [[nodiscard]]
constexpr friend extent3
operator*(
float const& lhs, extent3
const& rhs)
noexcept
260 return extent3{lhs * rhs._v};
268 [[nodiscard]]
constexpr friend bool operator==(extent3
const& lhs, extent3
const& rhs)
noexcept
270 return equal(lhs._v, rhs._v);
273 [[nodiscard]]
constexpr friend std::partial_ordering operator<=>(
extent3 const& lhs,
extent3 const& rhs)
noexcept
277 hilet equal = (lhs._v == rhs._v).mask() & mask;
280 return std::partial_ordering::equivalent;
283 hilet less = (lhs._v < rhs._v).mask() & mask;
284 if ((less | equal) == mask) {
286 return std::partial_ordering::less;
289 hilet greater = (lhs._v < rhs._v).mask() & mask;
290 if ((greater | equal) == mask) {
292 return std::partial_ordering::greater;
296 return std::partial_ordering::unordered;
303 [[nodiscard]] hi_force_inline
constexpr friend float squared_hypot(extent3
const& rhs)
noexcept
312 [[nodiscard]]
friend float hypot(extent3
const& rhs)
noexcept
321 [[nodiscard]]
constexpr friend float rcp_hypot(extent3
const& rhs)
noexcept
330 [[nodiscard]]
constexpr friend extent3
normalize(extent3
const& rhs)
noexcept
335 [[nodiscard]]
constexpr friend extent3 ceil(
extent3 const& rhs)
noexcept
337 return extent3{ceil(array_type{rhs})};
340 [[nodiscard]]
constexpr friend extent3 floor(extent3
const& rhs)
noexcept
342 return extent3{floor(
static_cast<array_type
>(rhs))};
345 [[nodiscard]]
constexpr friend extent3 round(extent3
const& rhs)
noexcept
347 return extent3{round(
static_cast<array_type
>(rhs))};
350 [[nodiscard]]
constexpr friend extent3 min(extent3
const& lhs, extent3
const& rhs)
noexcept
352 return extent3{min(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
355 [[nodiscard]]
constexpr friend extent3 max(extent3
const& lhs, extent3
const& rhs)
noexcept
357 return extent3{max(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
360 [[nodiscard]]
constexpr friend extent3 clamp(extent3
const& value, extent3
const& min, extent3
const& max)
noexcept
362 return extent3{clamp(
static_cast<array_type
>(value),
static_cast<array_type
>(min),
static_cast<array_type
>(max))};
371 return _v.x() >= 0.0f and _v.y() >= 0.0f and _v.z() >= 0.0f and _v.w() == 0.0f;
376 return std::format(
"[{}, {}, {}]", rhs._v.x(), rhs._v.y(), rhs._v.z());
381 return lhs << to_string(rhs);
390template<
typename CharT>
391struct std::formatter<
hi::extent3, CharT> {
399 return std::vformat_to(fc.out(),
"[{}, {}, {}]", std::make_format_args(t.
width(), t.
height(), t.
depth()));
Defined the geo::extent, extent2 and extent3 types.
@ other
The gui_event does not have associated data.
Definition gui_event_variant.hpp:22
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
A high-level geometric extent.
Definition extent2.hpp:29
A high-level geometric extent.
Definition extent3.hpp:30
constexpr extent3(extent2 const &other) noexcept
Construct a extent from a lower dimension extent.
Definition extent3.hpp:42
constexpr friend extent3 operator+(extent3 const &lhs, float const &rhs) noexcept
Add a scaler to the extent.
Definition extent3.hpp:243
constexpr float height() const noexcept
Access the y-as-height element from the extent.
Definition extent3.hpp:162
constexpr friend float rcp_hypot(extent3 const &rhs) noexcept
Get the length of the extent.
Definition extent3.hpp:321
constexpr extent3(float width, float height, float depth=0.0f) noexcept
Construct a 3D extent from width, height and depth.
Definition extent3.hpp:85
constexpr friend extent3 normalize(extent3 const &rhs) noexcept
Normalize a extent to a unit extent.
Definition extent3.hpp:330
constexpr friend extent3 operator-(extent3 const &lhs, extent3 const &rhs) noexcept
Subtract two extents from each other.
Definition extent3.hpp:208
constexpr friend extent3 operator*(extent3 const &lhs, float const &rhs) noexcept
Scale the extent by a scaler.
Definition extent3.hpp:218
constexpr float depth() const noexcept
Access the z-as-depth element from the extent.
Definition extent3.hpp:173
constexpr float & height() noexcept
Access the y-as-height element from the extent.
Definition extent3.hpp:129
constexpr float & depth() noexcept
Access the z-as-depth element from the extent.
Definition extent3.hpp:140
constexpr float width() const noexcept
Access the x-as-width element from the extent.
Definition extent3.hpp:151
constexpr friend bool operator==(extent3 const &lhs, extent3 const &rhs) noexcept
Compare if two extents are equal.
Definition extent3.hpp:268
constexpr extent3() noexcept
Construct a empty extent / zero length.
Definition extent3.hpp:78
constexpr bool holds_invariant() const noexcept
Check if the extent is valid.
Definition extent3.hpp:369
constexpr friend extent3 operator*(float const &lhs, extent3 const &rhs) noexcept
Scale the extent by a scaler.
Definition extent3.hpp:258
friend float hypot(extent3 const &rhs) noexcept
Get the length of the extent.
Definition extent3.hpp:312
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent3.hpp:118
hi_force_inline constexpr friend float squared_hypot(extent3 const &rhs) noexcept
Get the squared length of the extent.
Definition extent3.hpp:303
constexpr friend extent3 operator+(extent3 const &lhs, extent3 const &rhs) noexcept
Add two extents from each other.
Definition extent3.hpp:198
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:19
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:20
T signaling_NaN(T... args)