SA_Maths
Sapphire Suite's C++ Maths Library
|
Vector 2 Sapphire's class. More...
#include <Vector2.hpp>
Public Types | |
using | Type = T |
Scalar type of the Vector. | |
Public Member Functions | |
Vec2 ()=default | |
Default constructor. | |
constexpr | Vec2 (T _x, T _y) noexcept |
Value constructor. | |
constexpr | Vec2 (T _scale) noexcept |
Scale Value constructor. | |
Vec2 (Vec2 &&)=default | |
Default move constructor. | |
Vec2 (const Vec2 &)=default | |
Default copy constructor. | |
template<typename TIn > | |
constexpr | Vec2 (const Vec2< TIn > &_other) noexcept |
Value constructor from another Vec2 type. | |
template<typename TIn > | |
constexpr | Vec2 (const Vec3< TIn > &_other) noexcept |
Value constructor from Vec3. | |
constexpr bool | IsZero () const noexcept |
Whether this vector is a zero vector. | |
constexpr bool | Equals (const Vec2 &_other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept |
Compare 2 vector. | |
constexpr bool | operator== (const Vec2 &_rhs) const noexcept |
Compare 2 vector equality. | |
constexpr bool | operator!= (const Vec2 &_rhs) const noexcept |
Compare 2 vector inequality. | |
T * | Data () noexcept |
Getter of vector data | |
const T * | Data () const noexcept |
Const Getter of vector data | |
T & | operator[] (uint32_t _index) |
Access operator by index: x, y using 0, 1. | |
const T & | operator[] (uint32_t _index) const |
Const Access operator by index: x, y using 0, 1. | |
constexpr T | Length () const |
Getter of the /b length of this vector. | |
constexpr T | SqrLength () const noexcept |
Getter of the Squared Length of this vector. | |
Vec2 & | Normalize () |
Normalize this vector. | |
Vec2 | GetNormalized () const |
Normalize this vector. | |
constexpr bool | IsNormalized () const noexcept |
Whether this vector is normalized. | |
Vec2 | Reflect (const Vec2 &_normal, float _elasticity=1.0f) const noexcept |
Reflect this vector over the normal. | |
Vec2 | ProjectOnTo (const Vec2 &_other) const noexcept |
Project this vector onto an other vector. | |
Vec2 | ProjectOnToNormal (const Vec2 &_normal) const noexcept |
Project this vector onto s normal. | |
Vec2 | Perpendicular () const noexcept |
Compute the perpendicular vector to this vector. | |
Vec2 & | operator= (Vec2 &&)=default |
Default assignment move operator. | |
Vec2 & | operator= (const Vec2 &)=default |
Default assignment copy operator. | |
constexpr Vec2 | operator- () const noexcept |
Getter of the opposite signed vector. | |
constexpr Vec2 | operator* (T _scale) const noexcept |
Scale each vector axis by _scale. | |
Vec2 | operator/ (T _scale) const |
Inverse Scale each vector axis by _scale. | |
constexpr Vec2 | operator+ (const Vec2 &_rhs) const noexcept |
Add term by term vector values. | |
constexpr Vec2 | operator- (const Vec2 &_rhs) const noexcept |
Subtract term by term vector values. | |
constexpr Vec2 | operator* (const Vec2 &_rhs) const noexcept |
Multiply term by term vector values. | |
Vec2 | operator/ (const Vec2 &_rhs) const |
Divide term by term vector values. | |
constexpr T | operator| (const Vec2 &_rhs) const noexcept |
Compute the Dot product between this and _rhs. | |
constexpr T | operator^ (const Vec2 &_rhs) const noexcept |
Compute the Cross product between this and _rhs. | |
Vec2 & | operator*= (T _scale) noexcept |
Scale each vector axis by _scale. | |
Vec2 & | operator/= (T _scale) |
Inverse Scale each vector axis by _scale. | |
Vec2 & | operator+= (const Vec2 &_rhs) noexcept |
Add term by term vector values. | |
Vec2 & | operator-= (const Vec2 &_rhs) noexcept |
Substract term by term vector values. | |
Vec2 | operator*= (const Vec2 &_rhs) noexcept |
Multiply term by term vector values. | |
Vec2 | operator/= (const Vec2 &_rhs) |
Divide term by term vector values. | |
Static Public Member Functions | |
static constexpr T | Dot (const Vec2 &_lhs, const Vec2 &_rhs) noexcept |
Compute the Dot product between _lhs and _rhs. | |
static constexpr T | Cross (const Vec2 &_lhs, const Vec2 &_rhs) noexcept |
Compute the Cross product between _lhs and _rhs. | |
static Deg< T > | Angle (const Vec2 &_start, const Vec2 &_end) noexcept |
Compute the Signed Angle between _start and _end. | |
static Deg< T > | AngleUnsigned (const Vec2 &_start, const Vec2 &_end) noexcept |
Compute the Unsigned Angle between _start and _end. | |
static constexpr T | Dist (const Vec2 &_start, const Vec2 &_end) |
Compute the Distance between _start and _end. | |
static constexpr T | SqrDist (const Vec2 &_start, const Vec2 &_end) noexcept |
Compute the Squared Distance between _start and _end. | |
static constexpr Vec2 | Dir (const Vec2 &_start, const Vec2 &_end) noexcept |
Compute the Non-Normalized Direction from _start to _end. | |
static constexpr Vec2 | DirN (const Vec2 &_start, const Vec2 &_end) |
Compute the Normalized Direction from _start to _end. | |
static Vec2 | Lerp (const Vec2 &_start, const Vec2 &_end, float _alpha) noexcept |
Clamped Lerp from _start to _end at _alpha. | |
static Vec2 | LerpUnclamped (const Vec2 &_start, const Vec2 &_end, float _alpha) noexcept |
Unclamped Lerp from _start to _end at _alpha. | |
static Vec2 | SLerp (const Vec2 &_start, const Vec2 &_end, float _alpha) noexcept |
Clamped SLerp from _start to _end at _alpha. | |
static Vec2 | SLerpUnclamped (const Vec2 &_start, const Vec2 &_end, float _alpha) noexcept |
Unclamped SLerp from _start to _end at _alpha. | |
Public Attributes | |
T | x = T() |
Vector's X component (axis value). | |
T | y = T() |
Vector's Y component (axis value). | |
Static Public Attributes | |
static const Vec2 | Zero |
Zero vector constant { 0, 0 }. | |
static const Vec2 | One |
One vector constant { 1, 1 }. | |
static const Vec2 | Right |
Right vector constant { 1, 0 }. | |
static const Vec2 | Left |
Left vector constant { -1, 0 }. | |
static const Vec2 | Up |
Up vector constant { 0, 1 }. | |
static const Vec2 | Down |
Down vector constant { 0, -1 }. | |
Vector 2 Sapphire's class.
T | Type of the vector. |
|
constexprnoexcept |
Value constructor.
[in] | _x | X axis value. |
[in] | _y | Y axis value. |
|
constexprnoexcept |
Scale Value constructor.
[in] | _scale | Axis value to apply on all axis. |
|
staticnoexcept |
Compute the Signed Angle between _start and _end.
[in] | _start | Starting point to compute angle from. |
[in] | _end | Ending point to compute angle to. |
|
staticnoexcept |
Compute the Unsigned Angle between _start and _end.
[in] | _start | Starting point to compute angle from. |
[in] | _end | Ending point to compute angle to. |
|
staticconstexprnoexcept |
Compute the Cross product between _lhs and _rhs.
[in] | _lhs | Left hand side operand to compute cross product with. |
[in] | _rhs | Right hand side operand to compute cross product with. |
|
noexcept |
Const Getter of vector data
|
noexcept |
Getter of vector data
|
staticconstexprnoexcept |
Compute the Non-Normalized Direction from _start to _end.
Direction get not normalized. Use DirN instead.
[in] | _start | Starting point to compute direction from. |
[in] | _end | ending point to compute direction to. |
|
staticconstexpr |
Compute the Normalized Direction from _start to _end.
[in] | _start | Starting point to compute direction from. |
[in] | _end | ending point to compute direction to. |
|
staticconstexpr |
Compute the Distance between _start and _end.
[in] | _start | Left hand side operand to compute distance with. |
[in] | _end | Right hand side operand to compute distance with. |
|
staticconstexprnoexcept |
Compute the Dot product between _lhs and _rhs.
[in] | _lhs | Left hand side operand to compute dot product with. |
[in] | _rhs | Right hand side operand to compute dot product with. |
|
constexprnoexcept |
Compare 2 vector.
[in] | _other | Other vector to compare to. |
[in] | _epsilon | Epsilon value for threshold comparison. |
Normalize this vector.
|
constexprnoexcept |
Whether this vector is normalized.
|
constexprnoexcept |
Whether this vector is a zero vector.
|
constexpr |
Getter of the /b length of this vector.
|
staticnoexcept |
Clamped Lerp from _start to _end at _alpha.
Reference: https://en.wikipedia.org/wiki/Linear_interpolation
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
|
staticnoexcept |
Unclamped Lerp from _start to _end at _alpha.
Reference: https://en.wikipedia.org/wiki/Linear_interpolation
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
Normalize this vector.
|
constexprnoexcept |
Compare 2 vector inequality.
[in] | _rhs | Other vector to compare to. |
|
constexprnoexcept |
Multiply term by term vector values.
[in] | _rhs | Vector to multiply. |
Scale each vector axis by _scale.
[in] | _scale | Scale value to apply on all axis. |
Multiply term by term vector values.
[in] | _rhs | Vector to multiply. |
Scale each vector axis by _scale.
[in] | _scale | Scale value to apply on all axis. |
|
constexprnoexcept |
Add term by term vector values.
[in] | _rhs | Vector to add. |
Add term by term vector values.
[in] | _rhs | Vector to add. |
Getter of the opposite signed vector.
|
constexprnoexcept |
Subtract term by term vector values.
[in] | _rhs | Vector to substract. |
Substract term by term vector values.
[in] | _rhs | Vector to substract. |
Divide term by term vector values.
[in] | _rhs | Vector to divide. |
Inverse Scale each vector axis by _scale.
[in] | _scale | Inverse scale value to apply on all axis. |
Divide term by term vector values.
[in] | _rhs | Vector to divide. |
Inverse Scale each vector axis by _scale.
[in] | _scale | Scale value to apply on all axis. |
Default assignment copy operator.
Default assignment move operator.
|
constexprnoexcept |
Compare 2 vector equality.
[in] | _rhs | Other vector to compare to. |
T & SA::Vec2< T >::operator[] | ( | uint32_t | _index | ) |
Access operator by index: x, y using 0, 1.
[in] | _index | Index to access. |
const T & SA::Vec2< T >::operator[] | ( | uint32_t | _index | ) | const |
Const Access operator by index: x, y using 0, 1.
[in] | _index | Index to access. |
|
constexprnoexcept |
Compute the Cross product between this and _rhs.
[in] | _rhs | Right hand side operand vector to compute cross product with. |
|
constexprnoexcept |
Compute the Dot product between this and _rhs.
[in] | _rhs | Right hand side operand vector to compute dot product with. |
Compute the perpendicular vector to this vector.
Rotate this vector 90 degrees in trigonomety direction (counter-clockwise).
Project this vector onto an other vector.
Reference: https://en.wikipedia.org/wiki/Vector_projection
[in] | _other | Vector used for projection. |
|
noexcept |
Project this vector onto s normal.
Assume _normal is normalized. Use ProjectOnTo() for non normalized vector. Reference: https://en.wikipedia.org/wiki/Vector_projection
[in] | _normal | Normal used for projection. |
|
noexcept |
Reflect this vector over the normal.
[in] | _normal | Normal used for reflection. |
[in] | _elasticity | Elasticity reflection coefficient (use 1.0f for full reflection). |
|
staticnoexcept |
Clamped SLerp from _start to _end at _alpha.
Reference: https://en.wikipedia.org/wiki/Slerp
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
|
staticnoexcept |
Unclamped SLerp from _start to _end at _alpha.
Reference: https://en.wikipedia.org/wiki/Slerp
_start | Starting point of the lerp. |
_end | Ending point of the lerp. |
_alpha | Alpha of the lerp. |
|
staticconstexprnoexcept |
Compute the Squared Distance between _start and _end.
[in] | _start | Left hand side operand to compute squared distance with. |
[in] | _end | Right hand side operand to compute squared distance with. |
|
constexprnoexcept |
Getter of the Squared Length of this vector.