[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::Vector2< Real > Class Template Reference

#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 Vector2operator+= (const Vector2 &other)
constexpr Vector2 operator- (const Vector2 &other) const
constexpr Vector2operator-= (const Vector2 &other)
constexpr Vector2 operator* (const Vector2 &other) const
constexpr Vector2operator*= (const Vector2 &other)
constexpr Vector2 operator* (const Matrix2< Real > &matrix) const
constexpr Vector2 operator* (const Real value) const
constexpr Vector2operator*= (const Real value)
constexpr Vector2 operator/ (const Vector2 &other) const
constexpr Vector2operator/= (const Vector2 &other)
constexpr Vector2 operator/ (const Real value) const
constexpr Vector2operator/= (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

Detailed Description

template<typename Real>
class nnm::Vector2< Real >

2-dimensional vector.

Template Parameters
RealFloating-point value.

Constructor & Destructor Documentation

◆ Vector2() [1/4]

template<typename Real>
nnm::Vector2< Real >::Vector2 ( )
inlineconstexpr

Default initializes to all zeros.

◆ Vector2() [2/4]

template<typename Real>
template<typename Int>
nnm::Vector2< Real >::Vector2 ( const Vector2i< Int > & vector)
explicitconstexpr

Initializes by casting the integer 2D vector variant value.

Template Parameters
IntInteger type.
Parameters
vectorVector to cast from.

◆ Vector2() [3/4]

template<typename Real>
template<typename Other>
nnm::Vector2< Real >::Vector2 ( const Vector2< Other > & vector)
inlineexplicitconstexpr

Initializes by casting a different floating-point type vector.

Template Parameters
OtherOther floating-point type.
Parameters
vectorVector to cast from.

◆ Vector2() [4/4]

template<typename Real>
nnm::Vector2< Real >::Vector2 ( const Real x,
const Real y )
inlineconstexpr

Initializes from two provided values.

Parameters
xX value.
yY value.

Member Function Documentation

◆ abs()

template<typename Real>
Vector2 nnm::Vector2< Real >::abs ( ) const
inlinenodiscardconstexpr

Absolute value of all components.

Returns
Resulting vector.

◆ abs_max()

template<typename Real>
Real nnm::Vector2< Real >::abs_max ( ) const
inlinenodiscardconstexpr

The absolute-value maximum component.

Returns
Result.

◆ abs_max_index()

template<typename Real>
uint8_t nnm::Vector2< Real >::abs_max_index ( ) const
inlinenodiscardconstexpr

Index of the absolute-value maximum component.

Returns
Resulting index.

◆ abs_min()

template<typename Real>
Real nnm::Vector2< Real >::abs_min ( ) const
inlinenodiscardconstexpr

The absolute-value minimum component.

Returns
Result.

◆ abs_min_index()

template<typename Real>
uint8_t nnm::Vector2< Real >::abs_min_index ( ) const
inlinenodiscardconstexpr

Index of the absolute-value minimum component.

Returns
Resulting index.

◆ all()

template<typename Real>
constexpr Vector2 nnm::Vector2< Real >::all ( const Real value)
inlinestaticconstexpr

Vector with all components set to a value.

Parameters
valueValue.
Returns
Resulting vector.

◆ angle_between()

template<typename Real>
Real nnm::Vector2< Real >::angle_between ( const Vector2< Real > & other) const
inlinenodiscard

Angle in radians between this vector and another vector.

Parameters
otherOther vector.
Returns
Resulting angle in radians.

◆ angle_to()

template<typename Real>
Real nnm::Vector2< Real >::angle_to ( const Vector2< Real > & to) const
inlinenodiscard

Angle in radians from this position vector to another position vector.

Parameters
toPosition to.
Returns
Resulting angle in radians.

◆ approx_equal()

template<typename Real>
bool nnm::Vector2< Real >::approx_equal ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Determines if this vector is approximately equal to another vector.

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

◆ approx_zero()

template<typename Real>
bool nnm::Vector2< Real >::approx_zero ( ) const
inlinenodiscardconstexpr

Determines if all components are approximately zero.

Returns
True if approximately zero, false otherwise.

◆ arbitrary_perpendicular()

template<typename Real>
Vector2 nnm::Vector2< Real >::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.

◆ aspect_ratio()

template<typename Real>
Real nnm::Vector2< Real >::aspect_ratio ( ) const
inlinenodiscardconstexpr

The ratio between the x and y components.

Returns
Resulting ratio.

◆ at() [1/2]

template<typename Real>
Real & nnm::Vector2< Real >::at ( const uint8_t index)
inlineconstexpr

Reference to component at index.

Parameters
indexIndex.
Returns
Reference.

◆ at() [2/2]

template<typename Real>
const Real & nnm::Vector2< Real >::at ( const uint8_t index) const
inlinenodiscardconstexpr

Constant reference to component at index.

Parameters
indexIndex.
Returns
Constant reference.

◆ axis_x()

template<typename Real>
constexpr Vector2 nnm::Vector2< Real >::axis_x ( )
inlinestaticconstexpr

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

Returns
Resulting vector.

◆ axis_y()

template<typename Real>
constexpr Vector2 nnm::Vector2< Real >::axis_y ( )
inlinestaticconstexpr

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

Returns
Resulting vector.

◆ begin() [1/2]

template<typename Real>
Real * nnm::Vector2< Real >::begin ( )
inline

Start of the iterator.

Returns
Iterator.

◆ begin() [2/2]

template<typename Real>
const Real * nnm::Vector2< Real >::begin ( ) const
inlinenodiscard

Start of the constant iterator.

Returns
Constant iterator.

◆ ceil()

template<typename Real>
Vector2 nnm::Vector2< Real >::ceil ( ) const
inlinenodiscard

Ceiling of all components.

Returns
Resulting vector.

◆ clamp()

template<typename Real>
Vector2 nnm::Vector2< Real >::clamp ( const Vector2< Real > & min,
const Vector2< Real > & max ) const
inlinenodiscardconstexpr

Component-wise clamp.

Parameters
minMinimum.
maxMaximum.
Returns
Result.

◆ clamp_length()

template<typename Real>
Vector2 nnm::Vector2< Real >::clamp_length ( const Real min,
const Real max ) const
inlinenodiscard

A vector that has the same direction of this vector but whose length is clamped between minimum and maximum values.

Parameters
minMinimum length.
maxMaximum length.
Returns
Resulting length-clamped vector.

◆ cross()

template<typename Real>
Real nnm::Vector2< Real >::cross ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Cross product.

Parameters
otherOther vector.
Returns
Result.

◆ direction()

template<typename Real>
Vector2 nnm::Vector2< Real >::direction ( const Vector2< Real > & to) const
inlinenodiscard

Normalized vector that points in the direction from the position of this vector to another vector.

Parameters
toPosition to.
Returns
Resulting normalized direction vector.

◆ direction_unnormalized()

template<typename Real>
Vector2 nnm::Vector2< Real >::direction_unnormalized ( const Vector2< Real > & to) const
inlinenodiscardconstexpr

Non-normalized Vector that points in the direction from the position of this vector to another vector.

Parameters
toPosition to.
Returns
Resulting non-normalized direction vector.

◆ distance()

template<typename Real>
Real nnm::Vector2< Real >::distance ( const Vector2< Real > & to) const
inlinenodiscard

Distance from the position of this vector to another vector.

Parameters
toPosition to.
Returns
Resulting distance.

◆ distance_sqrd()

template<typename Real>
Real nnm::Vector2< Real >::distance_sqrd ( const Vector2< Real > & to) const
inlinenodiscardconstexpr

Squared distance from the position of this vector to another vector.

Parameters
toPosition to.
Returns
Resulting squared distance.

◆ dot()

template<typename Real>
Real nnm::Vector2< Real >::dot ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Dot product.

Parameters
otherOther vector.
Returns
Result.

◆ end() [1/2]

template<typename Real>
Real * nnm::Vector2< Real >::end ( )
inline

End of the iterator.

Returns
Iterator.

◆ end() [2/2]

template<typename Real>
const Real * nnm::Vector2< Real >::end ( ) const
inlinenodiscard

End of the constant iterator.

Returns
Constant iterator.

◆ floor()

template<typename Real>
Vector2 nnm::Vector2< Real >::floor ( ) const
inlinenodiscard

Floor of all components.

Returns
Resulting vector.

◆ inverse()

template<typename Real>
Vector2 nnm::Vector2< Real >::inverse ( ) const
inlinenodiscardconstexpr

Inverse of the vector.

Returns
Resulting inverse vector.

◆ length()

template<typename Real>
Real nnm::Vector2< Real >::length ( ) const
inlinenodiscard

Length of the vector.

Returns
Resulting length.

◆ length_sqrd()

template<typename Real>
Real nnm::Vector2< Real >::length_sqrd ( ) const
inlinenodiscardconstexpr

Squared length of the vector.

Returns
Resulting squared length.

◆ lerp()

template<typename Real>
Vector2 nnm::Vector2< Real >::lerp ( const Vector2< Real > & to,
const Real weight ) const
inlinenodiscardconstexpr

Linear interpolate between two this vector and another vector.

Parameters
toVector to interpolate to.
weightWeight between the two interpolated vectors.
Returns
Resulting interpolated vector.

◆ lerp_clamped()

template<typename Real>
Vector2 nnm::Vector2< Real >::lerp_clamped ( const Vector2< Real > & to,
const Real weight ) const
inlinenodiscardconstexpr

Linear interpolate between this vector and another vector where the weight is clamped between zero and one.

Parameters
toVector to interpolate to.
weightWeight between the two interpolate vectors that is clamped between zero and one.
Returns
Resulting interpolated vector.

◆ manhattan_distance()

template<typename Real>
Real nnm::Vector2< Real >::manhattan_distance ( const Vector2< Real > & to) const
inlinenodiscardconstexpr

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

Parameters
toPosition to.
Returns
Resulting distance.

◆ max()

template<typename Real>
Real nnm::Vector2< Real >::max ( ) const
inlinenodiscardconstexpr

The maximum component.

Returns
Result.

◆ max_index()

template<typename Real>
uint8_t nnm::Vector2< Real >::max_index ( ) const
inlinenodiscardconstexpr

Index of the maximum component.

Returns
Resulting index.

◆ min()

template<typename Real>
Real nnm::Vector2< Real >::min ( ) const
inlinenodiscardconstexpr

The minimum component.

Returns
Result.

◆ min_index()

template<typename Real>
uint8_t nnm::Vector2< Real >::min_index ( ) const
inlinenodiscardconstexpr

Index of the minimum component.

Returns
Resulting index.

◆ normalize()

template<typename Real>
Vector2 nnm::Vector2< Real >::normalize ( ) const
inlinenodiscard

Normalize the vector which keeps the direction but with a length of one.

Returns
Resulting normalized vector.

◆ one()

template<typename Real>
constexpr Vector2 nnm::Vector2< Real >::one ( )
inlinestaticconstexpr

Vector with all components set to one.

Returns
Resulting vector.

◆ operator bool()

template<typename Real>
nnm::Vector2< Real >::operator bool ( ) const
inlineexplicitnodiscardconstexpr

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

◆ operator!=()

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

Determines if this vector does not equal another.

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

◆ operator*() [1/3]

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::operator* ( const Matrix2< Real > & matrix) const
nodiscardconstexpr

Vector-matrix multiplication.

Parameters
matrixMatrix.
Returns
Result.

◆ operator*() [2/3]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator* ( const Real value) const
inlinenodiscardconstexpr

Vector-scalar multiplication.

Parameters
valueValue.
Returns
Result.

◆ operator*() [3/3]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator* ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Component-wise multiplication.

Parameters
otherOther vector.
Returns
Result.

◆ operator*=() [1/2]

template<typename Real>
Vector2 & nnm::Vector2< Real >::operator*= ( const Real value)
inlineconstexpr

Multiplies each component by a value.

Parameters
valueValue.
Returns
Reference to this vector.

◆ operator*=() [2/2]

template<typename Real>
Vector2 & nnm::Vector2< Real >::operator*= ( const Vector2< Real > & other)
inlineconstexpr

Multiplied each component of this vector by another vector.

Parameters
otherOther vector.
Returns
Reference to this vector.

◆ operator+() [1/2]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator+ ( ) const
inlinenodiscardconstexpr

Unary plus. Does nothing but specified for symmetry with unary minus.

Returns
Result.

◆ operator+() [2/2]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator+ ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Vector addition.

Parameters
otherOther vector.
Returns
Result.

◆ operator+=()

template<typename Real>
Vector2 & nnm::Vector2< Real >::operator+= ( const Vector2< Real > & other)
inlineconstexpr

Adds another vector to this vector.

Parameters
otherOther vector.
Returns
Reference to this vector.

◆ operator-() [1/2]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator- ( ) const
inlinenodiscardconstexpr

Component-wise negation.

Returns
Result.

◆ operator-() [2/2]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator- ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Vector subtraction.

Parameters
otherOther vector.
Returns
Result.

◆ operator-=()

template<typename Real>
Vector2 & nnm::Vector2< Real >::operator-= ( const Vector2< Real > & other)
inlineconstexpr

Subtracts another vector from this vector.

Parameters
otherOther vector.
Returns
Reference to this vector.

◆ operator/() [1/2]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator/ ( const Real value) const
inlinenodiscardconstexpr

Vector-scalar division.

Parameters
valueValue.
Returns
Result.

◆ operator/() [2/2]

template<typename Real>
Vector2 nnm::Vector2< Real >::operator/ ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Component-wise division.

Parameters
otherOther vector.
Returns
Result/

◆ operator/=() [1/2]

template<typename Real>
Vector2 & nnm::Vector2< Real >::operator/= ( const Real value)
inlineconstexpr

Divides each component by a value.

Parameters
valueValue.
Returns
Result.

◆ operator/=() [2/2]

template<typename Real>
Vector2 & nnm::Vector2< Real >::operator/= ( const Vector2< Real > & other)
inlineconstexpr

Divide each component by another vector.

Parameters
otherOther vector.
Returns
Reference to this vector.

◆ operator<()

template<typename Real>
bool nnm::Vector2< Real >::operator< ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Lexicographical comparison between components.

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

◆ operator==()

template<typename Real>
bool nnm::Vector2< Real >::operator== ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Determines if this vector equals another.

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

◆ operator[]() [1/2]

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

Reference to component at index.

Parameters
indexIndex.
Returns
Reference.

◆ operator[]() [2/2]

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

Constant reference to component at index.

Parameters
indexIndex.
Returns
Constant reference.

◆ outer()

template<typename Real>
Matrix2< Real > nnm::Vector2< Real >::outer ( const Vector2< Real > & other) const
nodiscardconstexpr

Outer product.

Parameters
otherOther vector.
Returns
Resulting 2x2 matrix.

◆ parallel()

template<typename Real>
bool nnm::Vector2< Real >::parallel ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Determines if this vector is parallel to another vector.

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

◆ perpendicular()

template<typename Real>
bool nnm::Vector2< Real >::perpendicular ( const Vector2< Real > & other) const
inlinenodiscardconstexpr

Determines if this vector is perpendicular to another vector.

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

◆ project()

template<typename Real>
Vector2 nnm::Vector2< Real >::project ( const Vector2< Real > & onto) const
inlinenodiscardconstexpr

Project this vector onto another vector.

Parameters
ontoVector to project onto.
Returns
Resulting projected vector.

◆ reflect()

template<typename Real>
Vector2 nnm::Vector2< Real >::reflect ( const Vector2< Real > & normal) const
inlinenodiscardconstexpr

Reflect this vector along a normal vector.

Parameters
normalNormal to reflect along.
Returns
Resulting reflected vector.

◆ rotate()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::rotate ( Real angle) const
nodiscard

Rotate about the origin.

Parameters
angleAngle in radians.
Returns
Resulting rotated vector.

◆ rotate_at()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::rotate_at ( const Vector2< Real > & origin,
Real angle ) const
nodiscard

Rotate about an origin.

Parameters
originOrigin to rotate about.
angleAngle in radians.
Returns
Resulting rotate vector.

◆ round()

template<typename Real>
Vector2 nnm::Vector2< Real >::round ( ) const
inlinenodiscard

Round all components.

Returns
Resulting vector.

◆ scale()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::scale ( const Vector2< Real > & factor) const
nodiscardconstexpr

Component-wise scale about the origin.

Parameters
factorScale factor.
Returns
Resulting scaled vector.

◆ scale_at()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::scale_at ( const Vector2< Real > & origin,
const Vector2< Real > & factor ) const
nodiscardconstexpr

Component-wise scale about an origin.

Parameters
originOrigin to scale about.
factorScale factor.
Returns
Resulting scaled vector.

◆ shear_x()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::shear_x ( Real factor) const
nodiscardconstexpr

Shear along the x-axis about the origin.

Parameters
factorFactor.
Returns
Resulting sheared vector.

◆ shear_x_at()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::shear_x_at ( const Vector2< Real > & origin,
Real factor ) const
nodiscardconstexpr

Shear along the x-axis about an origin.

Parameters
originOrigin to shear about.
factorAngle in radians.
Returns
Resulting sheared vector.

◆ shear_y()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::shear_y ( Real factor) const
nodiscardconstexpr

Shear along the y-axis about the origin.

Parameters
factorFactor.
Returns
Resulting sheared vector.

◆ shear_y_at()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::shear_y_at ( const Vector2< Real > & origin,
Real factor ) const
nodiscardconstexpr

Shear along the y-axis about an origin.

Parameters
originOrigin to shear about.
factorFactor.
Returns
Resulting sheared vector.

◆ transform() [1/2]

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::transform ( const Basis2< Real > & by) const
nodiscardconstexpr

Transform by a 2D basis about the origin.

Parameters
by2D basis to transform by.
Returns
Resulting transformed vector.

◆ transform() [2/2]

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::transform ( const Transform2< Real > & by,
Real z = static_cast<Real>(1) ) const
nodiscardconstexpr

Transform by a 2D transformation matrix about the origin.

Parameters
by2D transformation matrix to transform by.
zThe homogenous coordinate which defaults to one.
Returns
Resulting transformed vector.

◆ transform_at() [1/2]

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::transform_at ( const Vector2< Real > & origin,
const Basis2< Real > & by ) const
nodiscardconstexpr

Transform by a 2D basis about an origin.

Parameters
originOrigin to transform about.
by2D basis to transform by.
Returns
Resulting transformed vector.

◆ transform_at() [2/2]

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::transform_at ( const Vector2< Real > & origin,
const Transform2< Real > & by,
Real z = static_cast<Real>(1) ) const
nodiscardconstexpr

Transform by a 2D transformation matrix about an origin.

Parameters
originOrigin to transform about.
by2D transformation matrix to transform by.
zThe homogenous coordinate which defaults to one.
Returns
Resulting transformed vector.

◆ translate()

template<typename Real>
Vector2< Real > nnm::Vector2< Real >::translate ( const Vector2< Real > & by) const
nodiscardconstexpr

Translate vector as a position.

Parameters
byOffset.
Returns
Resulting translated vector.

◆ zero()

template<typename Real>
constexpr Vector2 nnm::Vector2< Real >::zero ( )
inlinestaticconstexpr

Vector with all components set to zero.

Returns
Resulting vector.

Member Data Documentation

◆ x

template<typename Real>
Real nnm::Vector2< Real >::x

◆ y

template<typename Real>
Real nnm::Vector2< Real >::y

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