Holds a 2D vector.
More...
#include <Vec2.hpp>
|
double | x { 0. } |
|
double | y { 0. } |
|
◆ Vec2() [1/4]
constexpr nc::Vec2::Vec2 |
( |
| ) |
|
|
constexprdefault |
◆ Vec2() [2/4]
constexpr nc::Vec2::Vec2 |
( |
double |
inX, |
|
|
double |
inY |
|
) |
| |
|
inlineconstexprnoexcept |
Constructor
- Parameters
-
inX | the x component |
inY | the y component |
◆ Vec2() [3/4]
nc::Vec2::Vec2 |
( |
const std::initializer_list< double > & |
inList | ) |
|
|
inline |
◆ Vec2() [4/4]
nc::Vec2::Vec2 |
( |
const NdArray< double > & |
ndArray | ) |
|
|
inline |
◆ angle()
double nc::Vec2::angle |
( |
const Vec2 & |
otherVec | ) |
const |
|
inlinenoexcept |
Returns the angle between the two vectors
- Parameters
-
- Returns
- the angle in radians
◆ clampMagnitude()
Vec2 nc::Vec2::clampMagnitude |
( |
double |
maxLength | ) |
const |
|
inlinenoexcept |
Returns a copy of the vector with its magnitude clamped to maxLength
- Parameters
-
- Returns
- Vec2
◆ distance()
double nc::Vec2::distance |
( |
const Vec2 & |
otherVec | ) |
const |
|
inlinenoexcept |
Returns the distance between the two vectors
- Parameters
-
- Returns
- the distance (equivalent to (a - b).norm()
◆ dot()
double nc::Vec2::dot |
( |
const Vec2 & |
otherVec | ) |
const |
|
inlinenoexcept |
Returns the dot product of the two vectors
- Parameters
-
- Returns
- the dot product
◆ down()
static constexpr Vec2 nc::Vec2::down |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
Returns the unit vector [0, -1]
- Returns
- Vec2
◆ left()
static constexpr Vec2 nc::Vec2::left |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
Returns the unit vector [-1, 0]
- Returns
- Vec2
◆ lerp()
Vec2 nc::Vec2::lerp |
( |
const Vec2 & |
otherVec, |
|
|
double |
t |
|
) |
| const |
|
inlinenoexcept |
Linearly interpolates between two vectors
- Parameters
-
otherVec | |
t | the amount to interpolate by (clamped from [0, 1]); |
- Returns
- Vec2
◆ norm()
double nc::Vec2::norm |
( |
| ) |
const |
|
inlinenoexcept |
Returns the magnitude of the vector
- Returns
- magnitude of the vector
◆ normalize()
Vec2 nc::Vec2::normalize |
( |
| ) |
const |
|
inlinenoexcept |
Returns a new normalized Vec2
- Returns
- Vec2
◆ operator!=()
bool nc::Vec2::operator!= |
( |
const Vec2 & |
rhs | ) |
const |
|
inlinenoexcept |
Not Equality operator
- Parameters
-
- Returns
- bool
◆ operator*=()
Vec2 & nc::Vec2::operator*= |
( |
double |
scalar | ) |
|
|
inlinenoexcept |
Scalar mulitplication
- Parameters
-
- Returns
- Vec2
◆ operator+=() [1/2]
Vec2 & nc::Vec2::operator+= |
( |
const Vec2 & |
rhs | ) |
|
|
inlinenoexcept |
Adds the two vectors
- Parameters
-
- Returns
- Vec2
◆ operator+=() [2/2]
Vec2 & nc::Vec2::operator+= |
( |
double |
scalar | ) |
|
|
inlinenoexcept |
Adds the scalar to the vector
- Parameters
-
- Returns
- Vec2
◆ operator-=() [1/2]
Vec2 & nc::Vec2::operator-= |
( |
const Vec2 & |
rhs | ) |
|
|
inlinenoexcept |
Subtracts the two vectors
- Parameters
-
- Returns
- Vec2
◆ operator-=() [2/2]
Vec2 & nc::Vec2::operator-= |
( |
double |
scalar | ) |
|
|
inlinenoexcept |
Subtracts the scalar from the vector
- Parameters
-
- Returns
- Vec2
◆ operator/=()
Vec2 & nc::Vec2::operator/= |
( |
double |
scalar | ) |
|
|
inlinenoexcept |
Scalar division
- Parameters
-
- Returns
- Vec2
◆ operator==()
bool nc::Vec2::operator== |
( |
const Vec2 & |
rhs | ) |
const |
|
inlinenoexcept |
Equality operator
- Parameters
-
- Returns
- bool
◆ project()
Vec2 nc::Vec2::project |
( |
const Vec2 & |
otherVec | ) |
const |
|
inlinenoexcept |
Projects the vector onto the input vector
- Parameters
-
- Returns
- Vec2
◆ right()
static constexpr Vec2 nc::Vec2::right |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
Returns the unit vector [1, 0]
- Returns
- Vec2
◆ toNdArray()
NdArray< double > nc::Vec2::toNdArray |
( |
| ) |
const |
|
inline |
◆ toString()
std::string nc::Vec2::toString |
( |
| ) |
const |
|
inline |
Returns the Vec2 as a string
- Returns
- std::string
◆ up()
static constexpr Vec2 nc::Vec2::up |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
Returns the unit vector [0, 1]
- Returns
- Vec2
double nc::Vec2::x { 0. } |
double nc::Vec2::y { 0. } |
The documentation for this class was generated from the following file: