qtrocket2/include/ForcesModel.h
2025-04-20 12:29:36 -06:00

74 lines
2.3 KiB
C++

#ifndef FORCESMODEL_H
#define FORCESMODEL_H
#include <array>
#include <memory>
class Rocket;
class Environment;
class FlightState;
/**
* @brief Computes aerodynamic, thrust, and gravitational forces acting on the rocket.
*
* The ForcesModel provides force and moment outputs based on the current rocket state,
* environmental conditions, and rocket configuration.
*/
class ForcesModel {
public:
/**
* @brief Constructs a new ForcesModel.
* @param rocket Pointer to the rocket configuration.
* @param environment Pointer to the simulation environment.
*/
ForcesModel(std::shared_ptr<Rocket> rocket,
std::shared_ptr<Environment> environment);
/**
* @brief Default destructor.
*/
~ForcesModel() = default;
/**
* @brief Computes the net external force vector acting on the rocket.
* @param state Current flight state.
* @return Force vector (Fx, Fy, Fz) in Newtons.
*/
std::array<double, 3> computeNetForce(const FlightState& state) const;
/**
* @brief Computes the net external moment vector acting on the rocket.
*
* Initially returns zero (for 3-DoF), but structured for 6-DoF extension.
*
* @param state Current flight state.
* @return Moment vector (Mx, My, Mz) in Newton-meters.
*/
std::array<double, 3> computeNetMoment(const FlightState& state) const;
private:
std::shared_ptr<Rocket> rocket_; ///< Rocket model reference.
std::shared_ptr<Environment> environment_; ///< Atmospheric and gravity conditions.
/**
* @brief Computes aerodynamic drag force based on velocity and rocket configuration.
* @param state Current flight state.
* @return Drag force vector (Newton).
*/
std::array<double, 3> computeAerodynamicDrag(const FlightState& state) const;
/**
* @brief Computes thrust force based on motor outputs.
* @param state Current flight state.
* @return Thrust force vector (Newton).
*/
std::array<double, 3> computeThrust(const FlightState& state) const;
/**
* @brief Computes gravitational force based on altitude and mass.
* @param state Current flight state.
* @return Gravity force vector (Newton).
*/
std::array<double, 3> computeGravity(const FlightState& state) const;
};
#endif // FORCESMODEL_H