FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
math::RotationPath Class Reference

Manages rotational paths with different interpolation techniques. More...

#include "rotation_path.h"

Public Types

enum class  InterpType { INTERP_STATIC , INTERP_CONSTANT , INTERP_LINEAR , INTERP_CUBIC }
 Enumeration for types of interpolation. More...
 

Public Member Functions

 RotationPath (const InterpType type=InterpType::INTERP_STATIC) noexcept
 Constructor for RotationPath.
 
 ~RotationPath ()=default
 
 RotationPath (const RotationPath &)=delete
 
RotationPathoperator= (const RotationPath &)=delete
 
 RotationPath (RotationPath &&)=delete
 
RotationPathoperator= (RotationPath &&)=delete
 
void addCoord (const RotationCoord &coord) noexcept
 Adds a rotation coordinate to the path.
 
void finalize ()
 Finalizes the rotation path for interpolation.
 
const std::vector< RotationCoord > & getCoords () const noexcept
 Gets the list of rotation coordinates.
 
RotationCoord getStart () const noexcept
 Gets the starting rotation coordinate.
 
RotationCoord getRate () const noexcept
 Gets the rate of change for the rotation.
 
InterpType getType () const noexcept
 Gets the interpolation type of the path.
 
SVec3 getPosition (RealType t) const
 Gets the rotational position at a given time.
 
void setStart (const RotationCoord &start) noexcept
 Sets the starting rotation coordinate.
 
void setRate (const RotationCoord &rate) noexcept
 Sets the rate of change for the rotation.
 
void setInterp (InterpType setinterp) noexcept
 Sets the interpolation type for the path.
 
void setConstantRate (const RotationCoord &setstart, const RotationCoord &setrate) noexcept
 Sets constant rate interpolation.
 

Detailed Description

Manages rotational paths with different interpolation techniques.

Definition at line 27 of file rotation_path.h.

Member Enumeration Documentation

◆ InterpType

enum class math::RotationPath::InterpType
strong

Enumeration for types of interpolation.

Enumerator
INTERP_STATIC 
INTERP_CONSTANT 
INTERP_LINEAR 
INTERP_CUBIC 

Definition at line 34 of file rotation_path.h.

Constructor & Destructor Documentation

◆ RotationPath() [1/3]

math::RotationPath::RotationPath ( const InterpType  type = InterpType::INTERP_STATIC)
explicitnoexcept

Constructor for RotationPath.

Parameters
typeThe type of interpolation (default is static).

Definition at line 47 of file rotation_path.h.

47: _type(type) {}

◆ ~RotationPath()

math::RotationPath::~RotationPath ( )
default

◆ RotationPath() [2/3]

math::RotationPath::RotationPath ( const RotationPath )
delete

◆ RotationPath() [3/3]

math::RotationPath::RotationPath ( RotationPath &&  )
delete

Member Function Documentation

◆ addCoord()

void math::RotationPath::addCoord ( const RotationCoord coord)
noexcept

Adds a rotation coordinate to the path.

Parameters
coordThe rotation coordinate to be added.

Definition at line 24 of file rotation_path.cpp.

25 {
26 const auto iter = std::lower_bound(_coords.begin(), _coords.end(), coord);
27 _coords.insert(iter, coord);
28 _final = false;
29 }

Referenced by fers_get_interpolated_rotation_path(), and math::from_json().

+ Here is the caller graph for this function:

◆ finalize()

void math::RotationPath::finalize ( )

Finalizes the rotation path for interpolation.

Definition at line 61 of file rotation_path.cpp.

62 {
63 if (!_final)
64 {
65 if (_type == InterpType::INTERP_CUBIC)
66 {
67 finalizeCubic(_coords, _dd);
68 }
69 _final = true;
70 }
71 }
void finalizeCubic(const std::vector< T > &coords, std::vector< T > &dd)
Finalizes cubic spline interpolation by calculating second derivatives.
Definition path_utils.h:173

References finalizeCubic(), and INTERP_CUBIC.

Referenced by fers_get_interpolated_rotation_path(), and math::from_json().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCoords()

const std::vector< RotationCoord > & math::RotationPath::getCoords ( ) const
noexcept

Gets the list of rotation coordinates.

Returns
A const reference to the vector of rotation coordinates.

Definition at line 76 of file rotation_path.h.

76{ return _coords; }

◆ getPosition()

SVec3 math::RotationPath::getPosition ( RealType  t) const

Gets the rotational position at a given time.

Parameters
tThe time value for which to calculate the position.
Returns
The calculated position as an SVec3.
Exceptions
PathExceptionif the path has not been finalized.

Definition at line 31 of file rotation_path.cpp.

32 {
33 if (!_final)
34 {
35 throw PathException("Finalize not called before getPosition in RotationPath.");
36 }
37 RotationCoord coord{};
38
39 switch (_type)
40 {
42 getPositionStatic(coord, _coords);
43 break;
45 getPositionLinear(t, coord, _coords);
46 break;
48 getPositionCubic(t, coord, _coords, _dd);
49 break;
51 coord.azimuth = std::fmod(t * _rate.azimuth + _start.azimuth, 2 * PI);
52 coord.elevation = std::fmod(t * _rate.elevation + _start.elevation, 2 * PI);
53 break;
54 default:
55 throw PathException("Unknown interpolation type.");
56 }
57
58 return {1, coord.azimuth, coord.elevation};
59 }
constexpr RealType PI
Mathematical constant π (pi).
Definition config.h:43
void getPositionLinear(RealType t, T &coord, const std::vector< T > &coords)
Performs linear interpolation between coordinate points.
Definition path_utils.h:85
void getPositionStatic(T &coord, const std::vector< T > &coords)
Interpolates a static position from a list of coordinates.
Definition path_utils.h:66
void getPositionCubic(RealType t, T &coord, const std::vector< T > &coords, const std::vector< T > &dd)
Performs cubic spline interpolation between coordinate points.
Definition path_utils.h:128
RealType elevation
Elevation angle.
Definition coord.h:74
RealType azimuth
Azimuth angle.
Definition coord.h:73

References math::RotationCoord::azimuth, math::RotationCoord::elevation, getPositionCubic(), getPositionLinear(), getPositionStatic(), INTERP_CONSTANT, INTERP_CUBIC, INTERP_LINEAR, INTERP_STATIC, and PI.

Referenced by fers_get_interpolated_rotation_path().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRate()

RotationCoord math::RotationPath::getRate ( ) const
noexcept

Gets the rate of change for the rotation.

Returns
The rotation rate.

Definition at line 90 of file rotation_path.h.

90{ return _rate; }

◆ getStart()

RotationCoord math::RotationPath::getStart ( ) const
noexcept

Gets the starting rotation coordinate.

Returns
The starting rotation coordinate.

Definition at line 83 of file rotation_path.h.

83{ return _start; }

◆ getType()

InterpType math::RotationPath::getType ( ) const
noexcept

Gets the interpolation type of the path.

Returns
The interpolation type.

Definition at line 97 of file rotation_path.h.

97{ return _type; }

Referenced by radar::to_json().

+ Here is the caller graph for this function:

◆ operator=() [1/2]

RotationPath & math::RotationPath::operator= ( const RotationPath )
delete

◆ operator=() [2/2]

RotationPath & math::RotationPath::operator= ( RotationPath &&  )
delete

◆ setConstantRate()

void math::RotationPath::setConstantRate ( const RotationCoord setstart,
const RotationCoord setrate 
)
noexcept

Sets constant rate interpolation.

Parameters
setstartThe starting rotation coordinate.
setrateThe rate of change for the rotation.

Definition at line 79 of file rotation_path.cpp.

80 {
81 _start = setstart;
82 _rate = setrate;
84 _final = true;
85 }

◆ setInterp()

void math::RotationPath::setInterp ( InterpType  setinterp)
noexcept

Sets the interpolation type for the path.

Parameters
setinterpThe new interpolation type to be used.

Definition at line 73 of file rotation_path.cpp.

74 {
75 _type = setinterp;
76 _final = false;
77 }

Referenced by fers_get_interpolated_rotation_path(), and math::from_json().

+ Here is the caller graph for this function:

◆ setRate()

void math::RotationPath::setRate ( const RotationCoord rate)
noexcept

Sets the rate of change for the rotation.

Parameters
rateThe new rate of change for the rotation.

Definition at line 120 of file rotation_path.h.

120{ _rate = rate; }
RealType rate() noexcept
Get the rendering sample rate.
Definition parameters.h:109

◆ setStart()

void math::RotationPath::setStart ( const RotationCoord start)
noexcept

Sets the starting rotation coordinate.

Parameters
startThe new starting rotation coordinate.

Definition at line 113 of file rotation_path.h.

113{ _start = start; }

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