14namespace hi {
inline namespace v1 {
25 constexpr circle() noexcept : _v()
30 [[nodiscard]]
constexpr explicit circle(f32x4 v) noexcept : _v(v)
35 [[nodiscard]]
constexpr explicit operator f32x4()
const noexcept
40 [[nodiscard]]
constexpr circle(point3 point,
float radius) noexcept : _v(f32x4{point})
46 [[nodiscard]]
constexpr circle(
float radius) noexcept : _v()
54 hilet square_ = f32x4{square};
57 _v = (addsub<0b0011>(square_.zwzw(), square_.xyxy()) * 0.5f).xy0w();
61 [[nodiscard]]
constexpr bool empty()
const noexcept
63 return _v.w() == 0.0f;
66 [[nodiscard]]
explicit operator bool()
const noexcept
71 [[nodiscard]]
constexpr float radius()
const noexcept
76 [[nodiscard]]
constexpr float diameter()
const noexcept
78 return radius() * 2.0f;
81 [[nodiscard]]
constexpr point3 center()
const noexcept
83 return point3{_v.xyz1()};
86 [[nodiscard]]
constexpr friend circle operator+(
circle const& lhs,
float rhs)
noexcept
88 return circle{lhs._v + insert<3>(f32x4{}, rhs)};
91 [[nodiscard]]
constexpr friend circle operator-(
circle const& lhs,
float rhs)
noexcept
93 return circle{lhs._v - insert<3>(f32x4{}, rhs)};
96 [[nodiscard]]
constexpr friend circle operator*(
circle const& lhs,
float rhs)
noexcept
98 return circle{lhs._v * insert<3>(f32x4::broadcast(1.0f), rhs)};
101 [[nodiscard]]
constexpr friend point3 midpoint(
circle const& rhs)
noexcept
103 return point3{rhs.center()};
106 [[nodiscard]]
constexpr friend aarectangle bounding_rectangle(
circle const& rhs)
noexcept
108 hilet p = rhs._v.xyxy();
109 hilet r = neg<0b0011>(rhs._v.wwww());
122 if (alignment == horizontal_alignment::left) {
123 return haystack.left() + needle.radius();
125 }
else if (alignment == horizontal_alignment::right) {
126 return haystack.right() - needle.radius();
128 }
else if (alignment == horizontal_alignment::center) {
129 return haystack.center();
137 if (alignment == vertical_alignment::bottom) {
138 return haystack.bottom() + needle.radius();
140 }
else if (alignment == vertical_alignment::top) {
141 return haystack.top() - needle.radius();
143 }
else if (alignment == vertical_alignment::middle) {
144 return haystack.middle();
151 return circle{point2{x, y}, needle.radius()};
158 [[nodiscard]]
constexpr bool holds_invariant() const noexcept
160 return _v.w() >= 0.0f;
#define hi_no_default(...)
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:279
#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
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:27
A type defining a 2D circle.
Definition circle.hpp:18
friend constexpr circle align(aarectangle haystack, circle needle, alignment alignment) noexcept
Align a rectangle within another rectangle.
Definition circle.hpp:119