![]() |
NumCpp
2.16.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
|
Holds a 2D vector. More...
#include <Vec2.hpp>
Public Member Functions | |
| constexpr | Vec2 ()=default |
| Vec2 (const NdArray< double > &ndArray) | |
| Vec2 (const std::initializer_list< double > &inList) | |
| constexpr | Vec2 (double inX, double inY) noexcept |
| double | angle (const Vec2 &otherVec) const noexcept |
| Vec2 | clampMagnitude (double maxLength) const noexcept |
| double | distance (const Vec2 &otherVec) const noexcept |
| double | dot (const Vec2 &otherVec) const noexcept |
| Vec2 | lerp (const Vec2 &otherVec, double t) const noexcept |
| double | norm () const noexcept |
| Vec2 | normalize () const noexcept |
| bool | operator!= (const Vec2 &rhs) const noexcept |
| Vec2 & | operator*= (double scalar) noexcept |
| Vec2 & | operator+= (const Vec2 &rhs) noexcept |
| Vec2 & | operator+= (double scalar) noexcept |
| Vec2 & | operator-= (const Vec2 &rhs) noexcept |
| Vec2 & | operator-= (double scalar) noexcept |
| Vec2 & | operator/= (double scalar) noexcept |
| bool | operator== (const Vec2 &rhs) const noexcept |
| Vec2 | project (const Vec2 &otherVec) const noexcept |
| NdArray< double > | toNdArray () const |
| std::string | toString () const |
Static Public Member Functions | |
| static constexpr Vec2 | down () noexcept |
| static constexpr Vec2 | left () noexcept |
| static constexpr Vec2 | right () noexcept |
| static constexpr Vec2 | up () noexcept |
Data Fields | |
| double | x { 0. } |
| double | y { 0. } |
Holds a 2D vector.
|
constexprdefault |
Default Constructor
Constructor
| inX | the x component |
| inY | the y component |
Constructor
| inList |
Returns the angle between the two vectors
| otherVec |
Returns a copy of the vector with its magnitude clamped to maxLength
| maxLength |
Returns the distance between the two vectors
| otherVec |
Returns the dot product of the two vectors
| otherVec |
Returns the unit vector [0, -1]
Returns the unit vector [-1, 0]
Linearly interpolates between two vectors
| otherVec | |
| t | the amount to interpolate by (clamped from [0, 1]); |
|
inlinenoexcept |
Returns the magnitude of the vector
Not Equality operator
| rhs |
Equality operator
| rhs |
Returns the unit vector [1, 0]
|
inline |
Returns the Vec2 as a string
Returns the unit vector [0, 1]
| double nc::Vec2::x { 0. } |
| double nc::Vec2::y { 0. } |