[nnm] No Nonsense Math 0.5.0
A No-Nonsense, C++ 17, single-header-only Math library geared towards graphics programming.
Loading...
Searching...
No Matches
nnm::Vector3i< Int > Class Template Reference

#include <nnm.hpp>

Classes

struct  Hash

Public Member Functions

constexpr Vector3i ()
template<typename Real>
constexpr Vector3i (const Vector3< Real > &vector)
constexpr Vector3i (const Vector2i< Int > &vector, const Int z)
constexpr Vector3i (const Int x, const Int y, const Int z)
constexpr Vector3i abs () const
constexpr Vector3i clamp (const Vector3i &min, const Vector3i &max) const
constexpr Int manhattan_distance (const Vector3i &to) const
constexpr Int length_sqrd () const
constexpr Int dot (const Vector3i &other) const
constexpr Vector3i cross (const Vector3i &other) const
constexpr bool parallel (const Vector3i &other) const
constexpr bool perpendicular (const Vector3i &other) const
constexpr Vector3i arbitrary_perpendicular () const
constexpr Int max () const
constexpr Int abs_max () const
constexpr Int min () const
constexpr Int 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 Vector2i< Int > xy () const
const Int * begin () const
const Int * end () const
Int * begin ()
Int * end ()
constexpr const Int & at (const uint8_t index) const
constexpr Int & at (const uint8_t index)
constexpr const Int & operator[] (const uint8_t index) const
constexpr Int & operator[] (const uint8_t index)
constexpr bool operator== (const Vector3i &other) const
constexpr bool operator!= (const Vector3i &other) const
constexpr Vector3i operator+ (const Vector3i &other) const
constexpr Vector3ioperator+= (const Vector3i &other)
constexpr Vector3i operator- (const Vector3i &other) const
constexpr Vector3ioperator-= (const Vector3i &other)
constexpr Vector3i operator* (const Vector3i &other) const
constexpr Vector3ioperator*= (const Vector3i &other)
constexpr Vector3i operator* (const Int value) const
constexpr Vector3ioperator*= (const Int value)
constexpr Vector3i operator/ (const Vector3i &other) const
constexpr Vector3ioperator/= (const Vector3i &other)
constexpr Vector3i operator/ (const Int value) const
constexpr Vector3ioperator/= (const Int value)
constexpr Vector3i operator% (const Vector3i &other) const
constexpr Vector3ioperator%= (const Vector3i &other)
constexpr Vector3i operator% (const Int value) const
constexpr Vector3ioperator%= (const Int value)
constexpr Vector3i operator+ () const
constexpr Vector3i operator- () const
constexpr bool operator< (const Vector3i &other) const
constexpr operator bool () const

Static Public Member Functions

static constexpr Vector3i all (const Int value)
static constexpr Vector3i zero ()
static constexpr Vector3i one ()
static constexpr Vector3i axis_x ()
static constexpr Vector3i axis_y ()
static constexpr Vector3i axis_z ()

Public Attributes

Int x
Int y
Int z

Detailed Description

template<typename Int>
class nnm::Vector3i< Int >

Three-dimensional vector with integer components.

Template Parameters
IntInteger type.

Constructor & Destructor Documentation

◆ Vector3i() [1/4]

template<typename Int>
nnm::Vector3i< Int >::Vector3i ( )
inlineconstexpr

Initialize with all zeros.

◆ Vector3i() [2/4]

template<typename Int>
template<typename Real>
nnm::Vector3i< Int >::Vector3i ( const Vector3< Real > & vector)
inlineexplicitconstexpr

Cast from component with floating-point components.

Template Parameters
RealFloating-point type.
Parameters
vectorVector to cast from.

◆ Vector3i() [3/4]

template<typename Int>
nnm::Vector3i< Int >::Vector3i ( const Vector2i< Int > & vector,
const Int z )
inlineconstexpr

Initialize first two components from two-dimensional vector and z value.

Parameters
vectorVector.
zZ value.

◆ Vector3i() [4/4]

template<typename Int>
nnm::Vector3i< Int >::Vector3i ( const Int x,
const Int y,
const Int z )
inlineconstexpr

Initialize with components.

Parameters
xX value.
yY value.
zZ value.

Member Function Documentation

◆ abs()

template<typename Int>
Vector3i nnm::Vector3i< Int >::abs ( ) const
inlinenodiscardconstexpr

Component-wise absolute value.

Returns
Result.

◆ abs_max()

template<typename Int>
Int nnm::Vector3i< Int >::abs_max ( ) const
inlinenodiscardconstexpr

Absolute-value maximum component.

Returns
Result.

◆ abs_max_index()

template<typename Int>
uint8_t nnm::Vector3i< Int >::abs_max_index ( ) const
inlinenodiscardconstexpr

Index of the absolute-value maximum component.

Returns
Result.

◆ abs_min()

template<typename Int>
Int nnm::Vector3i< Int >::abs_min ( ) const
inlinenodiscardconstexpr

Absolute-value minimum component.

Returns
Result.

◆ abs_min_index()

template<typename Int>
uint8_t nnm::Vector3i< Int >::abs_min_index ( ) const
inlinenodiscardconstexpr

Index of the absolute-value minimum component.

Returns
Result.

◆ all()

template<typename Int>
constexpr Vector3i nnm::Vector3i< Int >::all ( const Int value)
inlinestaticconstexpr

Initialize all components with value.

Parameters
valueValue.
Returns
Result.

◆ arbitrary_perpendicular()

template<typename Int>
Vector3i nnm::Vector3i< Int >::arbitrary_perpendicular ( ) const
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.

Returns
Resulting perpendicular vector.

◆ at() [1/2]

template<typename Int>
Int & nnm::Vector3i< Int >::at ( const uint8_t index)
inlineconstexpr

Reference to component at index.

Parameters
indexIndex.
Returns
Reference.

◆ at() [2/2]

template<typename Int>
const Int & nnm::Vector3i< Int >::at ( const uint8_t index) const
inlinenodiscardconstexpr

Constant reference to component at index.

Parameters
indexIndex.
Returns
Constant reference.

◆ axis_x()

template<typename Int>
constexpr Vector3i nnm::Vector3i< Int >::axis_x ( )
inlinestaticconstexpr

Normalized vector that points in the direction of the positive x-axis.

Returns
Result.

◆ axis_y()

template<typename Int>
constexpr Vector3i nnm::Vector3i< Int >::axis_y ( )
inlinestaticconstexpr

Normalized vector that points in the direction of the positive y-axis.

Returns
Result.

◆ axis_z()

template<typename Int>
constexpr Vector3i nnm::Vector3i< Int >::axis_z ( )
inlinestaticconstexpr

Normalized vector that points in the direction of the positive z-axis.

Returns
Result.

◆ begin() [1/2]

template<typename Int>
Int * nnm::Vector3i< Int >::begin ( )
inline

Start iterator.

Returns
Iterator.

◆ begin() [2/2]

template<typename Int>
const Int * nnm::Vector3i< Int >::begin ( ) const
inlinenodiscard

Start constant iterator.

Returns
Constant iterator.

◆ clamp()

template<typename Int>
Vector3i nnm::Vector3i< Int >::clamp ( const Vector3i< Int > & min,
const Vector3i< Int > & max ) const
inlinenodiscardconstexpr

Component-wise clamp.

Parameters
minMinimum.
maxMaximum.
Returns
Result.

◆ cross()

template<typename Int>
Vector3i nnm::Vector3i< Int >::cross ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Vector cross product.

Parameters
otherOther vector.
Returns
Result.

◆ dot()

template<typename Int>
Int nnm::Vector3i< Int >::dot ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Vector dot product.

Parameters
otherOther vector.
Returns
Result.

◆ end() [1/2]

template<typename Int>
Int * nnm::Vector3i< Int >::end ( )
inline

End iterator.

Returns
Iterator.

◆ end() [2/2]

template<typename Int>
const Int * nnm::Vector3i< Int >::end ( ) const
inlinenodiscard

End constant iterator.

Returns
Constant iterator.

◆ length_sqrd()

template<typename Int>
Int nnm::Vector3i< Int >::length_sqrd ( ) const
inlinenodiscardconstexpr

Squared vector length.

Returns
Result.

◆ manhattan_distance()

template<typename Int>
Int nnm::Vector3i< Int >::manhattan_distance ( const Vector3i< Int > & to) const
inlinenodiscardconstexpr

Distance between the position of this vector to another vector along the grid defined by the x, y, and z axes.

Parameters
toPosition to.
Returns
Resulting distance.

◆ max()

template<typename Int>
Int nnm::Vector3i< Int >::max ( ) const
inlinenodiscardconstexpr

Maximum component.

Returns
Result.

◆ max_index()

template<typename Int>
uint8_t nnm::Vector3i< Int >::max_index ( ) const
inlinenodiscardconstexpr

Index of maximum component.

Returns
Result.

◆ min()

template<typename Int>
Int nnm::Vector3i< Int >::min ( ) const
inlinenodiscardconstexpr

Minimum component.

Returns
Result.

◆ min_index()

template<typename Int>
uint8_t nnm::Vector3i< Int >::min_index ( ) const
inlinenodiscardconstexpr

Index of minimum component.

Returns
Result.

◆ one()

template<typename Int>
constexpr Vector3i nnm::Vector3i< Int >::one ( )
inlinestaticconstexpr

Initialize all components with one.

Returns
Result.

◆ operator bool()

template<typename Int>
nnm::Vector3i< Int >::operator bool ( ) const
inlineexplicitnodiscardconstexpr

Evaluates to false if all components are zero, true otherwise.

◆ operator!=()

template<typename Int>
bool nnm::Vector3i< Int >::operator!= ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise inequality.

Parameters
otherOther vector.
Returns
True if unequal, false otherwise.

◆ operator%() [1/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator% ( const Int value) const
inlinenodiscardconstexpr

Component-wise remainder with value.

Parameters
valueValue.
Returns
Result.

◆ operator%() [2/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator% ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise remainder.

Parameters
otherOther vector.
Returns
Result.

◆ operator%=() [1/2]

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator%= ( const Int value)
inlineconstexpr

Component-wise remainder with value.

Parameters
valueValue.
Returns
Result.

◆ operator%=() [2/2]

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator%= ( const Vector3i< Int > & other)
inlineconstexpr

Component-wise remainder.

Parameters
otherOther vector.
Returns
Reference to this modified vector.

◆ operator*() [1/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator* ( const Int value) const
inlinenodiscardconstexpr

Component-wise multiplication with value.

Parameters
valueValue.
Returns
Result.

◆ operator*() [2/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator* ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise multiplication.

Parameters
otherOther vector.
Returns
Result.

◆ operator*=() [1/2]

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator*= ( const Int value)
inlineconstexpr

Component-wise multiplication with value.

Parameters
valueValue.
Returns
Reference to this modified vector.

◆ operator*=() [2/2]

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator*= ( const Vector3i< Int > & other)
inlineconstexpr

Component-wise multiplication.

Parameters
otherOther vector.
Returns
Result.

◆ operator+() [1/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator+ ( ) const
inlinenodiscardconstexpr

Unary plus. Does nothing but provide symmetry with unary minus.

Returns
Result.

◆ operator+() [2/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator+ ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise addition.

Parameters
otherOther vector.
Returns
Result.

◆ operator+=()

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator+= ( const Vector3i< Int > & other)
inlineconstexpr

Component-wise addition.

Parameters
otherOther vector.
Returns
Reference to this modified vector.

◆ operator-() [1/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator- ( ) const
inlinenodiscardconstexpr

Component-wise negation.

Returns
Result.

◆ operator-() [2/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator- ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise subtraction.

Parameters
otherOther vector.
Returns
Result.

◆ operator-=()

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator-= ( const Vector3i< Int > & other)
inlineconstexpr

Component-wise subtraction.

Parameters
otherOther vector.
Returns
Reference to this modified vector.

◆ operator/() [1/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator/ ( const Int value) const
inlinenodiscardconstexpr

Component-wise division with value.

Parameters
valueValue.
Returns
Result.

◆ operator/() [2/2]

template<typename Int>
Vector3i nnm::Vector3i< Int >::operator/ ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise division.

Parameters
otherOther vector.
Returns
Result.

◆ operator/=() [1/2]

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator/= ( const Int value)
inlineconstexpr

Component-wise division with value.

Parameters
valueValue.
Returns
Result.

◆ operator/=() [2/2]

template<typename Int>
Vector3i & nnm::Vector3i< Int >::operator/= ( const Vector3i< Int > & other)
inlineconstexpr

Component-wise subtraction.

Parameters
otherOther vector.
Returns
Reference to this modified vector.

◆ operator<()

template<typename Int>
bool nnm::Vector3i< Int >::operator< ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Lexicographical comparison between components.

Parameters
otherOther vector.
Returns
True if less than, false otherwise.

◆ operator==()

template<typename Int>
bool nnm::Vector3i< Int >::operator== ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

Component-wise equality.

Parameters
otherOther vector.
Returns
True if equal, false otherwise.

◆ operator[]() [1/2]

template<typename Int>
Int & nnm::Vector3i< Int >::operator[] ( const uint8_t index)
inlineconstexpr

Reference to component at index.

Parameters
indexIndex.
Returns
Reference.

◆ operator[]() [2/2]

template<typename Int>
const Int & nnm::Vector3i< Int >::operator[] ( const uint8_t index) const
inlinenodiscardconstexpr

Constant reference to component at index.

Parameters
indexIndex.
Returns
Constant reference.

◆ parallel()

template<typename Int>
bool nnm::Vector3i< Int >::parallel ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

If parallel to another vector.

Parameters
otherOther vector.
Returns
True if parallel, false otherwise.

◆ perpendicular()

template<typename Int>
bool nnm::Vector3i< Int >::perpendicular ( const Vector3i< Int > & other) const
inlinenodiscardconstexpr

If perpendicular to another vector.

Parameters
otherOther vector.
Returns
True if perpendicular, false otherwise.

◆ xy()

template<typename Int>
Vector2i< Int > nnm::Vector3i< Int >::xy ( ) const
inlinenodiscardconstexpr

Two-dimensional vector from the first two components of this vector.

Returns
Result.

◆ zero()

template<typename Int>
constexpr Vector3i nnm::Vector3i< Int >::zero ( )
inlinestaticconstexpr

Initialize all components with zero.

Returns
Result.

Member Data Documentation

◆ x

template<typename Int>
Int nnm::Vector3i< Int >::x

◆ y

template<typename Int>
Int nnm::Vector3i< Int >::y

◆ z

template<typename Int>
Int nnm::Vector3i< Int >::z

The documentation for this class was generated from the following file: