vector.hpp#

Typedefs

typedef Vector<3> Vector3#
typedef Vector<6> State#
template<size_t n>
class Vector#
#include <vector.hpp>

n-Vector class Fixed size array

Public Functions

inline Vector()#

Default constructor creates the zero vector

inline Vector(std::initializer_list<double> l)#
inline double &operator[](size_t i)#

Access to vector component

inline const double &operator[](size_t i) const#

Private Members

double v[n + 1]#

Functions

template<size_t n>
Vector<n> operator+(const Vector<n> &a, const Vector<n> &b)#

Vectorial sum

Parameters
  • a – one vector

  • b – other vector

Returns

vectorial sum a + b

template<size_t n>
Vector<n> operator-(const Vector<n> &a, const Vector<n> &b)#

Vectorial difference

Parameters
  • a – one vector

  • b – another vector

Returns

vectorial sum a + (-b)

template<size_t n>
Vector<n> operator*(const Vector<n> &a, double t)#

Scalar vector multiplication

Parameters
  • a – a vector

  • t – a scalar

Returns

scaled vector t * a

template<size_t n>
Vector<n> operator*(double t, const Vector<n> &a)#

Scalar vector multiplication

Parameters
  • t – a scalar

  • a – a vector

Returns

scaled vector t * a

template<size_t n>
Vector<n> operator*(const Vector<n> &a, const Vector<n> &b)#

Element-wise vector multiplication

Parameters
  • a – a vector

  • b – other vector

Returns

scaled vector t * a

template<size_t n>
Vector<n> operator/(const Vector<n> &a, double t)#

Vector divided by scalar

Parameters
  • a – a vector

  • t – a scalar

Returns

scaled vector a / t

template<size_t n>
double dot(const Vector<n> &a, const Vector<n> &b)#

Dot product between two vector

Parameters
  • a – one vector

  • b – another vector

Returns

dot product a . b

template<size_t n>
double mod(const Vector<n> &v)#

Modulus of vector (2-norm)

Parameters

v – a vector

Returns

|v|

template<size_t n>
bool hasnan(const Vector<n> &v)#

Checks if there is a nan value inside

Parameters

vVector

Returns

true if there is a nan value

template<size_t n>
std::ostream &operator<<(std::ostream &out, const Vector<n> &v)#

Out stream operator

template<size_t n>
std::istream &operator>>(std::istream &in, Vector<n> &v)#

In stream operator

Vector3 cross(const Vector3 &a, const Vector3 &b)#

Cross product between two 3-Vectors

Parameters
  • a – one vector

  • b – another vector

Returns

dot product a x b

double angle_between(const Vector3 &a, const Vector3 &b)#

Angle between two 3-Vectors

Parameters
  • a – one vector

  • b – another vector

Returns

dot product a x b

double pitch_between(const Vector3 &a, const Vector3 &b)#

Pitch between two 3-Vectors

Parameters
  • a – one vector

  • b – another vector

Returns

dot product a x b

Vector3 get_position(const State &x)#

Get position form a state

Parameters

x – state

Returns

position

Vector3 get_velocity(const State &x)#

Get velocity form a state

Parameters

x – state

Returns

velocity

inline Vector3 cyl2cart(const Vector3 &v, double theta)#

Convert vector from cylindrical coordinates to cartesian

Parameters
  • v – cylindrical vector

  • r – cylindrical position

Returns

vector in cartesian

inline Vector3 cart2cyl(const Vector3 &v, double theta)#

Convert vector from cartesian coordinates to cylindrical

Parameters
  • v – cartesian vector

  • r – cylindrical position

Returns

vector in cylindrical

inline Vector3 cyl2cart(const Vector3 &r)#

Convert from cylindrical coordinates to cartesian

Parameters

r – cylindrical vcoordinates

Returns

cartesian coordinates

inline Vector3 cart2cyl(const Vector3 &r)#

Convert from cartesian coordinates to cylindrical

Parameters

r – cartesian coordinates

Returns

cylindrical coordinates