13#include "../utility/utility.hpp"
14#include "../macros.hpp"
15#include <hikocpu/hikocpu.hpp>
22hi_export_module(hikogui.geometry : extent3);
24hi_export
namespace hi {
inline namespace v1 {
36 using value_type = array_type::value_type;
50 [[nodiscard]]
constexpr explicit operator extent2() const noexcept
59 [[nodiscard]]
constexpr explicit operator array_type() const noexcept
64 [[nodiscard]]
constexpr explicit extent3(array_type
const&
other) noexcept : _v(
other)
69 [[nodiscard]]
constexpr explicit operator bool() const noexcept
71 return _v.x() != 0.0f or _v.y() != 0.0f or _v.z() != 0.0f;
74 [[nodiscard]]
constexpr explicit operator vector3() const noexcept
76 return vector3{
static_cast<array_type
>(*this)};
81 [[nodiscard]]
constexpr extent3() noexcept : _v(0.0f, 0.0f, 0.0f, 0.0f) {}
93 [[nodiscard]]
constexpr static extent3 infinity() noexcept
101 [[nodiscard]]
constexpr static extent3 large() noexcept
103 return extent3{large_number_v<float>, large_number_v<float>, large_number_v<float>};
106 [[nodiscard]]
constexpr static extent3 nan() noexcept
121 [[nodiscard]]
constexpr float&
width() noexcept
132 [[nodiscard]]
constexpr float&
height() noexcept
143 [[nodiscard]]
constexpr float&
depth() noexcept
154 [[nodiscard]]
constexpr float width() const noexcept
165 [[nodiscard]]
constexpr float height() const noexcept
176 [[nodiscard]]
constexpr float depth() const noexcept
181 [[nodiscard]]
constexpr vector3 right() const noexcept
186 [[nodiscard]]
constexpr vector3 up() const noexcept
188 return vector3{_v._0y00()};
193 return *
this = *
this + rhs;
203 return extent3{lhs._v + rhs._v};
213 return extent3{lhs._v - rhs._v};
223 return extent3{lhs._v * array_type::broadcast(rhs)};
228 return extent3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
233 return extent3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
236 [[nodiscard]]
constexpr friend vector3
operator+(vector3
const& lhs,
extent3 const& rhs)
noexcept
238 return vector3{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
250 r._v[i] = lhs._v[i] + rhs;
263 return extent3{array_type::broadcast(lhs) * rhs._v};
273 return equal(lhs._v, rhs._v);
276 [[nodiscard]]
constexpr friend std::partial_ordering operator<=>(
extent3 const& lhs,
extent3 const& rhs)
noexcept
280 auto const equal = (lhs._v == rhs._v).mask() & mask;
283 return std::partial_ordering::equivalent;
286 auto const less = (lhs._v < rhs._v).mask() & mask;
287 if ((less | equal) == mask) {
289 return std::partial_ordering::less;
292 auto const greater = (lhs._v < rhs._v).mask() & mask;
293 if ((greater | equal) == mask) {
295 return std::partial_ordering::greater;
299 return std::partial_ordering::unordered;
308 return dot<0b0111>(rhs._v, rhs._v).x();
317 return hypot<0b0111>(rhs._v).x();
326 return rhypot<0b0111>(rhs._v).x();
335 return extent3{normalize<0b0111>(rhs._v)};
338 [[nodiscard]]
constexpr friend extent3 ceil(
extent3 const& rhs)
noexcept
340 return extent3{ceil(array_type{rhs})};
343 [[nodiscard]]
constexpr friend extent3 floor(
extent3 const& rhs)
noexcept
345 return extent3{floor(
static_cast<array_type
>(rhs))};
348 [[nodiscard]]
constexpr friend extent3 round(
extent3 const& rhs)
noexcept
350 return extent3{round(
static_cast<array_type
>(rhs))};
355 return extent3{min(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
360 return extent3{max(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
365 return extent3{clamp(
static_cast<array_type
>(value),
static_cast<array_type
>(min),
static_cast<array_type
>(max))};
374 return _v.x() >= 0.0f and _v.y() >= 0.0f and _v.z() >= 0.0f and _v.w() == 0.0f;
379 return std::format(
"[{}, {}, {}]", rhs._v.x(), rhs._v.y(), rhs._v.z());
384 return lhs << to_string(rhs);
395struct std::formatter<
hi::extent3, char> : std::formatter<std::string, char> {
398 return std::formatter<std::string, char>::format(std::format(
"[{}, {}, {}]", t.
width(), t.
height(), t.
depth()), fc);
Defined the geo::extent, extent2 and extent3 types.
@ other
The gui_event does not have associated data.
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition simd_intf.hpp:18
A high-level geometric extent.
Definition extent2.hpp:32
A high-level geometric extent.
Definition extent3.hpp:33
constexpr extent3(extent2 const &other) noexcept
Construct a extent from a lower dimension extent.
Definition extent3.hpp:45
constexpr friend extent3 operator+(extent3 const &lhs, float const &rhs) noexcept
Add a scaler to the extent.
Definition extent3.hpp:246
constexpr float height() const noexcept
Access the y-as-height element from the extent.
Definition extent3.hpp:165
constexpr friend float rcp_hypot(extent3 const &rhs) noexcept
Get the length of the extent.
Definition extent3.hpp:324
constexpr extent3(float width, float height, float depth=0.0f) noexcept
Construct a 3D extent from width, height and depth.
Definition extent3.hpp:88
constexpr friend extent3 normalize(extent3 const &rhs) noexcept
Normalize a extent to a unit extent.
Definition extent3.hpp:333
constexpr friend extent3 operator-(extent3 const &lhs, extent3 const &rhs) noexcept
Subtract two extents from each other.
Definition extent3.hpp:211
constexpr friend extent3 operator*(extent3 const &lhs, float const &rhs) noexcept
Scale the extent by a scaler.
Definition extent3.hpp:221
constexpr float depth() const noexcept
Access the z-as-depth element from the extent.
Definition extent3.hpp:176
constexpr float & height() noexcept
Access the y-as-height element from the extent.
Definition extent3.hpp:132
constexpr float & depth() noexcept
Access the z-as-depth element from the extent.
Definition extent3.hpp:143
constexpr float width() const noexcept
Access the x-as-width element from the extent.
Definition extent3.hpp:154
constexpr friend bool operator==(extent3 const &lhs, extent3 const &rhs) noexcept
Compare if two extents are equal.
Definition extent3.hpp:271
constexpr extent3() noexcept
Construct a empty extent / zero length.
Definition extent3.hpp:81
constexpr bool holds_invariant() const noexcept
Check if the extent is valid.
Definition extent3.hpp:372
constexpr friend extent3 operator*(float const &lhs, extent3 const &rhs) noexcept
Scale the extent by a scaler.
Definition extent3.hpp:261
friend float hypot(extent3 const &rhs) noexcept
Get the length of the extent.
Definition extent3.hpp:315
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent3.hpp:121
hi_force_inline constexpr friend float squared_hypot(extent3 const &rhs) noexcept
Get the squared length of the extent.
Definition extent3.hpp:306
constexpr friend extent3 operator+(extent3 const &lhs, extent3 const &rhs) noexcept
Add two extents from each other.
Definition extent3.hpp:201
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:27
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:26
T signaling_NaN(T... args)