6#include "MRPch/MRBindingMacros.h"
18#pragma warning(disable: 4804)
19#pragma warning(disable: 4146)
37 static_assert(
elements == 4,
"Invalid number of elements" );
49 constexpr explicit Vector4(
const Vector4<U> & v ) noexcept :
x( T( v.x ) ),
y( T( v.y ) ),
z( T( v.z ) ),
w( T( v.w ) )
58 return x *
x +
y *
y +
z *
z +
w *
w;
73 return ( 1 / len ) * ( *this );
79 return {
x /
w,
y /
w,
z /
w };
84 return std::isfinite(
x ) && std::isfinite(
y ) && std::isfinite(
z ) && std::isfinite(
w );
93 [[nodiscard]]
friend constexpr auto operator -(
const Vector4<T> & a ) ->
Vector4<
decltype( -std::declval<T>() )> {
return { -a.
x, -a.y, -a.z, -a.w }; }
101 if constexpr ( std::is_integral_v<T> )
102 return { b.x / a, b.y / a, b.z / a, b.w / a };
104 return b * ( 1 / a );
112 if constexpr ( std::is_integral_v<T> )
113 { a.
x /= b; a.
y /= b; a.
z /= b; a.
w /= b;
return a; }
115 return a *= ( 1 / b );
120 return s << vec.
x <<
' ' << vec.
y <<
' ' << vec.
z <<
' ' << vec.
w;
125 return s >> vec.
x >> vec.
y >> vec.
z >> vec.
w;
136 return ( a - b ).lengthSq();
143 return ( a - b ).length();
150 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
164 return { a.
x * b.
x, a.
y * b.
y, a.
z * b.
z, a.
w * b.
w };
171 return { a.
x / b.
x, a.
y / b.
y, a.
z / b.
z, a.
w / b.
w };
183MR_BIND_IGNORE_PY
auto end(
const Vector4<T> & v ) {
return &v[4]; }
185MR_BIND_IGNORE_PY
auto end( Vector4<T> & v ) {
return &v[4]; }
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:34
MR_BIND_IGNORE_PY auto end(const BitSet &)
Definition MRBitSet.h:397
MR_BIND_IGNORE_PY auto begin(const BitSet &a)
Definition MRBitSet.h:395
friend constexpr Vector4< T > & operator*=(Vector4< T > &a, T b)
Definition MRVector4.h:109
friend constexpr bool operator!=(const Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:88
T y
Definition MRVector4.h:32
T z
Definition MRVector4.h:32
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
T x
Definition MRVector4.h:32
friend constexpr Vector4< T > & operator-=(Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:108
friend std::istream & operator>>(std::istream &s, Vector4 &vec)
Definition MRVector4.h:123
T sqr(const Vector4< T > &a)
squared length
Definition MRVector4.h:155
T w
Definition MRVector4.h:32
T lengthSq() const
Definition MRVector4.h:56
MR_BIND_IGNORE_PY auto begin(const Vector4< T > &v)
We don't need to bind those functions in Python, because this doesn't prevent __iter__ from being gen...
Definition MRVector4.h:178
Vector4(NoInit) noexcept
Definition MRVector4.h:39
friend std::ostream & operator<<(std::ostream &s, const Vector4 &vec)
Definition MRVector4.h:118
friend constexpr const Vector4< T > & operator+(const Vector4< T > &a)
NOTE: We use std::declval() in the operators below because libclang 18 in our binding generator is bu...
Definition MRVector4.h:92
friend constexpr auto operator-(const Vector4< T > &a) -> Vector4< decltype(-std::declval< T >())>
Definition MRVector4.h:93
T ValueType
Definition MRVector4.h:27
Vector4< T > div(const Vector4< T > &a, const Vector4< T > &b)
per component division
Definition MRVector4.h:169
MR_REQUIRES_IF_SUPPORTED(!std::is_same_v< T, U >) const expr explicit Vector4(const Vector4< U > &v) noexcept
Definition MRVector4.h:48
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:134
constexpr Vector4(T x, T y, T z, T w) noexcept
Definition MRVector4.h:40
auto dot(const Vector4< T > &a, const Vector4< T > &b) -> decltype(a.x *b.x)
dot product
Definition MRVector4.h:148
Vector4< T > mult(const Vector4< T > &a, const Vector4< T > &b)
per component multiplication
Definition MRVector4.h:162
friend constexpr bool operator==(const Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:87
auto length() const
Definition MRVector4.h:60
constexpr const T & operator[](int e) const noexcept
Definition MRVector4.h:53
static constexpr Vector4 diagonal(T a) noexcept
Definition MRVector4.h:41
bool isFinite() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRVector4.h:82
friend constexpr auto operator/(Vector4< T > b, T a) -> Vector4< decltype(std::declval< T >()/std::declval< T >())>
Definition MRVector4.h:99
friend constexpr Vector4< T > & operator/=(Vector4< T > &a, T b)
Definition MRVector4.h:110
static constexpr int elements
Definition MRVector4.h:30
friend constexpr Vector4< T > & operator+=(Vector4< T > &a, const Vector4< T > &b)
Definition MRVector4.h:107
Vector4 normalized() const MR_REQUIRES_IF_SUPPORTED(!std
Definition MRVector4.h:68
constexpr Vector4() noexcept
Definition MRVector4.h:34
friend constexpr auto operator*(T a, const Vector4< T > &b) -> Vector4< decltype(std::declval< T >() *std::declval< T >())>
Definition MRVector4.h:97
T distance(const Vector4< T > &a, const Vector4< T > &b)
distance between two points, better use distanceSq for higher performance
Definition MRVector4.h:141
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRMatrix4.h:25
Definition MRSymMatrix4.h:16
Definition MRVector3.h:33
Definition MRVector4.h:26