FERS 1.0.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 <vector>
17
18#include "coord.h"
19#include "core/config.h"
20
21namespace math
22{
23 class Vec3;
24
25 /**
26 * @class Path
27 * @brief Represents a path with coordinates and allows for various interpolation methods.
28 */
29 class Path
30 {
31 public:
32 /**
33 * @brief Types of interpolation supported by the Path class.
34 */
35 enum class InterpType
36 {
40 };
41
42 /**
43 * @brief Constructs a Path object with a specified interpolation type.
44 *
45 * @param type The interpolation type (default is INTERP_STATIC).
46 */
47 explicit Path(const InterpType type = InterpType::INTERP_STATIC) noexcept : _type(type) {}
48
49 ~Path() = default;
50
51 Path(const Path&) = delete;
52
53 Path(Path&&) = delete;
54
55 Path& operator=(const Path&) = delete;
56
57 Path& operator=(Path&&) = delete;
58
59 /**
60 * @brief Adds a coordinate to the path.
61 *
62 * @param coord The coordinate to be added.
63 */
64 void addCoord(const Coord& coord) noexcept;
65
66 /**
67 * @brief Finalizes the path, preparing it for interpolation.
68 */
69 void finalize();
70
71 /**
72 * @brief Retrieves the current interpolation type of the path.
73 *
74 * @return The interpolation type of the path.
75 */
76 [[nodiscard]] InterpType getType() const noexcept { return _type; }
77
78 /**
79 * @brief Gets the list of coordinates in the path.
80 *
81 * @return A constant reference to the vector of coordinates.
82 */
83 [[nodiscard]] const std::vector<Coord>& getCoords() const noexcept { return _coords; }
84
85 /**
86 * @brief Retrieves the position at a given time along the path.
87 *
88 * @param t The time parameter at which to get the position.
89 * @return The interpolated position as a Vec3 object.
90 * @throws PathException If finalize() has not been called before this method.
91 */
92 [[nodiscard]] Vec3 getPosition(RealType t) const;
93
94 /**
95 * @brief Retrieves the velocity at a given time along the path.
96 *
97 * @param t The time parameter at which to get the velocity.
98 * @return The interpolated velocity as a Vec3 object.
99 * @throws PathException If finalize() has not been called before this method.
100 */
101 [[nodiscard]] Vec3 getVelocity(RealType t) const;
102
103 /**
104 * @brief Changes the interpolation type.
105 *
106 * @param settype The new interpolation type to be used.
107 */
108 void setInterp(InterpType settype) noexcept;
109
110 private:
111 std::vector<Coord> _coords; ///< The list of coordinates in the path.
112 std::vector<Coord> _dd; ///< The list of second derivatives for cubic interpolation.
113 bool _final{false}; ///< Flag indicating whether the path has been finalized.
114 InterpType _type; ///< The current interpolation type of the path.
115 };
116}
Represents a path with coordinates and allows for various interpolation methods.
Definition path.h:30
Vec3 getPosition(RealType t) const
Retrieves the position at a given time along the path.
Definition path.cpp:35
Path(const Path &)=delete
const std::vector< Coord > & getCoords() const noexcept
Gets the list of coordinates in the path.
Definition path.h:83
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:47
Path & operator=(Path &&)=delete
~Path()=default
void setInterp(InterpType settype) noexcept
Changes the interpolation type.
Definition path.cpp:158
InterpType
Types of interpolation supported by the Path class.
Definition path.h:36
Vec3 getVelocity(RealType t) const
Retrieves the velocity at a given time along the path.
Definition path.cpp:59
void addCoord(const Coord &coord) noexcept
Adds a coordinate to the path.
Definition path.cpp:26
InterpType getType() const noexcept
Retrieves the current interpolation type of the path.
Definition path.h:76
void finalize()
Finalizes the path, preparing it for interpolation.
Definition path.cpp:141
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
Represents a position in 3D space with an associated time.
Definition coord.h:24