8#include "../SIMD/SIMD.hpp"
9#include "../macros.hpp"
15hi_export_module(hikogui.geometry : vector3);
17hi_export
namespace hi {
inline namespace v1 {
29 using value_type = array_type::value_type;
136 return *
this = *
this + rhs;
141 return *
this = *
this - rhs;
144 constexpr vector3& operator*=(
float const& rhs)
noexcept
146 return *
this = *
this * rhs;
156 return vector3{lhs._v + rhs._v};
166 return vector3{lhs._v - rhs._v};
176 return vector3{lhs._v * array_type::broadcast(rhs)};
186 return vector3{array_type::broadcast(lhs) * rhs._v};
196 return equal(lhs._v, rhs._v);
252 if (
angle !=
float{0}) {
253 hi_not_implemented();
265 auto const a_left = lhs._v.yzxw();
266 auto const b_left = rhs._v.zxyw();
269 auto const a_right = lhs._v.zxyw();
270 auto const b_right = rhs._v.yzxw();
321 return _v.w() == 0.0f;
326 return std::format(
"({}, {}, {})", rhs._v.x(), rhs._v.y(), rhs._v.z());
331 return lhs << to_string(rhs);
344struct std::formatter<
hi::vector3, char> {
352 return std::vformat_to(fc.out(),
"({}, {}, {})", std::make_format_args(t.
x(), t.
y(), t.
z()));
@ right
Align the text to the right side.
@ left
Align the text to the left side.
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:26
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:26
constexpr vector3 operator-() const noexcept
Mirror this vector.
Definition vector3.hpp:129
constexpr friend float rcp_hypot(vector3 const &rhs) noexcept
Get the length of the vector.
Definition vector3.hpp:221
constexpr friend vector3 operator+(vector3 const &lhs, vector3 const &rhs) noexcept
Add two vectors from each other.
Definition vector3.hpp:154
constexpr friend vector3 operator*(vector3 const &lhs, float const &rhs) noexcept
Scale the vector by a scaler.
Definition vector3.hpp:174
constexpr friend vector3 operator*(float const &lhs, vector3 const &rhs) noexcept
Scale the vector by a scaler.
Definition vector3.hpp:184
constexpr friend bool operator==(vector3 const &lhs, vector3 const &rhs) noexcept
Compare if two vectors are equal.
Definition vector3.hpp:194
friend constexpr vector3 max(vector3 const &lhs, vector3 const &rhs) noexcept
Mix the two vectors and get the highest value of each element.
Definition vector3.hpp:290
friend constexpr vector3 min(vector3 const &lhs, vector3 const &rhs) noexcept
Mix the two vectors and get the lowest value of each element.
Definition vector3.hpp:280
constexpr vector3(float x, float y, float z=0.0f) noexcept
Construct a 3D vector from x, y and z elements.
Definition vector3.hpp:76
constexpr friend vector3 operator-(vector3 const &lhs, vector3 const &rhs) noexcept
Subtract two vectors from each other.
Definition vector3.hpp:164
constexpr float z() const noexcept
Access the z element from the vector.
Definition vector3.hpp:121
constexpr float & x() noexcept
Access the x element from the vector.
Definition vector3.hpp:81
constexpr friend float dot(vector3 const &lhs, vector3 const &rhs) noexcept
Get the dot product between two vectors.
Definition vector3.hpp:240
constexpr float x() const noexcept
Access the x element from the vector.
Definition vector3.hpp:105
constexpr vector3(array_type const &other) noexcept
Construct a vector from a array_type-simd.
Definition vector3.hpp:62
constexpr friend float squared_hypot(vector3 const &rhs) noexcept
Get the squared length of the vector.
Definition vector3.hpp:203
friend constexpr vector3 round(vector3 const &rhs) noexcept
Round the elements of the vector toward nearest integer.
Definition vector3.hpp:297
constexpr friend vector3 normalize(vector3 const &rhs) noexcept
Normalize a vector to a unit vector.
Definition vector3.hpp:230
friend float hypot(vector3 const &rhs) noexcept
Get the length of the vector.
Definition vector3.hpp:212
constexpr friend vector3 cross(vector3 const &lhs, vector3 const &rhs) noexcept
Get the cross product between two 3D vectors.
Definition vector3.hpp:263
constexpr bool holds_invariant() const noexcept
Check if the vector is valid.
Definition vector3.hpp:319
constexpr float & y() noexcept
Access the y element from the vector.
Definition vector3.hpp:89
constexpr vector3() noexcept
Construct a empty vector / zero length.
Definition vector3.hpp:69
constexpr vector3(vector2 const &other) noexcept
Construct a vector from a lower dimension vector.
Definition vector3.hpp:38
constexpr float y() const noexcept
Access the y element from the vector.
Definition vector3.hpp:113
friend constexpr vector3 ceil(vector3 const &rhs) noexcept
Round the elements of the vector toward upward and to the right.
Definition vector3.hpp:304
friend constexpr vector3 floor(vector3 const &rhs) noexcept
Round the elements of the vector toward downward and to the left.
Definition vector3.hpp:311
constexpr friend vector3 normal(vector3 const &rhs, float angle) noexcept
Get the normal on a 3D vector.
Definition vector3.hpp:250
constexpr float & z() noexcept
Access the z element from the vector.
Definition vector3.hpp:97