FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
rotation_path.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2006-2008 Marc Brooker and Michael Inggs
4// Copyright (c) 2008-present FERS Contributors (see AUTHORS.md).
5//
6// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
7
8/**
9 * @file rotation_path.h
10 * @brief Defines the RotationPath class for handling rotational paths with different interpolation types.
11 */
12
13#pragma once
14
15#include <cstdint>
16#include <vector>
17
18#include "coord.h"
19#include "core/config.h"
20#include "geometry_ops.h"
21
22namespace math
23{
24 /**
25 * @class RotationPath
26 * @brief Manages rotational paths with different interpolation techniques.
27 */
29 {
30 public:
31 /**
32 * @enum InterpType
33 * @brief Enumeration for types of interpolation.
34 */
35 enum class InterpType : std::uint8_t
36 {
37 INTERP_STATIC, ///< Hold the first rotation for all query times.
38 INTERP_CONSTANT, ///< Hold the most recent rotation sample.
39 INTERP_LINEAR, ///< Linearly interpolate between neighboring rotations.
40 INTERP_CUBIC ///< Cubically interpolate between neighboring rotations.
41 };
42
43 /**
44 * @brief Constructor for RotationPath.
45 *
46 * @param type The type of interpolation (default is static).
47 */
48 explicit RotationPath(const InterpType type = InterpType::INTERP_STATIC) noexcept : _type(type) {}
49
50 ~RotationPath() = default;
51
52 RotationPath(const RotationPath&) = delete;
53
55
57
59
60 /**
61 * @brief Adds a rotation coordinate to the path.
62 *
63 * @param coord The rotation coordinate to be added.
64 */
65 void addCoord(const RotationCoord& coord) noexcept;
66
67 /**
68 * @brief Finalizes the rotation path for interpolation.
69 */
70 void finalize();
71
72 /**
73 * @brief Gets the list of rotation coordinates.
74 *
75 * @return A const reference to the vector of rotation coordinates.
76 */
77 [[nodiscard]] const std::vector<RotationCoord>& getCoords() const noexcept { return _coords; }
78
79 /**
80 * @brief Gets the starting rotation coordinate.
81 *
82 * @return The starting rotation coordinate.
83 */
85
86 /**
87 * @brief Gets the rate of change for the rotation.
88 *
89 * @return The rotation rate.
90 */
92
93 /**
94 * @brief Gets the interpolation type of the path.
95 *
96 * @return The interpolation type.
97 */
98 [[nodiscard]] InterpType getType() const noexcept { return _type; }
99
100 /**
101 * @brief Gets the rotational position at a given time.
102 *
103 * @param t The time value for which to calculate the position.
104 * @return The calculated position as an SVec3.
105 * @throws PathException if the path has not been finalized.
106 */
107 [[nodiscard]] SVec3 getPosition(RealType t) const;
108
109 /**
110 * @brief Sets the starting rotation coordinate.
111 *
112 * @param start The new starting rotation coordinate.
113 */
114 void setStart(const RotationCoord& start) noexcept { _start = start; }
115
116 /**
117 * @brief Sets the rate of change for the rotation.
118 *
119 * @param rate The new rate of change for the rotation.
120 */
121 void setRate(const RotationCoord& rate) noexcept { _rate = rate; }
122
123 /**
124 * @brief Sets the interpolation type for the path.
125 *
126 * @param setinterp The new interpolation type to be used.
127 */
128 void setInterp(InterpType setinterp) noexcept;
129
130 /**
131 * @brief Sets constant rate interpolation.
132 *
133 * @param setstart The starting rotation coordinate.
134 * @param setrate The rate of change for the rotation.
135 */
136 void setConstantRate(const RotationCoord& setstart, const RotationCoord& setrate) noexcept;
137
138 private:
139 std::vector<RotationCoord> _coords; ///< Vector of rotation coordinates in the path.
140 std::vector<RotationCoord> _dd; ///< Vector of second derivatives for cubic interpolation.
141 bool _final{false}; ///< Boolean flag to indicate whether the path has been finalized.
142 RotationCoord _start{}; ///< Starting rotation coordinate.
143 RotationCoord _rate{}; ///< Rate of change for constant interpolation.
144 InterpType _type{InterpType::INTERP_STATIC}; ///< Interpolation type used by the path.
145 };
146}
Manages rotational paths with different interpolation techniques.
void finalize()
Finalizes the rotation path for interpolation.
InterpType getType() const noexcept
Gets the interpolation type of the path.
RotationPath(const InterpType type=InterpType::INTERP_STATIC) noexcept
Constructor for RotationPath.
RotationPath & operator=(const RotationPath &)=delete
void setConstantRate(const RotationCoord &setstart, const RotationCoord &setrate) noexcept
Sets constant rate interpolation.
void setInterp(InterpType setinterp) noexcept
Sets the interpolation type for the path.
SVec3 getPosition(RealType t) const
Gets the rotational position at a given time.
void addCoord(const RotationCoord &coord) noexcept
Adds a rotation coordinate to the path.
RotationCoord getRate() const noexcept
Gets the rate of change for the rotation.
void setStart(const RotationCoord &start) noexcept
Sets the starting rotation coordinate.
RotationPath & operator=(RotationPath &&)=delete
RotationPath(RotationPath &&)=delete
InterpType
Enumeration for types of interpolation.
@ INTERP_STATIC
Hold the first rotation for all query times.
@ INTERP_LINEAR
Linearly interpolate between neighboring rotations.
@ INTERP_CONSTANT
Hold the most recent rotation sample.
@ INTERP_CUBIC
Cubically interpolate between neighboring rotations.
void setRate(const RotationCoord &rate) noexcept
Sets the rate of change for the rotation.
const std::vector< RotationCoord > & getCoords() const noexcept
Gets the list of rotation coordinates.
~RotationPath()=default
RotationCoord getStart() const noexcept
Gets the starting rotation coordinate.
RotationPath(const RotationPath &)=delete
A class representing a vector in spherical coordinates.
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
Coordinate and rotation structure operations.
Classes and operations for 3D geometry.
Definition coord.h:18
math::Vec3 max
Represents a rotation in terms of azimuth, elevation, and time.
Definition coord.h:72