EBGeometry  1.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Vec2T< T > Class Template Reference

Two-dimensional vector class with arithmetic operators. More...

#include <EBGeometry_Vec.hpp>

Public Member Functions

 Vec2T ()
 Default constructor. Sets the vector to the zero vector.
 
 Vec2T (const Vec2T &u) noexcept
 Copy constructor. More...
 
constexpr Vec2T (const T &a_x, const T &a_y)
 Full constructor. More...
 
 ~Vec2T ()=default
 Destructor (does nothing)
 
constexpr Vec2T< T > & operator= (const Vec2T &a_other) noexcept
 Assignment operator. Sets this.x = a_other.x and this.y = a_other.y. More...
 
constexpr Vec2T< T > operator+ (const Vec2T &a_other) const noexcept
 Addition operator. More...
 
constexpr Vec2T< T > operator- (const Vec2T &a_other) const noexcept
 Subtraction operator. More...
 
constexpr Vec2T< T > operator- () const noexcept
 Negation operator. Returns a new Vec2T<T> with negated components.
 
constexpr Vec2T< T > operator* (const T &s) const noexcept
 Multiplication operator. More...
 
constexpr Vec2T< T > operator/ (const T &s) const noexcept
 Division operator. More...
 
constexpr Vec2T< T > & operator+= (const Vec2T &a_other) noexcept
 Addition operator. More...
 
constexpr Vec2T< T > & operator-= (const Vec2T &a_other) noexcept
 Subtraction operator. More...
 
constexpr Vec2T< T > & operator*= (const T &s) noexcept
 Multiplication operator. More...
 
constexpr Vec2T< T > & operator/= (const T &s) noexcept
 Division operator operator. More...
 
constexpr T dot (const Vec2T &a_other) const noexcept
 Dot product operator. More...
 
constexpr T length () const noexcept
 Compute length of vector. More...
 
constexpr T length2 () const noexcept
 Compute square of vector. More...
 

Static Public Member Functions

static constexpr Vec2T< T > zero () noexcept
 Return av vector with x = y = 0.
 
static constexpr Vec2T< T > one () noexcept
 Return av vector with x = y = 1.
 
static constexpr Vec2T< T > min () noexcept
 Return minimum possible representative vector.
 
static constexpr Vec2T< T > max () noexcept
 Return maximum possible representative vector.
 
static constexpr Vec2T< T > infinity () noexcept
 Return a vector with inf components.
 

Public Attributes

x
 First component in the vector.
 
y
 Second component in the vector.
 

Detailed Description

template<typename T>
class Vec2T< T >

Two-dimensional vector class with arithmetic operators.

The class has a public-only interface. To change it's components one can call the member functions, or set components directly, e.g. vec.x = 5.0

Note
Vec2T is a templated class primarily used with DCEL grids.

Constructor & Destructor Documentation

◆ Vec2T() [1/2]

template<typename T >
Vec2T< T >::Vec2T ( const Vec2T< T > &  u)
noexcept

Copy constructor.

Parameters
[in]uOther vector

Sets *this = u

◆ Vec2T() [2/2]

template<typename T >
constexpr Vec2T< T >::Vec2T ( const T &  a_x,
const T &  a_y 
)
constexpr

Full constructor.

Parameters
[in]a_xFirst vector component
[in]a_ySecond vector component

Sets this->x = a_x and this->y = a_y

Member Function Documentation

◆ dot()

template<typename T >
constexpr T Vec2T< T >::dot ( const Vec2T< T > &  a_other) const
inlineconstexprnoexcept

Dot product operator.

Parameters
[in]a_otherother vector

Returns the dot product, i.e. this->x*a_other.x + this->y+a_other.y

◆ length()

template<typename T >
constexpr T Vec2T< T >::length ( ) const
inlineconstexprnoexcept

Compute length of vector.

Returns
Returns length of vector, i.e. sqrt[(this->x)*(this->x) + (this->y)*(this->y)]

◆ length2()

template<typename T >
constexpr T Vec2T< T >::length2 ( ) const
inlineconstexprnoexcept

Compute square of vector.

Returns
Returns length of vector, i.e. (this->x)*(this->x) + (this->y)*(this->y)

◆ operator*()

template<typename T >
constexpr Vec2T<T> Vec2T< T >::operator* ( const T &  s) const
inlineconstexprnoexcept

Multiplication operator.

Parameters
[in]sScalar to be multiplied

Returns a new Vec2T<T> with components x = s*this->x (and same for y)

◆ operator*=()

template<typename T >
constexpr Vec2T<T>& Vec2T< T >::operator*= ( const T &  s)
inlineconstexprnoexcept

Multiplication operator.

Parameters
[in]sScalar to multiply by

Returns (*this) with components this->x = s*this->x (and same for y)

◆ operator+()

template<typename T >
constexpr Vec2T<T> Vec2T< T >::operator+ ( const Vec2T< T > &  a_other) const
inlineconstexprnoexcept

Addition operator.

Parameters
[in]a_otherOther vector

Returns a new object with component x = this->x + a_other.x (same for y-component)

◆ operator+=()

template<typename T >
constexpr Vec2T<T>& Vec2T< T >::operator+= ( const Vec2T< T > &  a_other)
inlineconstexprnoexcept

Addition operator.

Parameters
[in]a_otherOther vector to add

Returns (*this) with components this->x = this->x + a_other.x (and same for y)

◆ operator-()

template<typename T >
constexpr Vec2T<T> Vec2T< T >::operator- ( const Vec2T< T > &  a_other) const
inlineconstexprnoexcept

Subtraction operator.

Parameters
[in]a_otherOther vector

Returns a new object with component x = this->x - a_other.x (same for y-component)

◆ operator-=()

template<typename T >
constexpr Vec2T<T>& Vec2T< T >::operator-= ( const Vec2T< T > &  a_other)
inlineconstexprnoexcept

Subtraction operator.

Parameters
[in]a_otherOther vector to subtract

Returns (*this) with components this->x = this->x - a_other.x (and same for y)

◆ operator/()

template<typename T >
constexpr Vec2T<T> Vec2T< T >::operator/ ( const T &  s) const
inlineconstexprnoexcept

Division operator.

Parameters
[in]sScalar to be multiplied

Returns a new Vec2T<T> with components x = (1/s)*this->x (and same for y)

◆ operator/=()

template<typename T >
constexpr Vec2T<T>& Vec2T< T >::operator/= ( const T &  s)
inlineconstexprnoexcept

Division operator operator.

Parameters
[in]sScalar to divide by

Returns (*this) with components this->x = (1/s)*this->x (and same for y)

◆ operator=()

template<typename T >
constexpr Vec2T<T>& Vec2T< T >::operator= ( const Vec2T< T > &  a_other)
inlineconstexprnoexcept

Assignment operator. Sets this.x = a_other.x and this.y = a_other.y.

Parameters
[in]a_otherOther vector

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