4#include "MRPch/MRBindingMacros.h"
12#pragma warning(disable: 4804)
13#pragma warning(disable: 4146)
28 constexpr Vector4() noexcept :
x( 0 ),
y( 0 ),
z( 0 ),
w( 0 ) { }
36 constexpr explicit Vector4(
const Vector4<U> & v ) noexcept :
x( T( v.x ) ),
y( T( v.y ) ),
z( T( v.z ) ),
w( T( v.w ) )
40 constexpr const T &
operator [](
int e )
const noexcept {
return *( &
x + e ); }
41 constexpr T &
operator [](
int e )
noexcept {
return *( &
x + e ); }
45 return x *
x +
y *
y +
z *
z +
w *
w;
60 return ( 1 / len ) * ( *this );
66 return {
x /
w,
y /
w,
z /
w };
71 return std::isfinite(
x ) && std::isfinite(
y ) && std::isfinite(
z ) && std::isfinite(
w );
80 [[nodiscard]]
friend constexpr auto operator -(
const Vector4<T> & a ) ->
Vector4<
decltype( -std::declval<T>() )> {
return { -a.
x, -a.y, -a.z, -a.w }; }
88 if constexpr ( std::is_integral_v<T> )
89 return { b.x / a, b.y / a, b.z / a, b.w / a };
99 if constexpr ( std::is_integral_v<T> )
100 { a.
x /= b; a.y /= b; a.z /= b; a.w /= b;
return a; }
102 return a *= ( 1 / b );
113 return ( a - b ).lengthSq();
120 return ( a - b ).length();
127 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
141 return { a.
x * b.
x, a.
y * b.
y, a.
z * b.
z, a.
w * b.
w };
148 return { a.
x / b.
x, a.
y / b.
y, a.
z / b.
z, a.
w / b.
w };
157MR_BIND_IGNORE
auto begin( Vector4<T> & v ) {
return &v[0]; }
160MR_BIND_IGNORE
auto end(
const Vector4<T> & v ) {
return &v[4]; }
162MR_BIND_IGNORE
auto end( Vector4<T> & v ) {
return &v[4]; }
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:31
MR_BIND_IGNORE auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:295
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:297
Definition MRMatrix4.h:20
Definition MRMesh/MRMeshFwd.h:89
Definition MRSymMatrix4.h:13
Definition MRMesh/MRVector3.h:26
Definition MRVector4.h:20
Vector4 normalized() const
Definition MRVector4.h:55
friend constexpr Vector4< T > & operator*=(Vector4< T > &a, T b)
Definition MRVector4.h:96
friend constexpr bool operator!=(const Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:75
T y
Definition MRVector4.h:26
T z
Definition MRVector4.h:26
T x
Definition MRVector4.h:26
friend constexpr Vector4< T > & operator-=(Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:95
T sqr(const Vector4< T > &a)
squared length
Definition MRVector4.h:132
T w
Definition MRVector4.h:26
T lengthSq() const
Definition MRVector4.h:43
Vector4(NoInit) noexcept
Definition MRVector4.h:29
friend constexpr const Vector4< T > & operator+(const Vector4< T > &a)
Definition MRVector4.h:79
friend constexpr auto operator-(const Vector4< T > &a) -> Vector4< decltype(-std::declval< T >())>
Definition MRVector4.h:80
T ValueType
Definition MRVector4.h:21
Vector3< T > proj3d() const
assuming this is a point represented in homogeneous 4D coordinates, returns the point as 3D-vector
Definition MRVector4.h:64
Vector4< T > div(const Vector4< T > &a, const Vector4< T > &b)
per component division
Definition MRVector4.h:146
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:111
constexpr Vector4(T x, T y, T z, T w) noexcept
Definition MRVector4.h:30
constexpr Vector4(const Vector4< U > &v) 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:125
Vector4< T > mult(const Vector4< T > &a, const Vector4< T > &b)
per component multiplication
Definition MRVector4.h:139
friend constexpr bool operator==(const Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:74
auto length() const
Definition MRVector4.h:47
constexpr const T & operator[](int e) const noexcept
Definition MRVector4.h:40
static constexpr Vector4 diagonal(T a) noexcept
Definition MRVector4.h:31
bool isFinite() const
Definition MRVector4.h:69
friend constexpr auto operator/(Vector4< T > b, T a) -> Vector4< decltype(std::declval< T >()/std::declval< T >())>
Definition MRVector4.h:86
friend constexpr Vector4< T > & operator/=(Vector4< T > &a, T b)
Definition MRVector4.h:97
static constexpr int elements
Definition MRVector4.h:24
friend constexpr Vector4< T > & operator+=(Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:94
constexpr Vector4() noexcept
Definition MRVector4.h:28
friend constexpr auto operator*(T a, const Vector4< T > &b) -> Vector4< decltype(std::declval< T >() *std::declval< T >())>
Definition MRVector4.h:84
T distance(const Vector4< T > &a, const Vector4< T > &b)
distance between two points, better use distanceSq for higher performance
Definition MRVector4.h:118