5#include "MRPch/MRBindingMacros.h"
16#pragma warning(disable: 4804)
17#pragma warning(disable: 4146)
51 constexpr explicit Vector2(
const Vector2<U> & v ) noexcept :
x( T( v.x ) ),
y( T( v.y ) ) { }
53 constexpr const T &
operator [](
int e )
const noexcept {
return *( &
x + e ); }
54 constexpr T &
operator [](
int e )
noexcept {
return *( &
x + e ); }
70 return ( 1 / len ) * (*this);
81 return std::isfinite(
x ) && std::isfinite(
y );
98 if constexpr ( std::is_integral_v<T> )
99 return { b.x / a, b.y / a };
101 return b * ( 1 / a );
109 if constexpr ( std::is_integral_v<T> )
110 { a.
x /= b; a.
y /= b;
return a; }
112 return a *= ( 1 / b );
123 return ( a - b ).lengthSq();
130 return ( a - b ).length();
137 return a.
x * b.
y - a.
y * b.
x;
144 return a.x * b.x + a.y * b.y;
158 return { a.
x * b.
x,a.
y * b.
y };
165 return { a.
x / b.
x, a.
y / b.
y };
172 return std::atan2( std::abs( cross( a, b ) ), dot( a, b ) );
181 if ( abs( x ) < abs( y ) )
209struct std::hash<
MR::Vector2f>
211 size_t operator()( MR::Vector2f
const& p )
const noexcept
214 static_assert(
sizeof( float ) ==
sizeof( std::uint32_t ) );
215 std::memcpy( &xy, &p.x,
sizeof( std::uint64_t ) );
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:31
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 MRMatrix2.h:19
Definition MRMesh/MRMeshFwd.h:90
Definition MRSymMatrix2.h:14
Definition MRVector2.h:27
T x
Definition MRVector2.h:33
Vector2(NoInit) noexcept
Definition MRVector2.h:36
Vector2< T > div(const Vector2< T > &a, const Vector2< T > &b)
per component division
Definition MRVector2.h:163
T cross(const Vector2< T > &a, const Vector2< T > &b)
cross product
Definition MRVector2.h:135
friend constexpr bool operator!=(const Vector2< T > &a, const Vector2< T > &b)
Definition MRVector2.h:85
static constexpr Vector2 plusY() noexcept
Definition MRVector2.h:44
static constexpr Vector2 minusX() noexcept
Definition MRVector2.h:45
friend constexpr Vector2< T > & operator-=(Vector2< T > &a, const Vector2< T > &b)
Definition MRVector2.h:105
friend constexpr Vector2< T > & operator+=(Vector2< T > &a, const Vector2< T > &b)
Definition MRVector2.h:104
friend constexpr auto operator*(T a, const Vector2< T > &b) -> Vector2< decltype(std::declval< T >() *std::declval< T >())>
Definition MRVector2.h:94
T ValueType
Definition MRVector2.h:28
friend constexpr Vector2< T > & operator/=(Vector2< T > &a, T b)
Definition MRVector2.h:107
T y
Definition MRVector2.h:33
constexpr const T & operator[](int e) const noexcept
Definition MRVector2.h:53
Vector2 normalized() const MR_REQUIRES_IF_SUPPORTED(!std
Definition MRVector2.h:65
friend constexpr bool operator==(const Vector2< T > &a, const Vector2< T > &b)
Definition MRVector2.h:84
constexpr Vector2() noexcept
Definition MRVector2.h:35
Vector2 furthestBasisVector() const MR_REQUIRES_IF_SUPPORTED(!std constexpr Vector2 perpendicular() const MR_REQUIRES_IF_SUPPORTED(!std
returns one of 2 basis unit vector that makes the biggest angle with the direction specified by this
Definition MRVector2.h:77
friend constexpr auto operator/(Vector2< T > b, T a) -> Vector2< decltype(std::declval< T >()/std::declval< T >())>
Definition MRVector2.h:96
static constexpr Vector2 diagonal(T a) noexcept
Definition MRVector2.h:42
T distanceSq(const Vector2< T > &a, const Vector2< T > &b)
squared distance between two points, which is faster to compute than just distance
Definition MRVector2.h:121
T distance(const Vector2< T > &a, const Vector2< T > &b)
distance between two points, better use distanceSq for higher performance
Definition MRVector2.h:128
MR_REQUIRES_IF_SUPPORTED(!std::is_same_v< T, U >) const expr explicit Vector2(const Vector2< U > &v) noexcept
Definition MRVector2.h:50
constexpr Vector2(T x, T y) noexcept
Definition MRVector2.h:37
T sqr(const Vector2< T > &a)
squared length
Definition MRVector2.h:149
static constexpr int elements
Definition MRVector2.h:31
auto length() const
Definition MRVector2.h:57
static constexpr Vector2 plusX() noexcept
Definition MRVector2.h:43
auto dot(const Vector2< T > &a, const Vector2< T > &b) -> decltype(a.x *b.x)
dot product
Definition MRVector2.h:142
MR_REQUIRES_IF_SUPPORTED(std::constructible_from< T, U >) explicit const expr Vector2(const Vector3< U > &v) noexcept
Definition MRVector2.h:39
Vector2< T > mult(const Vector2< T > &a, const Vector2< T > &b)
per component multiplication
Definition MRVector2.h:156
friend constexpr Vector2< T > & operator*=(Vector2< T > &a, T b)
Definition MRVector2.h:106
friend constexpr auto operator-(const Vector2< T > &a) -> Vector2< decltype(-std::declval< T >())>
Definition MRVector2.h:90
T lengthSq() const
Definition MRVector2.h:56
static constexpr Vector2 minusY() noexcept
Definition MRVector2.h:46
friend constexpr const Vector2< T > & operator+(const Vector2< T > &a)
Definition MRVector2.h:89
T angle(const Vector2< T > &a, const Vector2< T > &b)
angle in radians between two vectors
Definition MRVector2.h:170
bool isFinite() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRVector2.h:79
Definition MRMesh/MRVector3.h:28