[nnm] No Nonsense Math 0.5.0
A No-Nonsense, C++ 17, single-header-only Math library geared towards graphics programming.
|
#include <nnm.hpp>
Public Member Functions | |
constexpr | Vector2 () |
template<typename Int> | |
constexpr | Vector2 (const Vector2i< Int > &vector) |
template<typename Other> | |
constexpr | Vector2 (const Vector2< Other > &vector) |
constexpr | Vector2 (const Real x, const Real y) |
constexpr Vector2 | abs () const |
Vector2 | ceil () const |
Vector2 | floor () const |
Vector2 | round () const |
constexpr Real | aspect_ratio () const |
constexpr Vector2 | clamp (const Vector2 &min, const Vector2 &max) const |
Vector2 | direction (const Vector2 &to) const |
constexpr Vector2 | direction_unnormalized (const Vector2 &to) const |
constexpr Real | distance_sqrd (const Vector2 &to) const |
Real | distance (const Vector2 &to) const |
constexpr Real | manhattan_distance (const Vector2 &to) const |
constexpr Real | length_sqrd () const |
Real | length () const |
Vector2 | clamp_length (const Real min, const Real max) const |
Vector2 | normalize () const |
constexpr Vector2 | lerp (const Vector2 &to, const Real weight) const |
constexpr Vector2 | lerp_clamped (const Vector2 &to, const Real weight) const |
constexpr Real | dot (const Vector2 &other) const |
constexpr Real | cross (const Vector2 &other) const |
constexpr Matrix2< Real > | outer (const Vector2 &other) const |
constexpr Vector2 | reflect (const Vector2 &normal) const |
constexpr Vector2 | project (const Vector2 &onto) const |
constexpr Vector2 | inverse () const |
Real | angle_between (const Vector2 &other) const |
Real | angle_to (const Vector2 &to) const |
constexpr bool | parallel (const Vector2 &other) const |
constexpr bool | perpendicular (const Vector2 &other) const |
constexpr Vector2 | arbitrary_perpendicular () const |
constexpr Vector2 | translate (const Vector2 &by) const |
Vector2 | rotate (Real angle) const |
Vector2 | rotate_at (const Vector2 &origin, Real angle) const |
constexpr Vector2 | scale (const Vector2 &factor) const |
constexpr Vector2 | scale_at (const Vector2 &origin, const Vector2 &factor) const |
constexpr Vector2 | shear_x (Real factor) const |
constexpr Vector2 | shear_x_at (const Vector2 &origin, Real factor) const |
constexpr Vector2 | shear_y (Real factor) const |
constexpr Vector2 | shear_y_at (const Vector2 &origin, Real factor) const |
constexpr Vector2 | transform (const Basis2< Real > &by) const |
constexpr Vector2 | transform_at (const Vector2 &origin, const Basis2< Real > &by) const |
constexpr Vector2 | transform (const Transform2< Real > &by, Real z=static_cast< Real >(1)) const |
constexpr Vector2 | transform_at (const Vector2 &origin, const Transform2< Real > &by, Real z=static_cast< Real >(1)) const |
constexpr Real | max () const |
constexpr Real | abs_max () const |
constexpr Real | min () const |
constexpr Real | abs_min () const |
constexpr uint8_t | max_index () const |
constexpr uint8_t | abs_max_index () const |
constexpr uint8_t | min_index () const |
constexpr uint8_t | abs_min_index () const |
constexpr bool | approx_equal (const Vector2 &other) const |
constexpr bool | approx_zero () const |
const Real * | begin () const |
const Real * | end () const |
Real * | begin () |
Real * | end () |
constexpr const Real & | at (const uint8_t index) const |
constexpr Real & | at (const uint8_t index) |
constexpr const Real & | operator[] (const uint8_t index) const |
constexpr Real & | operator[] (const uint8_t index) |
constexpr bool | operator== (const Vector2 &other) const |
constexpr bool | operator!= (const Vector2 &other) const |
constexpr Vector2 | operator+ (const Vector2 &other) const |
constexpr Vector2 & | operator+= (const Vector2 &other) |
constexpr Vector2 | operator- (const Vector2 &other) const |
constexpr Vector2 & | operator-= (const Vector2 &other) |
constexpr Vector2 | operator* (const Vector2 &other) const |
constexpr Vector2 & | operator*= (const Vector2 &other) |
constexpr Vector2 | operator* (const Matrix2< Real > &matrix) const |
constexpr Vector2 | operator* (const Real value) const |
constexpr Vector2 & | operator*= (const Real value) |
constexpr Vector2 | operator/ (const Vector2 &other) const |
constexpr Vector2 & | operator/= (const Vector2 &other) |
constexpr Vector2 | operator/ (const Real value) const |
constexpr Vector2 & | operator/= (const Real value) |
constexpr Vector2 | operator+ () const |
constexpr Vector2 | operator- () const |
constexpr bool | operator< (const Vector2 &other) const |
constexpr | operator bool () const |
Static Public Member Functions | |
static constexpr Vector2 | all (const Real value) |
static constexpr Vector2 | zero () |
static constexpr Vector2 | one () |
static constexpr Vector2 | axis_x () |
static constexpr Vector2 | axis_y () |
Public Attributes | |
Real | x |
Real | y |
2-dimensional vector.
Real | Floating-point value. |
|
inlineconstexpr |
Default initializes to all zeros.
|
explicitconstexpr |
Initializes by casting the integer 2D vector variant value.
Int | Integer type. |
vector | Vector to cast from. |
|
inlineexplicitconstexpr |
Initializes by casting a different floating-point type vector.
Other | Other floating-point type. |
vector | Vector to cast from. |
|
inlineconstexpr |
Initializes from two provided values.
x | X value. |
y | Y value. |
|
inlinenodiscardconstexpr |
Absolute value of all components.
|
inlinenodiscardconstexpr |
The absolute-value maximum component.
|
inlinenodiscardconstexpr |
Index of the absolute-value maximum component.
|
inlinenodiscardconstexpr |
The absolute-value minimum component.
|
inlinenodiscardconstexpr |
Index of the absolute-value minimum component.
|
inlinestaticconstexpr |
Vector with all components set to a value.
value | Value. |
|
inlinenodiscard |
Angle in radians between this vector and another vector.
other | Other vector. |
|
inlinenodiscard |
Angle in radians from this position vector to another position vector.
to | Position to. |
|
inlinenodiscardconstexpr |
Determines if this vector is approximately equal to another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Determines if all components are approximately zero.
|
inlinenodiscardconstexpr |
Returns a vector that is perpendicular to this vector. There are multiple possible perpendicular vectors so an arbitrary perpendicular vector is returned and no assumptions should be made on which solution is returned.
|
inlinenodiscardconstexpr |
The ratio between the x and y components.
|
inlineconstexpr |
Reference to component at index.
index | Index. |
|
inlinenodiscardconstexpr |
Constant reference to component at index.
index | Index. |
|
inlinestaticconstexpr |
Normalized vector that points in the direction of the positive x-axis.
|
inlinestaticconstexpr |
Normalized vector that points in the direction of the positive y-axis.
|
inline |
Start of the iterator.
|
inlinenodiscard |
Start of the constant iterator.
|
inlinenodiscard |
Ceiling of all components.
|
inlinenodiscardconstexpr |
Component-wise clamp.
min | Minimum. |
max | Maximum. |
|
inlinenodiscard |
A vector that has the same direction of this vector but whose length is clamped between minimum and maximum values.
min | Minimum length. |
max | Maximum length. |
|
inlinenodiscardconstexpr |
Cross product.
other | Other vector. |
|
inlinenodiscard |
Normalized vector that points in the direction from the position of this vector to another vector.
to | Position to. |
|
inlinenodiscardconstexpr |
Non-normalized Vector that points in the direction from the position of this vector to another vector.
to | Position to. |
|
inlinenodiscard |
Distance from the position of this vector to another vector.
to | Position to. |
|
inlinenodiscardconstexpr |
Squared distance from the position of this vector to another vector.
to | Position to. |
|
inlinenodiscardconstexpr |
Dot product.
other | Other vector. |
|
inline |
End of the iterator.
|
inlinenodiscard |
End of the constant iterator.
|
inlinenodiscard |
Floor of all components.
|
inlinenodiscardconstexpr |
Inverse of the vector.
|
inlinenodiscard |
Length of the vector.
|
inlinenodiscardconstexpr |
Squared length of the vector.
|
inlinenodiscardconstexpr |
Linear interpolate between two this vector and another vector.
to | Vector to interpolate to. |
weight | Weight between the two interpolated vectors. |
|
inlinenodiscardconstexpr |
Linear interpolate between this vector and another vector where the weight is clamped between zero and one.
to | Vector to interpolate to. |
weight | Weight between the two interpolate vectors that is clamped between zero and one. |
|
inlinenodiscardconstexpr |
Distance between the position of this vector to another vector along the grid defined by the x and y axes.
to | Position to. |
|
inlinenodiscardconstexpr |
The maximum component.
|
inlinenodiscardconstexpr |
Index of the maximum component.
|
inlinenodiscardconstexpr |
The minimum component.
|
inlinenodiscardconstexpr |
Index of the minimum component.
|
inlinenodiscard |
Normalize the vector which keeps the direction but with a length of one.
|
inlinestaticconstexpr |
Vector with all components set to one.
|
inlineexplicitnodiscardconstexpr |
Evaluates to false if all components are zero, true otherwise.
|
inlinenodiscardconstexpr |
Determines if this vector does not equal another.
other | Other vector. |
|
nodiscardconstexpr |
Vector-matrix multiplication.
matrix | Matrix. |
|
inlinenodiscardconstexpr |
Vector-scalar multiplication.
value | Value. |
|
inlinenodiscardconstexpr |
Component-wise multiplication.
other | Other vector. |
|
inlineconstexpr |
Multiplies each component by a value.
value | Value. |
|
inlineconstexpr |
Multiplied each component of this vector by another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Unary plus. Does nothing but specified for symmetry with unary minus.
|
inlinenodiscardconstexpr |
Vector addition.
other | Other vector. |
|
inlineconstexpr |
Adds another vector to this vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Component-wise negation.
|
inlinenodiscardconstexpr |
Vector subtraction.
other | Other vector. |
|
inlineconstexpr |
Subtracts another vector from this vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Vector-scalar division.
value | Value. |
|
inlinenodiscardconstexpr |
Component-wise division.
other | Other vector. |
|
inlineconstexpr |
Divides each component by a value.
value | Value. |
|
inlineconstexpr |
Divide each component by another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Lexicographical comparison between components.
other | Other vector. |
|
inlinenodiscardconstexpr |
Determines if this vector equals another.
other | Other vector. |
|
inlineconstexpr |
Reference to component at index.
index | Index. |
|
inlinenodiscardconstexpr |
Constant reference to component at index.
index | Index. |
|
nodiscardconstexpr |
Outer product.
other | Other vector. |
|
inlinenodiscardconstexpr |
Determines if this vector is parallel to another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Determines if this vector is perpendicular to another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Project this vector onto another vector.
onto | Vector to project onto. |
|
inlinenodiscardconstexpr |
Reflect this vector along a normal vector.
normal | Normal to reflect along. |
|
nodiscard |
Rotate about the origin.
angle | Angle in radians. |
|
nodiscard |
Rotate about an origin.
origin | Origin to rotate about. |
angle | Angle in radians. |
|
inlinenodiscard |
Round all components.
|
nodiscardconstexpr |
Component-wise scale about the origin.
factor | Scale factor. |
|
nodiscardconstexpr |
Component-wise scale about an origin.
origin | Origin to scale about. |
factor | Scale factor. |
|
nodiscardconstexpr |
Shear along the x-axis about the origin.
factor | Factor. |
|
nodiscardconstexpr |
Shear along the x-axis about an origin.
origin | Origin to shear about. |
factor | Angle in radians. |
|
nodiscardconstexpr |
Shear along the y-axis about the origin.
factor | Factor. |
|
nodiscardconstexpr |
Shear along the y-axis about an origin.
origin | Origin to shear about. |
factor | Factor. |
|
nodiscardconstexpr |
Transform by a 2D basis about the origin.
by | 2D basis to transform by. |
|
nodiscardconstexpr |
Transform by a 2D transformation matrix about the origin.
by | 2D transformation matrix to transform by. |
z | The homogenous coordinate which defaults to one. |
|
nodiscardconstexpr |
Transform by a 2D basis about an origin.
origin | Origin to transform about. |
by | 2D basis to transform by. |
|
nodiscardconstexpr |
Transform by a 2D transformation matrix about an origin.
origin | Origin to transform about. |
by | 2D transformation matrix to transform by. |
z | The homogenous coordinate which defaults to one. |
|
nodiscardconstexpr |
Translate vector as a position.
by | Offset. |
|
inlinestaticconstexpr |
Vector with all components set to zero.
Real nnm::Vector2< Real >::x |
Real nnm::Vector2< Real >::y |