[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 | Vector3 () |
template<typename Int> | |
constexpr | Vector3 (const Vector3i< Int > &vector) |
template<typename Other> | |
constexpr | Vector3 (const Vector3< Other > &vector) |
constexpr | Vector3 (const Vector2< Real > &vector, const Real z) |
constexpr | Vector3 (const Real x, const Real y, const Real z) |
constexpr Vector3 | abs () const |
Vector3 | ceil () const |
Vector3 | floor () const |
Vector3 | round () const |
constexpr Vector3 | clamp (const Vector3 &min, const Vector3 &max) const |
Vector3 | direction (const Vector3 &to) const |
constexpr Vector3 | direction_unnormalized (const Vector3 &to) const |
constexpr Real | distance_sqrd (const Vector3 &to) const |
Real | distance (const Vector3 &to) const |
constexpr Real | manhattan_distance (const Vector3 &to) const |
constexpr Real | length_sqrd () const |
Real | length () const |
Vector3 | clamp_length (const Real min, const Real max) const |
Vector3 | normalize () const |
constexpr Vector3 | lerp (const Vector3 &to, const Real weight) const |
constexpr Vector3 | lerp_clamped (const Vector3 &to, const Real weight) const |
constexpr Real | dot (const Vector3 &other) const |
constexpr Vector3 | cross (const Vector3 &other) const |
constexpr Matrix3< Real > | outer (const Vector3 &other) const |
constexpr Vector3 | reflect (const Vector3 &normal) const |
constexpr Vector3 | project (const Vector3 &onto) const |
constexpr Vector3 | inverse () const |
Real | angle (const Vector3 &to) const |
constexpr bool | parallel (const Vector3 &other) const |
constexpr bool | perpendicular (const Vector3 &other) const |
constexpr Vector3 | arbitrary_perpendicular () const |
constexpr Vector3 | translate (const Vector3 &by) const |
Vector3 | rotate_axis_angle (const Vector3 &axis, Real angle) const |
Vector3 | rotate_axis_angle_at (const Vector3 &origin, const Vector3 &axis, Real angle) const |
constexpr Vector3 | rotate_quaternion (const Quaternion< Real > &quaternion) const |
constexpr Vector3 | rotate_quaternion_at (const Vector3 &origin, const Quaternion< Real > &quaternion) const |
constexpr Vector3 | scale (const Vector3 &factor) const |
constexpr Vector3 | scale_at (const Vector3 &origin, const Vector3 &factor) const |
constexpr Vector3 | shear_x (Real factor_y, Real factor_z) const |
constexpr Vector3 | shear_x_at (const Vector3 &origin, Real factor_y, Real factor_z) const |
constexpr Vector3 | shear_y (Real factor_x, Real factor_z) const |
constexpr Vector3 | shear_y_at (const Vector3 &origin, Real factor_x, Real factor_z) const |
constexpr Vector3 | shear_z (Real factor_x, Real factor_y) const |
constexpr Vector3 | shear_z_at (const Vector3 &origin, Real factor_x, Real factor_y) const |
constexpr Vector3 | transform (const Basis3< Real > &by) const |
constexpr Vector3 | transform_at (const Vector3 &origin, const Basis3< Real > &by) const |
constexpr Vector3 | transform (const Transform2< Real > &by) const |
constexpr Vector3 | transform_at (const Vector2< Real > &origin, const Transform2< Real > &by) const |
constexpr Vector3 | transform (const Transform3< Real > &by, Real w=static_cast< Real >(1)) const |
constexpr Vector3 | transform_at (const Vector3 &origin, const Transform3< Real > &by, Real w=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 Vector3 &other) const |
constexpr bool | approx_zero () const |
constexpr Vector2< Real > | xy () 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 Vector3 &other) const |
constexpr bool | operator!= (const Vector3 &other) const |
constexpr Vector3 | operator+ (const Vector3 &other) const |
constexpr Vector3 & | operator+= (const Vector3 &other) |
constexpr Vector3 | operator- (const Vector3 &other) const |
constexpr Vector3 & | operator-= (const Vector3 &other) |
constexpr Vector3 | operator* (const Vector3 &other) const |
constexpr Vector3 & | operator*= (const Vector3 &other) |
constexpr Vector3 | operator* (const Matrix3< Real > &matrix) const |
constexpr Vector3 | operator* (const Real value) const |
constexpr Vector3 & | operator*= (const Real value) |
constexpr Vector3 | operator/ (const Vector3 &other) const |
constexpr Vector3 & | operator/= (const Vector3 &other) |
constexpr Vector3 | operator/ (const Real value) const |
constexpr Vector3 & | operator/= (const Real value) |
constexpr Vector3 | operator+ () const |
constexpr Vector3 | operator- () const |
constexpr bool | operator< (const Vector3 &other) const |
constexpr | operator bool () const |
Static Public Member Functions | |
static constexpr Vector3 | all (Real value) |
static constexpr Vector3 | zero () |
static constexpr Vector3 | one () |
static constexpr Vector3 | axis_x () |
static constexpr Vector3 | axis_y () |
static constexpr Vector3 | axis_z () |
Public Attributes | |
Real | x |
Real | y |
Real | z |
three-dimensional vector.
Real | Floating-point type. |
|
inlineconstexpr |
Initializes all components to zero.
|
explicitconstexpr |
Casts from three-dimensional integer vector.
Int | Integer type. |
vector | Vector to cast. |
|
inlineexplicitconstexpr |
Casts from other vector.
Other | Other floating-point type. |
vector | Vector to cast. |
|
inlineconstexpr |
Initialize initial components with two-dimensional vector and z with value.
vector | Two-dimensional vector. |
z | Z value |
|
inlineconstexpr |
Initialize with components.
x | X value. |
y | Y value. |
z | Z value. |
|
inlinenodiscardconstexpr |
Component-wise absolute value.
|
inlinenodiscardconstexpr |
Absolute-value maximum component.
|
inlinenodiscardconstexpr |
Index of the absolute-value maximum component.
|
inlinenodiscardconstexpr |
Absolute-value minimum component.
|
inlinenodiscardconstexpr |
Index of the absolute-value minimum component.
|
inlinestaticconstexpr |
Vector with all components with value.
value | Value. |
|
inlinenodiscard |
Angle in radians from this position vector to another position vector.
to | Position to. |
|
inlinenodiscardconstexpr |
If approximately equal to another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
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.
|
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.
|
inlinestaticconstexpr |
Normalized vector that points in the direction of the positive z-axis.
|
inline |
Start iterator.
|
inlinenodiscard |
Start constant iterator.
|
inlinenodiscard |
Component-wise ceiling.
|
inlinenodiscardconstexpr |
Component-wise clamp.
min | Minimum. |
max | Maximum. |
|
inlinenodiscard |
Clamp length.
min | Minimum. |
max | Maximum. |
|
inlinenodiscardconstexpr |
Vector cross product.
other | Other vector. |
|
inlinenodiscard |
The direction from position of this vector to the position of another vector.
to | Position to. |
|
inlinenodiscardconstexpr |
The non-normalized direction from position of this vector to the position of another vector.
to | Position to. |
|
inlinenodiscard |
Distance from the position of this vector to the position of another vector.
to | Position to. |
|
inlinenodiscardconstexpr |
Squared distance from the position of this vector to the position of another vector.
to | Position to. |
|
inlinenodiscardconstexpr |
Vector dot product.
other | Other vector. |
|
inline |
End iterator.
|
inlinenodiscard |
End constant iterator.
|
inlinenodiscard |
Component-wise floor.
|
inlinenodiscardconstexpr |
Inverse vector.
|
inlinenodiscard |
Vector length.
|
inlinenodiscardconstexpr |
Squared vector length.
|
inlinenodiscardconstexpr |
Linear interpolate from this vector to another.
to | Vector to interpolate to. |
weight | Interpolation weight which typically ranges from zero to one. |
|
inlinenodiscardconstexpr |
Linear interpolate from this vector to another which a clamped weight between zero and one.
to | Vector to interpolate to. |
weight | Interpolation weight which is clamped from zero to one. |
|
inlinenodiscardconstexpr |
Distance between the position of this vector to another vector along the grid defined by the x, y, and z axes.
to | Position to. |
|
inlinenodiscardconstexpr |
Maximum component.
|
inlinenodiscardconstexpr |
Index of the maximum component.
|
inlinenodiscardconstexpr |
Minimum component.
|
inlinenodiscardconstexpr |
Index of the minimum component.
|
inlinenodiscard |
Normalize vector length to one.
|
inlinestaticconstexpr |
Vector with all components one.
|
inlineexplicitnodiscardconstexpr |
Evaluates to false if all components are zero, true otherwise.
|
inlinenodiscardconstexpr |
If unequal to another vector.
other | Other vector. |
|
nodiscardconstexpr |
Vector-matrix multiplication.
matrix | 3x3 Matrix. |
|
inlinenodiscardconstexpr |
Component-wise multiplication with value.
value | Value. |
|
inlinenodiscardconstexpr |
Component-wise multiplication.
other | Other vector. |
|
inlineconstexpr |
Component-wise multiplication with value.
value | Value. |
|
inlineconstexpr |
Component-wise multiplication.
other | Other vector. |
|
inlinenodiscardconstexpr |
Unary plus. Does nothing but provides symmetry with unary minus.
|
inlinenodiscardconstexpr |
Component-wise addition.
other | Other vector. |
|
inlineconstexpr |
Component-wise addition.
other | Other vector. |
|
inlinenodiscardconstexpr |
Component-wise negation.
|
inlinenodiscardconstexpr |
Component-wise subtraction.
other | Other vector. |
|
inlineconstexpr |
Component-wise subtraction.
other | Other vector. |
|
inlinenodiscardconstexpr |
Component-wise division with value.
value | Value |
|
inlinenodiscardconstexpr |
Component-wise division.
other | Other vector. |
|
inlineconstexpr |
Component-wise division with value.
value | Value. |
|
inlineconstexpr |
Component-wise division.
other | Other vector. |
|
inlinenodiscardconstexpr |
Lexicographical comparison between components.
other | Other vector. |
|
inlinenodiscardconstexpr |
If all components are equal to another vector.
other | Other vector. |
|
inlineconstexpr |
Reference to component at index.
index | Index. |
|
inlinenodiscardconstexpr |
Constant reference to component at index.
index | Index. |
|
nodiscardconstexpr |
Vector outer product.
other | Other vector. |
|
inlinenodiscardconstexpr |
If this vector is parallel to another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
If this vector is perpendicular to another vector.
other | Other vector. |
|
inlinenodiscardconstexpr |
Project this vector onto another
onto | Vector to project onto. |
|
inlinenodiscardconstexpr |
Reflect this vector based on a normal vector.
normal | Normal vector. |
|
nodiscard |
Rotate via normalized axis and angle in radians about the origin.
axis | Normalized axis. |
angle | Angle in radians. |
|
nodiscard |
Rotate via normalized axis and angle in radians around an origin.
origin | Origin to rotate about. |
axis | Normalized axis. |
angle | Angle in radians. |
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Rotate via quaternion about an origin.
origin | Origin to rotate about. |
quaternion | Quaternion |
|
inlinenodiscard |
Component-wise round.
|
nodiscardconstexpr |
Component-wise scale about the origin.
factor | Scale factor. |
|
nodiscardconstexpr |
Component-wise scale about an origin.
origin | Origin to scale bout. |
factor | Scale factor. |
|
nodiscardconstexpr |
Shear along x-axis about the origin.
factor_y | Y-Axis factor. |
factor_z | Z-Axis factor. |
|
nodiscardconstexpr |
Shear along x-axis about an origin.
origin | Origin to shear about. |
factor_y | Y-Axis factor. |
factor_z | Z-Axis factor. |
|
nodiscardconstexpr |
Shear along y-axis about the origin.
factor_x | X-Axis factor. |
factor_z | Z-Axis factor. |
|
nodiscardconstexpr |
Shear along y-axis about the origin.
origin | Origin to shear about. |
factor_x | X-Axis factor. |
factor_z | Z-Axis factor. |
|
nodiscardconstexpr |
Shear along z-axis about the origin.
factor_x | X-Axis factor. |
factor_y | Y-Axis factor. |
|
nodiscardconstexpr |
Shear along z-axis about an origin.
origin | Origin to shear about. |
factor_x | X-Axis factor. |
factor_y | Y-Axis factor. |
|
nodiscardconstexpr |
Transform by a three-dimensional basis matrix about the origin.
by | Basis to transform by. |
|
nodiscardconstexpr |
Transform by a two-dimensional transformation matrix about the origin.
by | Transformation matrix to transform by. |
|
nodiscardconstexpr |
Transform by a three-dimensional transformation matrix about the origin.
by | Transformation matrix to transform by. |
w | The homogenous coordinate that defaults to one. |
|
nodiscardconstexpr |
Transform by a two-dimensional transformation matrix about an origin.
origin | Origin to transform about. |
by | Transformation matrix to transform by. |
|
nodiscardconstexpr |
Transform by a three-dimensional basis matrix about an origin.
origin | Origin to transform about. |
by | Basis to transform by. |
|
nodiscardconstexpr |
Transform by a three-dimensional transformation matrix about an origin.
origin | Origin to transform about. |
by | Transform matrix to transform by. |
w | The homogenous coordinate that defaults to one. |
|
nodiscardconstexpr |
Translate vector as position.
by | Offset to translate by. |
|
inlinenodiscardconstexpr |
Two-dimensional vector from the first two components of this vector.
|
inlinestaticconstexpr |
Vector with all components zero.
Real nnm::Vector3< Real >::x |
Real nnm::Vector3< Real >::y |
Real nnm::Vector3< Real >::z |