33#include <initializer_list>
50 std::enable_if_t<std::is_floating_point_v<Value_type>,
bool> =
true>
67 constexpr static const size_t components = 4;
70 constexpr static const size_t byte_size = components *
sizeof(
value_type);
81 : x(v), y(v), z(v), w(v) {}
84 : x(x_), y(y_), z(z_), w(w_) {}
87 : x(o3.x), y(o3.y), z(o3.z), w(w_) {}
90 : x(v[0]), y(v[1]), z(v[2]), w(v[3]) {}
92 constexpr Vector4F(std::initializer_list<value_type> v) noexcept
93 : x(v[0]), y(v[1]), z(v[2]), w(v[3]) {}
115 explicit operator pointer() noexcept {
return &x; }
149 { x = o.
x; y = o.y; z = o.z; w = w_;
return *
this; }
152 { x=vx; y=vy; z=vz; w=vw;
return *
this; }
156 { x=xyzw[0]; y=xyzw[1]; z=xyzw[2]; z=xyzw[3];
return *
this; }
160 { x+=dx; y+=dy; z+=dz; w+=dw;
return *
this; }
164 { x*=sx; y*=sy; z*=sz; w*=sw;
return *
this; }
168 { x*=s; y*=s; z*=s; w*=s;
return *
this; }
172 x+=rhs.
x; y+=rhs.y; z+=rhs.z; w+=rhs.w;
178 x-=rhs.
x; y-=rhs.y; z-=rhs.z; w-=rhs.w;
188 x*=s; y*=s; z*=s; w*=s;
198 x/=s; y/=s; z/=s; w/=s;
212 return x*x + y*y + z*z + w*w;
219 return std::sqrt(length_sq());
254 return dx*dx + dy*dy + dz*dz + dw*dw;
261 return std::sqrt(dist_sq(o));
265 const value_type eps = std::numeric_limits<value_type>::epsilon();
275 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
287 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
293 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
299 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
305 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
312 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
318 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
320 return out << v.toString();
324 static_assert(
alignof(float) ==
alignof(
Vec4f));
325 static_assert(
sizeof(float)*4 ==
sizeof(
Vec4f));
331 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
335 static_assert(
alignof(float) ==
alignof(
Point4f));
336 static_assert(
sizeof(float)*4 ==
sizeof(
Point4f));
3D vector using three value_type components.
4D vector using four value_type components.
const value_type & const_reference
constexpr Vector4F & operator+=(const Vector4F &rhs) noexcept
this = this + rhs, returns this.
constexpr Vector4F & set(const value_type vx, const value_type vy, const value_type vz, const value_type vw) noexcept
constexpr Vector4F & operator*=(const value_type s) noexcept
Scale this vector with given scale factor.
Vector3F< value_type, std::is_floating_point_v< Value_type > > Vec3
constexpr Vector4F & set(const_iterator xyzw) noexcept
this = xyzw, returns this.
constexpr_cxx23 bool intersects(const Vector4F &o) const noexcept
constexpr Vector4F & mul(const value_type sx, const value_type sy, const value_type sz, const value_type sw) noexcept
this = this * {sx, sy, sz, sw}, returns this.
constexpr Vector4F & set(const Vec3f &o, const value_type w_) noexcept
TODO constexpr bool operator<=>(const vec4f_t& rhs ) const noexcept { return ... }.
constexpr Vector4F() noexcept
constexpr value_type length_sq() const noexcept
Return the squared length of a vector, a.k.a the squared norm or squared magnitude
const value_type * const_iterator
constexpr Vec3 & getVec3(Vec3 &out) const noexcept
out = { this.x, this.y, this.z } dropping w, returns out.
constexpr value_type length() const noexcept
Return the length of a vector, a.k.a the norm or magnitude
constexpr bool is_zero() const noexcept
constexpr Vector4F & add(const value_type dx, const value_type dy, const value_type dz, const value_type dw) noexcept
this = this + {dx, dy, dz, dw}, returns this.
constexpr Vector4F(const_iterator v) noexcept
const value_type * const_pointer
constexpr value_type dist(const Vector4F &o) const noexcept
Return the distance between this vector and the given one.
constexpr const_iterator cbegin() const noexcept
constexpr Vector4F & normalize() noexcept
Normalize this vector in place.
constexpr Vector4F(const value_type x_, const value_type y_, const value_type z_, const value_type w_) noexcept
constexpr Vector4F(std::initializer_list< value_type > v) noexcept
constexpr Vector4F(Vector4F &&o) noexcept=default
constexpr iterator get(iterator xyzw) const noexcept
xyzw = this, returns xyzw.
constexpr Vector4F(const value_type v) noexcept
constexpr Vector4F & scale(const value_type s) noexcept
this = this * s, returns this.
constexpr Vector4F(const Vector4F &o) noexcept=default
constexpr Vector4F & operator=(const Vector4F &) noexcept=default
constexpr Vector4F & operator=(Vector4F &&) noexcept=default
std::string toString() const noexcept
constexpr Vector4F(const Vec3 &o3, const value_type w_) noexcept
constexpr iterator begin() noexcept
constexpr bool operator==(const Vector4F &rhs) const noexcept
constexpr value_type dist_sq(const Vector4F &o) const noexcept
Return the squared distance between this vector and the given one.
constexpr reference operator[](size_t i) noexcept
Returns writeable reference to component.
constexpr Vector4F & operator-=(const Vector4F &rhs) noexcept
this = this - rhs, returns this.
constexpr Vector4F & operator/=(const value_type s) noexcept
Divide this vector with given scale factor.
std::string to_string(const alphabet &v) noexcept
std::enable_if< std::is_floating_point_v< T >, bool >::type constexpr is_zero(const T &a, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
Returns true if the given value is less than epsilon, w/ epsilon > 0.
constexpr T abs(const T x) noexcept
Returns the absolute value of an arithmetic number (w/ branching) in O(1)
constexpr Vector3F< T > to_vec3(const Vector4F< T > &v) noexcept
out = { this.x, this.y, this.z } dropping w, returns out.
constexpr Quaternion< T > operator-(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
constexpr Vector2F< T > operator/(const Vector2F< T > &lhs, const T s) noexcept
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
constexpr Quaternion< T > operator+(const Quaternion< T > &lhs, const Quaternion< T > &rhs) noexcept
std::ostream & operator<<(std::ostream &out, const Matrix4< T > &v) noexcept
constexpr const jau::fraction_i64 zero(0l, 1lu)
zero is 0/1
constexpr const jau::fraction_i64 one(1l, 1lu)
one is 10^0 or 1/1