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

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

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

Inheritance diagram for spat::Vector< Valtype >:

Public Types

enum class  specials { null = -1 , ex = 0 , ey = 1 , ez = 2 }
 Identifiers for special vectors. More...
typedef Valtype value_type
using AngleType = decltype(Valtype{}/Valtype{})

Public Member Functions

Valtype * ptr () noexcept
 Pointer accessor for direct copying.
const Valtype * ptr () const noexcept
 Pointer accessor for direct copying.
VectorInit (specials s=specials::ex) noexcept
 Initializes the vector.
constexpr bool Is (specials s) const noexcept
 Test the vector to mach a special vector exactly.
constexpr Valtype Length () const noexcept
 Calculates the length of the vector.
auto Normalize () noexcept -> decltype(Valtype{}/Valtype{})
 Normalizes the vector to length 1.
constexpr bool IsNormal (Valtype epsilon_length=2 *std::numeric_limits< Valtype >::epsilon()) const noexcept
VectorRotate (const Vector< AngleType > &r, AngleType angle) noexcept
 Rotate this vector around unit vector r with angle in radiants.
VectorRotate (const Vector< AngleType > &r) noexcept
 Rotate this vector around r with angle r.Length() in radiants.
template<typename Valtype2>
constexpr Vector< Valtype > ParallelProjection (const Vector< Valtype2 > &normal) const noexcept
 Part of this Vector which is parallel to normal.
template<typename Valtype2>
constexpr Vector< Valtype > OrthogonalProjection (const Vector< Valtype2 > &normal) const noexcept
 Calculate part of this tVector wich is orthogonal to normal.
constexpr bool Equals (const Vector &v, Valtype epsilon=Valtype{0}) const noexcept
 Comparison within some range.
VectorRound (int toDigit) noexcept
 Rounds the vectors values to a certain digit after the point.
template<typename Valtype2>
Vector< Valtype > & operator= (const Valtype2 *pVal) noexcept
template<typename Valtype2>
Vector< Valtype > & operator= (const Vector2D< Valtype2 > &vector) noexcept
Construction
Parameters
dxcartesian x component.
dycartesian y component.
dzcartesian z component.
sOne of the specials values. Vector will be initialized accordingly.
pPosition for explicit conversion.
pValArray of three values.
constexpr Vector () noexcept=default
 Does not initialize the members.
constexpr Vector (Valtype dx, Valtype dy, Valtype dz) noexcept
 Does not initialize the members.
constexpr Vector (specials s) noexcept
 Does not initialize the members.
 Vector (const Position< Valtype > &p)=delete
 Conversions between Position and Vector shouldn't be necessary.
constexpr Vector (const Vector2D< Valtype > &v2D) noexcept
 Does not initialize the members.
template<typename Valtype2>
 Vector (const Valtype2 *pVal) noexcept
 Does not initialize the members.
Assignment
Parameters
pValArray of three values.
vectorsource vector
template<typename Valtype2>
Vectoroperator= (const Valtype2 *pVal) noexcept
template<typename Valtype2>
Vectoroperator= (const Vector2D< Valtype2 > &vector) noexcept
Subscripting.
Returns
Reference to value.
const Valtype & operator[] (size_t index) const
Valtype & operator[] (size_t index)
AircraftPrincipalAxes

Calculate the vector as normal vector from Yaw and Pitch.

If the dx,dy are small the yaw will be calculated to be zero.

Parameters
yawThe Yaw angle. The angle in the plane.
pitchThe Pitch angle. The angle vertical to a plane.
epsilonlength in x/y direction to ignore for yaw.
Returns
yaw, pitch, roll in a Position struct.
VectorAircraftPrincipalAxes (AngleType yaw, AngleType pitch)
VectorAircraftPrincipalAxes (const Position2D< AngleType > &angles)
Position2D< AngleType > AircraftPrincipalAxes (Valtype epsilon=std::numeric_limits< Valtype >::epsilon()) const

Public Attributes

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

Detailed Description

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

Implements a 3D - vector in cartesian coordinates.

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

Member Enumeration Documentation

◆ specials

template<typename Valtype>
enum class spat::Vector::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.

ez 

Unit vector in z-direction.

Member Function Documentation

◆ Equals()

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

Comparison within some range.

The area within two vectors regarded as equal is a sphere with radius epsilon. In case of a unit vector epsilon equals the angle between the two vectors, as long as epsilon is small.

Parameters
vVector 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>
Vector< Valtype > & spat::Vector< Valtype >::Init ( specials s = specials::ex)
inlinenoexcept

Initializes the vector.

Parameters
sType of vector to initialize with.

◆ Is()

template<typename Valtype>
bool spat::Vector< Valtype >::Is ( specials s) const
constexprnoexcept

Test the vector to mach a special vector exactly.

Parameters
sspecial type of vector to check.

◆ IsNormal()

template<typename Valtype>
bool spat::Vector< Valtype >::IsNormal ( Valtype epsilon_length = 2*std::numeric_limits<Valtype>::epsilon()) const
inlineconstexprnoexcept
Returns
true if the length of the vectr is 1 within the limits of epsilon.

◆ Length()

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

Calculates the length of the vector.

Returns
Length of vector.

◆ Normalize()

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

Normalizes the vector to length 1.

Returns
Previous length.

◆ OrthogonalProjection()

template<typename Valtype>
template<typename Valtype2>
Vector< Valtype > spat::Vector< Valtype >::OrthogonalProjection ( const Vector< Valtype2 > & 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>
template<typename Valtype2>
Vector< Valtype > spat::Vector< Valtype >::ParallelProjection ( const Vector< Valtype2 > & normal) const
inlineconstexprnoexcept

Part of this Vector which 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/Box.h
  • C:/Trend/Development/Trax3/Code/spat/Vector.h