Acid  0.14.1
A high speed C++17 Vulkan game engine.
Public Member Functions | Data Fields | Static Public Attributes
acid::Vector2< T > Class Template Reference

Holds a 2-tuple vector. More...

#include <Vector2.hpp>

Public Member Functions

constexpr Vector2 ()=default
 
constexpr Vector2 (const T &a)
 
constexpr Vector2 (const T &x, const T &y)
 
template<typename K , typename J >
constexpr Vector2 (const K &x, const J &y)
 
template<typename K >
constexpr Vector2 (const Vector2< K > &source)
 
template<typename K >
constexpr Vector2 (const Vector3< K > &source)
 
template<typename K >
constexpr auto Add (const Vector2< K > &other) const
 
template<typename K >
constexpr auto Subtract (const Vector2< K > &other) const
 
template<typename K >
constexpr auto Multiply (const Vector2< K > &other) const
 
template<typename K >
constexpr auto Divide (const Vector2< K > &other) const
 
template<typename K >
constexpr auto Angle (const Vector2< K > &other) const
 
template<typename K >
constexpr auto Dot (const Vector2< K > &other) const
 
template<typename K , typename J = float>
constexpr auto Lerp (const Vector2< K > &other, const J &progression) const
 
template<typename K = float>
constexpr auto Scale (const K &scalar) const
 
template<typename K = float>
auto Rotate (const K &angle) const
 
template<typename K = float, typename J >
auto Rotate (const K &angle, const Vector2< J > &rotationAxis) const
 
auto Normalize () const
 
constexpr auto LengthSquared () const
 
auto Length () const
 
auto Abs () const
 
constexpr auto Min () const
 
constexpr auto Max () const
 
constexpr auto MinMax () const
 
template<typename K >
constexpr auto Min (const Vector2< K > &other)
 
template<typename K >
constexpr auto Max (const Vector2< K > &other)
 
template<typename K >
constexpr auto DistanceSquared (const Vector2< K > &other) const
 
template<typename K >
auto Distance (const Vector2< K > &other) const
 
template<typename K >
constexpr auto DistanceVector (const Vector2< K > &other) const
 
template<typename K >
constexpr bool InTriangle (const Vector2< K > &v1, const Vector2< K > &v2, const Vector2< K > &v3) const
 
template<typename K , typename J >
constexpr auto SmoothDamp (const Vector2< K > &target, const Vector2< J > &rate) const
 
auto CartesianToPolar () const
 
auto PolarToCartesian () const
 
constexpr const T & operator[] (uint32_t index) const
 
constexpr T & operator[] (uint32_t index)
 
template<typename K >
constexpr bool operator== (const Vector2< K > &other) const
 
template<typename K >
constexpr bool operator!= (const Vector2< K > &other) const
 
template<typename U = T>
constexpr std::enable_if_t< std::is_signed_v< U >, Vector2operator- () const
 
template<typename U = T>
constexpr std::enable_if_t< std::is_integral_v< U >, Vector2operator~ () const
 
template<typename K >
constexpr Vector2operator+= (const Vector2< K > &other)
 
template<typename K >
constexpr Vector2operator-= (const Vector2< K > &other)
 
template<typename K >
constexpr Vector2operator*= (const Vector2< K > &other)
 
template<typename K >
constexpr Vector2operator/= (const Vector2< K > &other)
 
constexpr Vector2operator+= (const T &other)
 
constexpr Vector2operator-= (const T &other)
 
constexpr Vector2operator*= (const T &other)
 
constexpr Vector2operator/= (const T &other)
 
template<typename U >
constexpr std::enable_if_t< std::is_signed_v< U >, Vector2< T > > operator- () const
 
template<typename U >
constexpr std::enable_if_t< std::is_integral_v< U >, Vector2< T > > operator~ () const
 
template<typename K >
constexpr Vector2< T > & operator+= (const Vector2< K > &other)
 
template<typename K >
constexpr Vector2< T > & operator-= (const Vector2< K > &other)
 
template<typename K >
constexpr Vector2< T > & operator*= (const Vector2< K > &other)
 
template<typename K >
constexpr Vector2< T > & operator/= (const Vector2< K > &other)
 

Data Fields

x = 0
 
y = 0
 

Static Public Attributes

static ACID_EXPORT const Vector2 Zero
 
static ACID_EXPORT const Vector2 One
 
static ACID_EXPORT const Vector2 Infinity
 
static ACID_EXPORT const Vector2 Left
 
static ACID_EXPORT const Vector2 Right
 
static ACID_EXPORT const Vector2 Up
 
static ACID_EXPORT const Vector2 Down
 

Detailed Description

template<typename T>
class acid::Vector2< T >

Holds a 2-tuple vector.

Template Parameters
TThe value type.

Constructor & Destructor Documentation

◆ Vector2() [1/6]

template<typename T >
constexpr acid::Vector2< T >::Vector2 ( )
constexprdefault

Constructor for Vector2.

◆ Vector2() [2/6]

template<typename T >
constexpr acid::Vector2< T >::Vector2 ( const T &  a)
explicitconstexpr

Constructor for Vector2.

Parameters
aThe value to set all components to.

◆ Vector2() [3/6]

template<typename T >
constexpr acid::Vector2< T >::Vector2 ( const T &  x,
const T &  y 
)
constexpr

Constructor for Vector2.

Parameters
xStart x.
yStart y.

◆ Vector2() [4/6]

template<typename T >
template<typename K , typename J >
constexpr acid::Vector2< T >::Vector2 ( const K &  x,
const J &  y 
)
constexpr

Constructor for Vector2.

Template Parameters
KThe x type.
JThe y type.
Parameters
xStart x.
yStart y.

◆ Vector2() [5/6]

template<typename T >
template<typename K >
constexpr acid::Vector2< T >::Vector2 ( const Vector2< K > &  source)
constexpr

Constructor for Vector2.

Template Parameters
KThe sources type.
Parameters
sourceCreates this vector out of a existing vector.

◆ Vector2() [6/6]

template<typename T >
template<typename K >
constexpr acid::Vector2< T >::Vector2 ( const Vector3< K > &  source)
constexpr

Constructor for Vector3.

Template Parameters
KThe sources type.
Parameters
sourceCreates this vector out of a existing vector.

Member Function Documentation

◆ Abs()

template<typename T >
auto acid::Vector2< T >::Abs

Gets the absolute value of every component in this vector.

Returns
The absolute value of this vector.

◆ Add()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Add ( const Vector2< K > &  other) const
constexpr

Adds this vector to another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The resultant vector.

◆ Angle()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Angle ( const Vector2< K > &  other) const
constexpr

Calculates the angle between this vector and another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The angle, in radians.

◆ CartesianToPolar()

template<typename T >
auto acid::Vector2< T >::CartesianToPolar

Converts from rectangular to spherical coordinates, this vector is in cartesian (x, y).

Returns
The polar coordinates (radius, theta).

◆ Distance()

template<typename T >
template<typename K >
auto acid::Vector2< T >::Distance ( const Vector2< K > &  other) const

Gets the between this vector and another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The distance.

◆ DistanceSquared()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::DistanceSquared ( const Vector2< K > &  other) const
constexpr

Gets the distance between this vector and another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The squared distance.

◆ DistanceVector()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::DistanceVector ( const Vector2< K > &  other) const
constexpr

Gets the vector distance between this vector and another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The vector distance.

◆ Divide()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Divide ( const Vector2< K > &  other) const
constexpr

Divides this vector by another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The resultant vector.

◆ Dot()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Dot ( const Vector2< K > &  other) const
constexpr

Calculates the dot product of the this vector and another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The dot product.

◆ InTriangle()

template<typename T >
template<typename K >
constexpr bool acid::Vector2< T >::InTriangle ( const Vector2< K > &  v1,
const Vector2< K > &  v2,
const Vector2< K > &  v3 
) const
constexpr

Gets if this vector is in a triangle.

Template Parameters
KThe types.
Parameters
v1The first triangle vertex.
v2The second triangle vertex.
v3The third triangle vertex.
Returns
If this vector is in a triangle.

◆ Length()

template<typename T >
auto acid::Vector2< T >::Length

Gets the length of this vector.

Returns
The length.

◆ LengthSquared()

template<typename T >
constexpr auto acid::Vector2< T >::LengthSquared
constexpr

Gets the length squared of this vector.

Returns
The length squared.

◆ Lerp()

template<typename T >
template<typename K , typename J >
constexpr auto acid::Vector2< T >::Lerp ( const Vector2< K > &  other,
const J &  progression 
) const
constexpr

Calculates the linear interpolation between this vector and another vector.

Template Parameters
KThe others type.
JThe progression type.
Parameters
otherThe other quaternion.
progressionThe progression.
Returns
Left lerp right.

◆ Max() [1/2]

template<typename T >
constexpr auto acid::Vector2< T >::Max
constexpr

Gets the maximal value in this vector.

Returns
The maximal components.

◆ Max() [2/2]

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Max ( const Vector2< K > &  other)
constexpr

Gets the maximum vector size between this vector and other.

Template Parameters
KThe others type.
Parameters
otherThe other vector to get values from.
Returns
The maximum vector.

◆ Min() [1/2]

template<typename T >
constexpr auto acid::Vector2< T >::Min
constexpr

Gets the minimal value in this vector.

Returns
The minimal components.

◆ Min() [2/2]

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Min ( const Vector2< K > &  other)
constexpr

Gets the lowest vector size between this vector and other.

Template Parameters
KThe others type.
Parameters
otherThe other vector to get values from.
Returns
The lowest vector.

◆ MinMax()

template<typename T >
constexpr auto acid::Vector2< T >::MinMax
constexpr

Gets the minimal and maximal values in the vector.

Returns
The minimal and maximal components.

◆ Multiply()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Multiply ( const Vector2< K > &  other) const
constexpr

Multiplies this vector with another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The resultant vector.

◆ Normalize()

template<typename T >
auto acid::Vector2< T >::Normalize

Normalizes this vector.

Returns
The normalized vector.

◆ operator!=()

template<typename T >
template<typename K >
constexpr bool acid::Vector2< T >::operator!= ( const Vector2< K > &  other) const
constexpr

◆ operator*=() [1/3]

template<typename T >
constexpr Vector2< T > & acid::Vector2< T >::operator*= ( const T &  other)
constexpr

◆ operator*=() [2/3]

template<typename T >
template<typename K >
constexpr Vector2<T>& acid::Vector2< T >::operator*= ( const Vector2< K > &  other)
constexpr

◆ operator*=() [3/3]

template<typename T >
template<typename K >
constexpr Vector2& acid::Vector2< T >::operator*= ( const Vector2< K > &  other)
constexpr

◆ operator+=() [1/3]

template<typename T >
constexpr Vector2< T > & acid::Vector2< T >::operator+= ( const T &  other)
constexpr

◆ operator+=() [2/3]

template<typename T >
template<typename K >
constexpr Vector2<T>& acid::Vector2< T >::operator+= ( const Vector2< K > &  other)
constexpr

◆ operator+=() [3/3]

template<typename T >
template<typename K >
constexpr Vector2& acid::Vector2< T >::operator+= ( const Vector2< K > &  other)
constexpr

◆ operator-() [1/2]

template<typename T >
template<typename U >
constexpr std::enable_if_t<std::is_signed_v<U>, Vector2<T> > acid::Vector2< T >::operator- ( ) const
constexpr

◆ operator-() [2/2]

template<typename T >
template<typename U = T>
constexpr std::enable_if_t<std::is_signed_v<U>, Vector2> acid::Vector2< T >::operator- ( ) const
constexpr

◆ operator-=() [1/3]

template<typename T >
constexpr Vector2< T > & acid::Vector2< T >::operator-= ( const T &  other)
constexpr

◆ operator-=() [2/3]

template<typename T >
template<typename K >
constexpr Vector2<T>& acid::Vector2< T >::operator-= ( const Vector2< K > &  other)
constexpr

◆ operator-=() [3/3]

template<typename T >
template<typename K >
constexpr Vector2& acid::Vector2< T >::operator-= ( const Vector2< K > &  other)
constexpr

◆ operator/=() [1/3]

template<typename T >
constexpr Vector2< T > & acid::Vector2< T >::operator/= ( const T &  other)
constexpr

◆ operator/=() [2/3]

template<typename T >
template<typename K >
constexpr Vector2<T>& acid::Vector2< T >::operator/= ( const Vector2< K > &  other)
constexpr

◆ operator/=() [3/3]

template<typename T >
template<typename K >
constexpr Vector2& acid::Vector2< T >::operator/= ( const Vector2< K > &  other)
constexpr

◆ operator==()

template<typename T >
template<typename K >
constexpr bool acid::Vector2< T >::operator== ( const Vector2< K > &  other) const
constexpr

◆ operator[]() [1/2]

template<typename T >
constexpr T & acid::Vector2< T >::operator[] ( uint32_t  index)
constexpr

◆ operator[]() [2/2]

template<typename T >
constexpr const T & acid::Vector2< T >::operator[] ( uint32_t  index) const
constexpr

◆ operator~() [1/2]

template<typename T >
template<typename U >
constexpr std::enable_if_t<std::is_integral_v<U>, Vector2<T> > acid::Vector2< T >::operator~ ( ) const
constexpr

◆ operator~() [2/2]

template<typename T >
template<typename U = T>
constexpr std::enable_if_t<std::is_integral_v<U>, Vector2> acid::Vector2< T >::operator~ ( ) const
constexpr

◆ PolarToCartesian()

template<typename T >
auto acid::Vector2< T >::PolarToCartesian

Converts from spherical to rectangular coordinates, this vector is in polar (radius, theta).

Returns
The cartesian coordinates (x, y).

◆ Rotate() [1/2]

template<typename T >
template<typename K >
auto acid::Vector2< T >::Rotate ( const K &  angle) const

Rotates this vector by a angle around the origin.

Template Parameters
KThe angle type.
Parameters
angleThe angle to rotate by, in radians.
Returns
The rotated vector.

◆ Rotate() [2/2]

template<typename T >
template<typename K , typename J >
auto acid::Vector2< T >::Rotate ( const K &  angle,
const Vector2< J > &  rotationAxis 
) const

Rotates this vector by a angle around a rotation axis.

Template Parameters
KThe angle type.
JThe rotation axis type.
Parameters
angleThe angle to rotate by, in radians.
rotationAxisThe point to rotate the vector around.
Returns
The rotated vector.

◆ Scale()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Scale ( const K &  scalar) const
constexpr

Scales this vector by a scalar.

Template Parameters
KThe scalar type.
Parameters
scalarThe scalar value.
Returns
The scaled vector.

◆ SmoothDamp()

template<typename T >
template<typename K , typename J >
constexpr auto acid::Vector2< T >::SmoothDamp ( const Vector2< K > &  target,
const Vector2< J > &  rate 
) const
constexpr

Gradually changes this vector to a target.

Parameters
targetThe target vector.
rateThe rate to go from current to the target.
Returns
The changed vector.

◆ Subtract()

template<typename T >
template<typename K >
constexpr auto acid::Vector2< T >::Subtract ( const Vector2< K > &  other) const
constexpr

Subtracts this vector to another vector.

Template Parameters
KThe others type.
Parameters
otherThe other vector.
Returns
The resultant vector.

Field Documentation

◆ Down

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::Down
static

◆ Infinity

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::Infinity
static

◆ Left

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::Left
static

◆ One

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::One
static

◆ Right

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::Right
static

◆ Up

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::Up
static

◆ x

template<typename T >
T acid::Vector2< T >::x = 0

◆ y

template<typename T >
T acid::Vector2< T >::y = 0

◆ Zero

template<typename T >
ACID_EXPORT const Vector2 acid::Vector2< T >::Zero
static

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