21 constexpr Vector4() noexcept :
x( 0 ),
y( 0 ),
z( 0 ),
w( 0 ) { }
29 constexpr explicit Vector4(
const Vector4<U> & v ) noexcept :
x( T( v.x ) ),
y( T( v.y ) ),
z( T( v.z ) ),
w( T( v.w ) )
33 constexpr const T &
operator [](
int e )
const noexcept {
return *( &
x + e ); }
34 constexpr T &
operator [](
int e )
noexcept {
return *( &
x + e ); }
38 return x *
x +
y *
y +
z *
z +
w *
w;
53 return ( 1 / len ) * ( *this );
61 x += b.
x;
y += b.
y;
z += b.
z;
w += b.
w;
return *
this;
65 x -= b.
x;
y -= b.
y;
z -= b.
z;
w -= b.
w;
return *
this;
70 if constexpr ( std::is_integral_v<T> )
71 {
x /= b;
y /= b;
z /= b;
w /= b;
return *
this; }
73 return *
this *= ( 1 / b );
79 return {
x /
w,
y /
w,
z /
w };
84 return std::isfinite(
x ) && std::isfinite(
y ) && std::isfinite(
z ) && std::isfinite(
w );
94 return a.
x == b.
x && a.
y == b.
y && a.
z == b.
z && a.
w == b.
w;
104inline Vector4<T>
operator +(
const Vector4<T> & a,
const Vector4<T> & b )
106 return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w};
110inline Vector4<T>
operator -(
const Vector4<T> & a,
const Vector4<T> & b )
112 return {a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w};
116inline Vector4<T>
operator *( T a,
const Vector4<T> & b )
118 return {a * b.x, a * b.y, a * b.z, a * b.w};
122inline Vector4<T>
operator *(
const Vector4<T> & b, T a )
124 return {a * b.x, a * b.y, a * b.z, a * b.w};
128inline Vector4<T>
operator /( Vector4<T> b, T a )
129 { b /= a;
return b; }
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 };
164inline auto begin( Vector4<T> & v ) {
return &v[0]; }
167inline auto end(
const Vector4<T> & v ) {
return &v[4]; }
169inline auto end( Vector4<T> & v ) {
return &v[4]; }
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:29
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:342
auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:280
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:282
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:276
Definition MRCameraOrientationPlugin.h:8
Color operator/(const Color &b, float a)
Definition MRColor.h:128
Color operator*(float a, const Color &b)
Definition MRColor.h:118
Color operator+(const Color &a, const Color &b)
Definition MRColor.h:108
Definition MRMatrix4.h:14
Definition MRMesh/MRMeshFwd.h:56
Definition MRSymMatrix4.h:13
Definition MRMesh/MRVector3.h:19
Definition MRVector4.h:13
Vector4 & operator*=(T b)
Definition MRVector4.h:67
T y
Definition MRVector4.h:19
T z
Definition MRVector4.h:19
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:77
const Vector4 & operator+() const
Definition MRVector4.h:57
T x
Definition MRVector4.h:19
T sqr(const Vector4< T > &a)
squared length
Definition MRVector4.h:141
T w
Definition MRVector4.h:19
T lengthSq() const
Definition MRVector4.h:36
Vector4(NoInit) noexcept
Definition MRVector4.h:22
T ValueType
Definition MRVector4.h:14
Vector4 & operator+=(const Vector4< T > &b)
Definition MRVector4.h:59
Vector4< T > div(const Vector4< T > &a, const Vector4< T > &b)
per component division
Definition MRVector4.h:155
Vector4 & operator-=(const Vector4< T > &b)
Definition MRVector4.h:63
constexpr Vector4(T x, T y, T z, T w) noexcept
Definition MRVector4.h:23
constexpr Vector4(const Vector4< U > &v) noexcept
Definition MRVector4.h:29
Vector4 operator-() const
Definition MRVector4.h:56
Vector4< T > mult(const Vector4< T > &a, const Vector4< T > &b)
per component multiplication
Definition MRVector4.h:148
Vector4 & operator/=(T b)
Definition MRVector4.h:68
auto length() const
Definition MRVector4.h:40
constexpr const T & operator[](int e) const noexcept
Definition MRVector4.h:33
static constexpr Vector4 diagonal(T a) noexcept
Definition MRVector4.h:24
bool isFinite() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRVector4.h:82
static constexpr int elements
Definition MRVector4.h:17
Vector4 normalized() const MR_REQUIRES_IF_SUPPORTED(!std
Definition MRVector4.h:48
T dot(const Vector4< T > &a, const Vector4< T > &b)
dot product
Definition MRVector4.h:134
constexpr Vector4() noexcept
Definition MRVector4.h:21