SA_Maths
Sapphire Suite's C++ Maths Library
|
Vector 3 Sapphire-Maths class. More...
#include <Vector3.hpp>
Public Types | |
using | Type = T |
Type of the Vector. | |
Public Member Functions | |
Vec3 ()=default | |
Default constructor. | |
constexpr | Vec3 (T _x, T _y, T _z) noexcept |
Value constructor. | |
constexpr | Vec3 (T _scale) noexcept |
Scale Value constructor. | |
Vec3 (Vec3 &&)=default | |
Default move constructor. | |
Vec3 (const Vec3 &)=default | |
Default copy constructor. | |
template<typename TIn > | |
constexpr | Vec3 (const Vec3< TIn > &_other) noexcept |
Value constructor from another Vec3 type. | |
template<typename TIn > | |
constexpr | Vec3 (const Vec2< TIn > &_other, T _z=T(0)) noexcept |
Value constructor from Vec2. | |
template<typename TIn > | |
constexpr | Vec3 (const Vec4< TIn > &_other) noexcept |
Value constructor from Vec4. | |
constexpr bool | IsZero () const noexcept |
Whether this vector is a zero vector. | |
constexpr bool | Equals (const Vec3 &_other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept |
Compare 2 vector. | |
constexpr bool | operator== (const Vec3 &_rhs) const noexcept |
Compare 2 vector equality. | |
constexpr bool | operator!= (const Vec3 &_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, z using 0, 1, 2. | |
const T & | operator[] (uint32_t _index) const |
Const Access operator by index: x, y, z using 0, 1, 2. | |
constexpr T | Length () const |
Getter of the length of this vector. | |
constexpr T | SqrLength () const noexcept |
Getter of the Squared Length of this vector. | |
Vec3 & | Normalize () |
Normalize this vector. | |
Vec3 | GetNormalized () const |
Normalize this vector. | |
constexpr bool | IsNormalized () const noexcept |
Whether this vector is normalized. | |
Vec3 | Reflect (const Vec3 &_normal, float _elasticity=1.0f) const noexcept |
Reflect this vector over the normal. | |
Vec3 | ProjectOnTo (const Vec3 &_other) const noexcept |
Project this vector onto an other vector. | |
Vec3 | ProjectOnToNormal (const Vec3 &_normal) const noexcept |
Project this vector onto s normal. | |
Vec3 & | operator= (Vec3 &&)=default |
Default assignment move operator. | |
Vec3 & | operator= (const Vec3 &)=default |
Default assignment copy operator. | |
constexpr Vec3 | operator- () const noexcept |
Getter of the opposite signed vector. | |
Vec3 | operator* (T _scale) const noexcept |
Scale each vector axis by _scale. | |
Vec3 | operator/ (T _scale) const |
Inverse Scale each vector axis by _scale. | |
constexpr Vec3 | operator+ (const Vec3 &_rhs) const noexcept |
Add term by term vector values. | |
constexpr Vec3 | operator- (const Vec3 &_rhs) const noexcept |
Subtract term by term vector values. | |
constexpr Vec3 | operator* (const Vec3 &_rhs) const noexcept |
Multiply term by term vector values. | |
Vec3 | operator/ (const Vec3 &_rhs) const |
Divide term by term vector values. | |
constexpr T | operator| (const Vec3 &_rhs) const noexcept |
Compute the Dot product between this and _rhs. | |
constexpr Vec3 | operator^ (const Vec3 &_rhs) const noexcept |
Compute the Cross product between this and _rhs. | |
Vec3 & | operator*= (T _scale) noexcept |
Scale each vector axis by _scale. | |
Vec3 & | operator/= (T _scale) |
Inverse Scale each vector axis by _scale. | |
Vec3 & | operator+= (const Vec3 &_rhs) noexcept |
Add term by term vector values. | |
Vec3 & | operator-= (const Vec3 &_rhs) noexcept |
Substract term by term vector values. | |
Vec3 | operator*= (const Vec3 &_rhs) noexcept |
Multiply term by term vector values. | |
Vec3 | operator/= (const Vec3 &_rhs) |
Divide term by term vector values. | |
Static Public Member Functions | |
static constexpr T | Dot (const Vec3 &_lhs, const Vec3 &_rhs) noexcept |
Compute the Dot product between _lhs and _rhs. | |
static constexpr Vec3< T > | Cross (const Vec3 &_lhs, const Vec3 &_rhs) noexcept |
Compute the Cross product between _lhs and _rhs. | |
static Deg< T > | Angle (const Vec3 &_start, const Vec3 &_end, const Vec3 &_normal=Vec3::Up) noexcept |
Compute the Signed Angle between _lhs and _rhs. | |
static Deg< T > | AngleUnsigned (const Vec3 &_start, const Vec3 &_end) noexcept |
Compute the Unsigned Angle between _lhs and _rhs. | |
static constexpr T | Dist (const Vec3 &_start, const Vec3 &_end) |
Compute the Distance between _lhs and _rhs. | |
static constexpr T | SqrDist (const Vec3 &_start, const Vec3 &_end) noexcept |
Compute the Squared Distance between _lhs and _rhs. | |
static constexpr Vec3 | Dir (const Vec3 &_start, const Vec3 &_end) noexcept |
Compute the Non-Normalized Direction from _lhs and _rhs. | |
static constexpr Vec3 | DirN (const Vec3 &_start, const Vec3 &_end) |
Compute the Normalized Direction from _start to _end. | |
static Vec3 | Lerp (const Vec3 &_start, const Vec3 &_end, float _alpha) noexcept |
Clamped Lerp from _start to _end at _alpha. | |
static Vec3 | LerpUnclamped (const Vec3 &_start, const Vec3 &_end, float _alpha) noexcept |
Unclamped Lerp from _start to _end at _alpha. | |
static Vec3 | SLerp (const Vec3 &_start, const Vec3 &_end, float _alpha) noexcept |
Clamped SLerp from _start to _end at _alpha. | |
static Vec3 | SLerpUnclamped (const Vec3 &_start, const Vec3 &_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). | |
T | z = T() |
Vector's Z component (axis value). | |
Static Public Attributes | |
static const Vec3 | Zero |
Zero vector constant {0, 0, 0}. | |
static const Vec3 | One |
One vector constant {1, 1, 1}. | |
static const Vec3 | Right |
Right vector constant {1, 0, 0}. | |
static const Vec3 | Left |
Left vector constant {-1, 0, 0}. | |
static const Vec3 | Up |
Up vector constant {0, 1, 0}. | |
static const Vec3 | Down |
Down vector constant {0, -1, 0}. | |
static const Vec3 | Forward |
Down vector constant {0, 0, 1}. | |
static const Vec3 | Backward |
Down vector constant {0, 0, -1}. | |
Vector 3 Sapphire-Maths class.
T | Type of the vector. |
|
constexprnoexcept |
Value constructor.
[in] | _x | X axis value. |
[in] | _y | Y axis value. |
[in] | _z | Z axis value. |
|
constexprnoexcept |
Scale Value constructor.
[in] | _scale | Axis value to apply on all axis. |
|
staticnoexcept |
Compute the Signed Angle between _lhs and _rhs.
[in] | _start | Left hand side operand to compute angle with. |
[in] | _end | Right hand side operand to compute angle with. |
[in] | _normal | Normal of the plan between _lhs and _rhs, used to determine angle's sign. |
|
staticnoexcept |
Compute the Unsigned Angle between _lhs and _rhs.
[in] | _start | Left hand side operand to compute angle with. |
[in] | _end | Right hand side operand to compute angle with. |
|
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 _lhs and _rhs.
Direction get not normalized. Use DirN instead.
[in] | _start | Left hand side operand to compute direction from. |
[in] | _end | Right hand side operand 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 _lhs and _rhs.
[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 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::Vec3< T >::operator[] | ( | uint32_t | _index | ) |
Access operator by index: x, y, z using 0, 1, 2.
[in] | _index | Index to access. |
const T & SA::Vec3< T >::operator[] | ( | uint32_t | _index | ) | const |
Const Access operator by index: x, y, z using 0, 1, 2.
[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. |
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 GetProjectOnTo() 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 _lhs and _rhs.
[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.