5#include "MRPch/MRBindingMacros.h"
14#pragma warning(disable: 4804)
15#pragma warning(disable: 4146)
33 static_assert(
elements == 4,
"Invalid number of elements" );
45 constexpr explicit Vector4(
const Vector4<U> & v ) noexcept :
x( T( v.x ) ),
y( T( v.y ) ),
z( T( v.z ) ),
w( T( v.w ) )
54 return x *
x +
y *
y +
z *
z +
w *
w;
69 return ( 1 / len ) * ( *this );
75 return {
x /
w,
y /
w,
z /
w };
80 return std::isfinite(
x ) && std::isfinite(
y ) && std::isfinite(
z ) && std::isfinite(
w );
89 [[nodiscard]]
friend constexpr auto operator -(
const Vector4<T> & a ) ->
Vector4<
decltype( -std::declval<T>() )> {
return { -a.
x, -a.y, -a.z, -a.w }; }
97 if constexpr ( std::is_integral_v<T> )
98 return { b.x / a, b.y / a, b.z / a, b.w / a };
100 return b * ( 1 / a );
108 if constexpr ( std::is_integral_v<T> )
109 { a.
x /= b; a.
y /= b; a.
z /= b; a.
w /= b;
return a; }
111 return a *= ( 1 / b );
122 return ( a - b ).lengthSq();
129 return ( a - b ).length();
136 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
150 return { a.
x * b.
x, a.
y * b.
y, a.
z * b.
z, a.
w * b.
w };
157 return { a.
x / b.
x, a.
y / b.
y, a.
z / b.
z, a.
w / b.
w };
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:34
MR_BIND_IGNORE auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:308
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:310
Definition MRCameraOrientationPlugin.h:8
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
Definition MRMatrix4.h:20
Definition MRMesh/MRMeshFwd.h:90
Definition MRSymMatrix4.h:13
Definition MRMesh/MRVector3.h:29
Definition MRVector4.h:22
friend constexpr Vector4< T > & operator*=(Vector4< T > &a, T b)
Definition MRVector4.h:105
friend constexpr bool operator!=(const Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:84
T y
Definition MRVector4.h:28
T z
Definition MRVector4.h:28
Vector3< T > proj3d() const MR_REQUIRES_IF_SUPPORTED(!std
assuming this is a point represented in homogeneous 4D coordinates, returns the point as 3D-vector
Definition MRVector4.h:73
T x
Definition MRVector4.h:28
friend constexpr Vector4< T > & operator-=(Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:104
T sqr(const Vector4< T > &a)
squared length
Definition MRVector4.h:141
T w
Definition MRVector4.h:28
T lengthSq() const
Definition MRVector4.h:52
Vector4(NoInit) noexcept
Definition MRVector4.h:35
friend constexpr const Vector4< T > & operator+(const Vector4< T > &a)
Definition MRVector4.h:88
friend constexpr auto operator-(const Vector4< T > &a) -> Vector4< decltype(-std::declval< T >())>
Definition MRVector4.h:89
T ValueType
Definition MRVector4.h:23
Vector4< T > div(const Vector4< T > &a, const Vector4< T > &b)
per component division
Definition MRVector4.h:155
MR_REQUIRES_IF_SUPPORTED(!std::is_same_v< T, U >) const expr explicit Vector4(const Vector4< U > &v) noexcept
Definition MRVector4.h:44
T distanceSq(const Vector4< T > &a, const Vector4< T > &b)
squared distance between two points, which is faster to compute than just distance
Definition MRVector4.h:120
constexpr Vector4(T x, T y, T z, T w) noexcept
Definition MRVector4.h:36
auto dot(const Vector4< T > &a, const Vector4< T > &b) -> decltype(a.x *b.x)
dot product
Definition MRVector4.h:134
Vector4< T > mult(const Vector4< T > &a, const Vector4< T > &b)
per component multiplication
Definition MRVector4.h:148
friend constexpr bool operator==(const Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:83
auto length() const
Definition MRVector4.h:56
constexpr const T & operator[](int e) const noexcept
Definition MRVector4.h:49
static constexpr Vector4 diagonal(T a) noexcept
Definition MRVector4.h:37
bool isFinite() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRVector4.h:78
friend constexpr auto operator/(Vector4< T > b, T a) -> Vector4< decltype(std::declval< T >()/std::declval< T >())>
Definition MRVector4.h:95
friend constexpr Vector4< T > & operator/=(Vector4< T > &a, T b)
Definition MRVector4.h:106
static constexpr int elements
Definition MRVector4.h:26
friend constexpr Vector4< T > & operator+=(Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:103
Vector4 normalized() const MR_REQUIRES_IF_SUPPORTED(!std
Definition MRVector4.h:64
constexpr Vector4() noexcept
Definition MRVector4.h:30
friend constexpr auto operator*(T a, const Vector4< T > &b) -> Vector4< decltype(std::declval< T >() *std::declval< T >())>
Definition MRVector4.h:93
T distance(const Vector4< T > &a, const Vector4< T > &b)
distance between two points, better use distanceSq for higher performance
Definition MRVector4.h:127