FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
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 path.h
10 * @brief Provides the definition and functionality of the Path class
11 * for handling coordinate-based paths with different interpolation types.
12 */
13
14#pragma once
15
16#include <cstdint>
17#include <vector>
18
19#include "coord.h"
20#include "core/config.h"
21
22namespace math
23{
24 class Vec3;
25
26 /**
27 * @class Path
28 * @brief Represents a path with coordinates and allows for various interpolation methods.
29 */
30 class Path
31 {
32 public:
33 /**
34 * @brief Types of interpolation supported by the Path class.
35 */
36 enum class InterpType : std::uint8_t
37 {
38 INTERP_STATIC, ///< Hold the first coordinate for all query times.
39 INTERP_LINEAR, ///< Linearly interpolate between neighboring coordinates.
40 INTERP_CUBIC ///< Cubically interpolate between neighboring coordinates.
41 };
42
43 /**
44 * @brief Constructs a Path object with a specified interpolation type.
45 *
46 * @param type The interpolation type (default is INTERP_STATIC).
47 */
48 explicit Path(const InterpType type = InterpType::INTERP_STATIC) noexcept : _type(type) {}
49
50 ~Path() = default;
51
52 Path(const Path&) = delete;
53
54 Path(Path&&) = delete;
55
56 Path& operator=(const Path&) = delete;
57
58 Path& operator=(Path&&) = delete;
59
60 /**
61 * @brief Adds a coordinate to the path.
62 *
63 * @param coord The coordinate to be added.
64 */
65 void addCoord(const Coord& coord) noexcept;
66
67 /**
68 * @brief Finalizes the path, preparing it for interpolation.
69 */
70 void finalize();
71
72 /**
73 * @brief Retrieves the current interpolation type of the path.
74 *
75 * @return The interpolation type of the path.
76 */
77 [[nodiscard]] InterpType getType() const noexcept { return _type; }
78
79 /**
80 * @brief Gets the list of coordinates in the path.
81 *
82 * @return A constant reference to the vector of coordinates.
83 */
84 [[nodiscard]] const std::vector<Coord>& getCoords() const noexcept { return _coords; }
85
86 /**
87 * @brief Retrieves the position at a given time along the path.
88 *
89 * @param t The time parameter at which to get the position.
90 * @return The interpolated position as a Vec3 object.
91 * @throws PathException If finalize() has not been called before this method.
92 */
94
95 /**
96 * @brief Retrieves the velocity at a given time along the path.
97 *
98 * @param t The time parameter at which to get the velocity.
99 * @return The interpolated velocity as a Vec3 object.
100 * @throws PathException If finalize() has not been called before this method.
101 */
102 [[nodiscard]] Vec3 getVelocity(RealType t) const;
103
104 /**
105 * @brief Changes the interpolation type.
106 *
107 * @param settype The new interpolation type to be used.
108 */
109 void setInterp(InterpType settype) noexcept;
110
111 private:
112 std::vector<Coord> _coords; ///< The list of coordinates in the path.
113 std::vector<Coord> _dd; ///< The list of second derivatives for cubic interpolation.
114 bool _final{false}; ///< Flag indicating whether the path has been finalized.
115 InterpType _type; ///< The current interpolation type of the path.
116 };
117}
Represents a path with coordinates and allows for various interpolation methods.
Definition path.h:31
Vec3 getPosition(RealType t) const
Retrieves the position at a given time along the path.
Definition path.cpp:36
Path(const Path &)=delete
const std::vector< Coord > & getCoords() const noexcept
Gets the list of coordinates in the path.
Definition path.h:84
Path(Path &&)=delete
Path & operator=(const Path &)=delete
Path(const InterpType type=InterpType::INTERP_STATIC) noexcept
Constructs a Path object with a specified interpolation type.
Definition path.h:48
InterpType
Types of interpolation supported by the Path class.
Definition path.h:37
@ INTERP_STATIC
Hold the first coordinate for all query times.
@ INTERP_LINEAR
Linearly interpolate between neighboring coordinates.
@ INTERP_CUBIC
Cubically interpolate between neighboring coordinates.
Path & operator=(Path &&)=delete
~Path()=default
void setInterp(InterpType settype) noexcept
Changes the interpolation type.
Definition path.cpp:164
Vec3 getVelocity(RealType t) const
Retrieves the velocity at a given time along the path.
Definition path.cpp:60
void addCoord(const Coord &coord) noexcept
Adds a coordinate to the path.
Definition path.cpp:27
InterpType getType() const noexcept
Retrieves the current interpolation type of the path.
Definition path.h:77
void finalize()
Finalizes the path, preparing it for interpolation.
Definition path.cpp:147
A class representing a vector in rectangular coordinates.
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
Coordinate and rotation structure operations.
Definition coord.h:18
math::Vec3 max
Represents a position in 3D space with an associated time.
Definition coord.h:24