40 constexpr const T &
operator [](
int e )
const noexcept {
return *( &
x + e ); }
41 constexpr T &
operator [](
int e )
noexcept {
return *( &
x + e ); }
57 return ( 1 / len ) * (*this);
74 if constexpr ( std::is_integral_v<T> )
75 {
x /= b;
y /= b;
return *
this; }
77 return *
this *= ( 1 / b );
82 return std::isfinite(
x ) && std::isfinite(
y );
93 return ( a - b ).lengthSq();
100 return ( a - b ).length();
107 return a.
x * b.
y - a.
y * b.
x;
114 return a.
x * b.
x + a.
y * b.
y;
128 return { a.
x * b.
x,a.
y * b.
y };
135 return { a.
x / b.
x, a.
y / b.
y };
142 return std::atan2( std::abs( cross( a, b ) ), dot( a, b ) );
151 if ( abs( x ) < abs( y ) )
158inline bool operator ==(
const Vector2<T> & a,
const Vector2<T> & b )
159 {
return a.x == b.x && a.y == b.y; }
162inline bool operator !=(
const Vector2<T> & a,
const Vector2<T> & b )
163 {
return !( a == b ); }
166inline Vector2<T>
operator +(
const Vector2<T> & a,
const Vector2<T> & b )
167 {
return { a.x + b.x, a.y + b.y }; }
170inline Vector2<T>
operator -(
const Vector2<T> & a,
const Vector2<T> & b )
171 {
return { a.x - b.x, a.y - b.y }; }
174inline Vector2<T>
operator *( T a,
const Vector2<T> & b )
175 {
return { a * b.x, a * b.y }; }
178inline Vector2<T>
operator *(
const Vector2<T> & b, T a )
179 {
return { a * b.x, a * b.y }; }
182inline Vector2<T>
operator /( Vector2<T> b, T a )
183 { b /= a;
return b; }
186inline auto begin(
const Vector2<T> & v ) {
return &v[0]; }
188inline auto begin( Vector2<T> & v ) {
return &v[0]; }
191inline auto end(
const Vector2<T> & v ) {
return &v[2]; }
193inline auto end( Vector2<T> & v ) {
return &v[2]; }
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:29
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:357
MR_BIND_IGNORE auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:295
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...
MR_BIND_IGNORE bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:291
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:297
Color operator/(const Color &b, float a)
Definition MRMesh/MRColor.h:128
Color operator*(float a, const Color &b)
Definition MRMesh/MRColor.h:118
Color operator+(const Color &a, const Color &b)
Definition MRMesh/MRColor.h:108
Definition MRMatrix2.h:13
Definition MRMesh/MRMeshFwd.h:89
Definition MRSymMatrix2.h:14
Definition MRVector2.h:18
T x
Definition MRVector2.h:24
Vector2(NoInit) noexcept
Definition MRVector2.h:27
Vector2< T > div(const Vector2< T > &a, const Vector2< T > &b)
per component division
Definition MRVector2.h:133
T cross(const Vector2< T > &a, const Vector2< T > &b)
cross product
Definition MRVector2.h:105
Vector2 furthestBasisVector() const
returns one of 2 basis unit vector that makes the biggest angle with the direction specified by this
static constexpr Vector2 plusY() noexcept
Definition MRVector2.h:33
constexpr Vector2(const Vector2< U > &v) noexcept
Definition MRVector2.h:38
const Vector2 & operator+() const
Definition MRVector2.h:61
static constexpr Vector2 minusX() noexcept
Definition MRVector2.h:34
T ValueType
Definition MRVector2.h:19
T y
Definition MRVector2.h:24
Vector2 operator-() const
Definition MRVector2.h:60
constexpr Vector2(const Vector3< T > &v) noexcept
Definition MRVector2.h:29
Vector2 & operator-=(const Vector2< T > &b)
Definition MRVector2.h:70
constexpr const T & operator[](int e) const noexcept
Definition MRVector2.h:40
T dot(const Vector2< T > &a, const Vector2< T > &b)
dot product
Definition MRVector2.h:112
constexpr Vector2() noexcept
Definition MRVector2.h:26
bool isFinite() const
Definition MRVector2.h:80
static constexpr Vector2 diagonal(T a) noexcept
Definition MRVector2.h:31
Vector2 & operator*=(T b)
Definition MRVector2.h:71
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:91
Vector2 perpendicular() const
returns same length vector orthogonal to this (rotated 90 degrees counter-clockwise)
Definition MRVector2.h:67
T distance(const Vector2< T > &a, const Vector2< T > &b)
distance between two points, better use distanceSq for higher performance
Definition MRVector2.h:98
constexpr Vector2(T x, T y) noexcept
Definition MRVector2.h:28
T sqr(const Vector2< T > &a)
squared length
Definition MRVector2.h:119
static constexpr int elements
Definition MRVector2.h:22
auto length() const
Definition MRVector2.h:44
static constexpr Vector2 plusX() noexcept
Definition MRVector2.h:32
Vector2< T > mult(const Vector2< T > &a, const Vector2< T > &b)
per component multiplication
Definition MRVector2.h:126
Vector2 normalized() const
Definition MRVector2.h:52
Vector2 & operator/=(T b)
Definition MRVector2.h:72
T lengthSq() const
Definition MRVector2.h:43
static constexpr Vector2 minusY() noexcept
Definition MRVector2.h:35
T angle(const Vector2< T > &a, const Vector2< T > &b)
angle in radians between two vectors
Definition MRVector2.h:140
Vector2 & operator+=(const Vector2< T > &b)
Definition MRVector2.h:69
Definition MRMesh/MRVector3.h:19