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.
x * b.
y - a.
y * b.
x;
100 return a.
x * b.
x + a.
y * b.
y;
114 return { a.
x * b.
x,a.
y * b.
y };
121 return { a.
x / b.
x, a.
y / b.
y };
128 return std::atan2( std::abs( cross( a, b ) ), dot( a, b ) );
137 if ( abs( x ) < abs( y ) )
144inline bool operator ==(
const Vector2<T> & a,
const Vector2<T> & b )
145 {
return a.x == b.x && a.y == b.y; }
148inline bool operator !=(
const Vector2<T> & a,
const Vector2<T> & b )
149 {
return !( a == b ); }
152inline Vector2<T>
operator +(
const Vector2<T> & a,
const Vector2<T> & b )
153 {
return { a.x + b.x, a.y + b.y }; }
156inline Vector2<T>
operator -(
const Vector2<T> & a,
const Vector2<T> & b )
157 {
return { a.x - b.x, a.y - b.y }; }
160inline Vector2<T>
operator *( T a,
const Vector2<T> & b )
161 {
return { a * b.x, a * b.y }; }
164inline Vector2<T>
operator *(
const Vector2<T> & b, T a )
165 {
return { a * b.x, a * b.y }; }
168inline Vector2<T>
operator /( Vector2<T> b, T a )
169 { b /= a;
return b; }
172inline auto begin(
const Vector2<T> & v ) {
return &v[0]; }
174inline auto begin( Vector2<T> & v ) {
return &v[0]; }
177inline auto end(
const Vector2<T> & v ) {
return &v[2]; }
179inline 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: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 MRMatrix2.h:13
Definition MRMesh/MRMeshFwd.h:56
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:119
T cross(const Vector2< T > &a, const Vector2< T > &b)
cross product
Definition MRVector2.h:91
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
Vector2 furthestBasisVector() const MR_REQUIRES_IF_SUPPORTED(!std 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:67
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
Vector2 normalized() const MR_REQUIRES_IF_SUPPORTED(!std
Definition MRVector2.h:52
T dot(const Vector2< T > &a, const Vector2< T > &b)
dot product
Definition MRVector2.h:98
constexpr Vector2() noexcept
Definition MRVector2.h:26
static constexpr Vector2 diagonal(T a) noexcept
Definition MRVector2.h:31
Vector2 & operator*=(T b)
Definition MRVector2.h:71
constexpr Vector2(T x, T y) noexcept
Definition MRVector2.h:28
T sqr(const Vector2< T > &a)
squared length
Definition MRVector2.h:105
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:112
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:126
bool isFinite() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRVector2.h:80
Vector2 & operator+=(const Vector2< T > &b)
Definition MRVector2.h:69
Definition MRMesh/MRVector3.h:19