27 constexpr Vector3() noexcept :
x( 0 ),
y( 0 ),
z( 0 ) { }
41 constexpr explicit Vector3(
const Vector3<U> & v ) noexcept :
x( T( v.x ) ),
y( T( v.y ) ),
z( T( v.z ) ) { }
43 constexpr const T &
operator [](
int e )
const noexcept {
return *( &
x + e ); }
44 constexpr T &
operator [](
int e )
noexcept {
return *( &
x + e ); }
60 return ( 1 / len ) * (*this);
73 return xf ? ( *xf )( *this ) : *
this;
79 for (
auto i = 0; i <
elements; ++i )
80 if ( (*
this)[i] == 0.f && std::signbit( (*
this)[i] ) )
86 return std::isfinite(
x ) && std::isfinite(
y ) && std::isfinite(
z );
105 if constexpr ( std::is_integral_v<T> )
106 { a.x /= b; a.y /= b; a.z /= b;
return a; }
108 return a *= ( 1 / b );
122 a.
y * b.
z - a.
z * b.
y,
123 a.
z * b.
x - a.
x * b.
z,
124 a.
x * b.
y - a.
y * b.
x
132 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
146 return dot( a, cross( b, c ) );
153 return { a.
x * b.
x,a.
y * b.
y,a.
z * b.
z };
160 return { a.
x / b.
x, a.
y / b.
y, a.
z / b.
z };
169 return std::atan2( cross( a, b ).
length(), dot( a, b ) );
178 if ( abs( x ) < abs( y ) )
179 return ( abs( x ) < abs( z ) ) ?
Vector3( 1, 0, 0 ) :
Vector3( 0, 0, 1 );
181 return ( abs( y ) < abs( z ) ) ?
Vector3( 0, 1, 0 ) :
Vector3( 0, 0, 1 );
188 auto c1 = furthestBasisVector();
189 res.first = cross( *
this, c1 ).normalized();
190 res.second = cross( *
this, res.first ).normalized();
196 {
return a.x == b.x && a.y == b.y && a.z == b.z; }
200 {
return !( a == b ); }
204 {
return { T( a.x + b.x ), T( a.y + b.y ), T( a.z + b.z ) }; }
208 {
return { T( a.x - b.x ), T( a.y - b.y ), T( a.z - b.z ) }; }
212 {
return { T( a * b.x ), T( a * b.y ), T( a * b.z ) }; }
216 {
return { T( a * b.x ), T( a * b.y ), T( a * b.z ) }; }
220 { b /= a;
return b; }
226 const auto zenithAngle = T( PI2 ) - altitude;
229 std::sin( zenithAngle ) * std::cos( azimuth ),
230 std::sin( zenithAngle ) * std::sin( azimuth ),
231 std::cos( zenithAngle )
constexpr A & operator/=(A &a, B b)
Definition MRImGuiVectorOperators.h:115
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:26
length
Definition MRObjectDimensionsEnum.h:14
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:325
auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:263
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:265
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:259
MRMESH_API FloatGrid operator+=(FloatGrid &a, const FloatGrid &b)
MRMESH_API FloatGrid operator-=(FloatGrid &a, const FloatGrid &b)
MRMESH_API FloatGrid operator*=(FloatGrid &a, const FloatGrid &b)
Definition MRCameraOrientationPlugin.h:7
Color operator/(const Color &b, float a)
Definition MRColor.h:128
Color operator*(float a, const Color &b)
Definition MRColor.h:118
MRMESH_CLASS Vector3
Definition MRMesh/MRMeshFwd.h:136
Color operator+(const Color &a, const Color &b)
Definition MRColor.h:108
Definition MRMesh/MRAffineXf.h:14
Definition MRMesh/MRMatrix3.h:13
Definition MRMesh/MRMeshFwd.h:56
Definition MRSymMatrix3.h:15
Definition MRVector2.h:18
Definition MRMesh/MRVector3.h:19
static constexpr Vector3 plusX() noexcept
Definition MRMesh/MRVector3.h:33
void unsignZeroValues() MR_REQUIRES_IF_SUPPORTED(std
get rid of signed zero values to be sure that equal vectors have identical binary representation
Definition MRMesh/MRVector3.h:77
Vector3< T > unitVector3(T azimuth, T altitude)
returns a point on unit sphere given two angles
Definition MRMesh/MRVector3.h:224
Vector3< T > div(const Vector3< T > &a, const Vector3< T > &b)
per component division
Definition MRMesh/MRVector3.h:158
T dot(const Vector3< T > &a, const Vector3< T > &b)
dot product
Definition MRMesh/MRVector3.h:130
T x
Definition MRMesh/MRVector3.h:25
static constexpr Vector3 minusX() noexcept
Definition MRMesh/MRVector3.h:36
static constexpr Vector3 minusY() noexcept
Definition MRMesh/MRVector3.h:37
T y
Definition MRMesh/MRVector3.h:25
static constexpr int elements
Definition MRMesh/MRVector3.h:23
Vector3(NoInit) noexcept
Definition MRMesh/MRVector3.h:28
T ValueType
Definition MRMesh/MRVector3.h:20
constexpr const T & operator[](int e) const noexcept
Definition MRMesh/MRVector3.h:43
Vector3 furthestBasisVector() const MR_REQUIRES_IF_SUPPORTED(!std std::pair< Vector3, Vector3 > perpendicular() const MR_REQUIRES_IF_SUPPORTED(std Vector3 transformed(const AffineXf3< T > *xf) const MR_REQUIRES_IF_SUPPORTED(!std
returns one of 3 basis unit vector that makes the biggest angle with the direction specified by this
Definition MRMesh/MRVector3.h:71
auto length() const
Definition MRMesh/MRVector3.h:47
constexpr Vector3(T x, T y, T z) noexcept
Definition MRMesh/MRVector3.h:29
T mixed(const Vector3< T > &a, const Vector3< T > &b, const Vector3< T > &c)
mixed product
Definition MRMesh/MRVector3.h:144
static constexpr Vector3 plusZ() noexcept
Definition MRMesh/MRVector3.h:35
Vector3 normalized() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRMesh/MRVector3.h:55
T sqr(const Vector3< T > &a)
squared length
Definition MRMesh/MRVector3.h:137
T angle(const Vector3< T > &a, const Vector3< T > &b)
Definition MRMesh/MRVector3.h:167
constexpr Vector3(const Vector2< T > &v) noexcept
Definition MRMesh/MRVector3.h:30
constexpr Vector3(const Vector3< U > &v) noexcept
Definition MRMesh/MRVector3.h:41
constexpr Vector3() noexcept
Definition MRMesh/MRVector3.h:27
static constexpr Vector3 minusZ() noexcept
Definition MRMesh/MRVector3.h:38
Vector3< T > mult(const Vector3< T > &a, const Vector3< T > &b)
per component multiplication
Definition MRMesh/MRVector3.h:151
T z
Definition MRMesh/MRVector3.h:25
T lengthSq() const
Definition MRMesh/MRVector3.h:46
static constexpr Vector3 plusY() noexcept
Definition MRMesh/MRVector3.h:34
bool isFinite() const MR_REQUIRES_IF_SUPPORTED(std
Definition MRMesh/MRVector3.h:84
static constexpr Vector3 diagonal(T a) noexcept
Definition MRMesh/MRVector3.h:32
Vector3< T > cross(const Vector3< T > &a, const Vector3< T > &b)
cross product
Definition MRMesh/MRVector3.h:119