Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
spat::Vector2D< Valtype > Struct Template Reference

Implements a 2D - vector in cartesian coordinates. More...

#include <C:/Trend/Development/Trax3/Code/spat/Vector2D.h>

Inheritance diagram for spat::Vector2D< Valtype >:

Public Types

enum class  specials { null = -1 , ex = 0 , ey = 1 }
 Identifiers for special vectors. More...
typedef Valtype value_type

Public Member Functions

Vector2DInit (specials s=specials::ex) noexcept
 Initializes the Vector2D.
constexpr bool Is (specials s) const noexcept
 Test the Vector2D to mach a special Vector2D exactly.
constexpr Valtype Length () const noexcept
 Calculates the length of the Vector2D.
auto Normalize () noexcept -> decltype(Valtype{}/Valtype{})
template<typename Valtype2>
Vector2DRotate (Valtype2 angle) noexcept
 Rotate this vector with angle in radiants.
constexpr Vector2D ParallelProjection (const Vector2D &normal) const noexcept
 Part of this tVector wich is parallel to normal.
constexpr Vector2D OrthogonalProjection (const Vector2D &normal) const noexcept
 Calculate part of this tVector wich is orthogonal to normal.
constexpr bool Equals (const Vector2D &v, Valtype epsilon=0) const noexcept
 Comparison within some range. The area within two vectors regarded as equal is a sphere with radius epsilon.
template<typename Valtype2>
Vector2D< Valtype > & operator= (const Vector< Valtype2 > &v) noexcept
template<typename Valtype2>
Vector2D< Valtype > & Rotate (Valtype2 angle) noexcept
Construction
Parameters
dxcartesian x component.
dycartesian y component.
s
p
pVal
constexpr Vector2D () noexcept=default
 Does not initialize the members.
constexpr Vector2D (Valtype dx, Valtype dy) noexcept
 Does not initialize the members.
constexpr Vector2D (specials s) noexcept
 Does not initialize the members.
 Vector2D (const Position2D< Valtype > &p) noexcept=delete
 Conversions between Position2D and Vector2D shouldn't be necessary.
constexpr Vector2D (const Vector< Valtype > &v) noexcept
 Does not initialize the members.
template<typename Valtype2>
 Vector2D (const Valtype2 *pVal) noexcept
 Does not initialize the members.
Assignment
Parameters
vectorsource vector
template<typename Valtype2>
Vector2Doperator= (const Vector< Valtype2 > &vector) noexcept
Subscripting.
Returns
Reference to value.
const Valtype & operator[] (size_t index) const
Valtype & operator[] (size_t index)

Public Attributes

Valtype dx
 cartesian x component.
Valtype dy
 cartesian y component.

Detailed Description

template<typename Valtype>
struct spat::Vector2D< Valtype >

Implements a 2D - vector in cartesian coordinates.

Specifies the coordinates of a direction in 2D space. For points, like e.g. vertices, use the Position2D type.

Member Enumeration Documentation

◆ specials

template<typename Valtype>
enum class spat::Vector2D::specials
strong

Identifiers for special vectors.

Enumerator
null 

Vector with all parameters zeroed.

ex 

Unit vector in x-direction.

ey 

Unit vector in y-direction.

Member Function Documentation

◆ Equals()

template<typename Valtype>
bool spat::Vector2D< Valtype >::Equals ( const Vector2D< Valtype > & v,
Valtype epsilon = 0 ) const
constexprnoexcept

Comparison within some range. The area within two vectors regarded as equal is a sphere with radius epsilon.

Parameters
vVector2D to compare with.
epsilonDistance <= wich two vectors are regarded as equal.
Returns
True if positions are nearby each other, else false.

◆ Init()

template<typename Valtype>
Vector2D< Valtype > & spat::Vector2D< Valtype >::Init ( specials s = specials::ex)
noexcept

Initializes the Vector2D.

Parameters
sType of Vector2D to initialize with.

◆ Length()

template<typename Valtype>
Valtype spat::Vector2D< Valtype >::Length ( ) const
inlineconstexprnoexcept

Calculates the length of the Vector2D.

Returns
Length of Vector2D.

◆ Normalize()

template<typename Valtype>
auto spat::Vector2D< Valtype >::Normalize ( ) ->decltype(Valtype{}/Valtype{})
inlinenoexcept

Normalizes the Vector2D to length 1.

Returns
Previous length.

◆ OrthogonalProjection()

template<typename Valtype>
Vector2D< Valtype > spat::Vector2D< Valtype >::OrthogonalProjection ( const Vector2D< Valtype > & normal) const
inlineconstexprnoexcept

Calculate part of this tVector wich is orthogonal to normal.

Parameters
normalReference vector to meassure this against. Must not be 0.
Returns
A vector orthogonal to normal.

◆ ParallelProjection()

template<typename Valtype>
Vector2D< Valtype > spat::Vector2D< Valtype >::ParallelProjection ( const Vector2D< Valtype > & normal) const
inlineconstexprnoexcept

Part of this tVector wich is parallel to normal.

Parameters
normalReference vector to meassure this against. Must not be 0.
Returns
A vector parallel to normal.

The documentation for this struct was generated from the following files:
  • C:/Trend/Development/Trax3/Code/spat/Matrix.h
  • C:/Trend/Development/Trax3/Code/spat/Vector2D.h