QtRocket
 
Loading...
Searching...
No Matches
Rocket.h
Go to the documentation of this file.
1#ifndef ROCKET_H
2#define ROCKET_H
3
4#include <string>
5#include <vector>
6#include <memory> // for smart pointers
7
8// Forward declarations to keep compile times fast
9class Stage;
10class FlightState;
11class Environment;
12
20class Rocket {
21public:
26 Rocket(const std::string& name);
27
31 ~Rocket() = default;
32
37 double getTotalMass() const;
38
43 double getTotalPropellantMass() const;
44
49 double getCenterOfGravity() const;
50
55 double getCenterOfPressure() const;
56
65 double getStabilityMargin() const;
66
71 void addStage(std::unique_ptr<Stage> stage);
72
77 const std::vector<std::unique_ptr<Stage>>& getStages() const;
78
85
93 void prepareForFlight(const Environment& env);
94
102 void applyFlightState(const FlightState& state);
103
108 const std::string& getName() const;
109
114 void setName(const std::string& name);
115
116private:
117 std::string name_;
118 std::vector<std::unique_ptr<Stage>> stages_;
119
120 // Cached mass properties (updated by updateMassProperties())
121 double totalMass_;
125};
126
127#endif // ROCKET_H
Models atmospheric and gravitational conditions for the flight simulation.
Definition Environment.h:10
Represents the physical state of the rocket at a given simulation time.
Definition FlightState.h:12
double totalPropellantMass_
Total remaining propellant mass [kg].
Definition Rocket.h:122
double getTotalPropellantMass() const
Returns the total remaining propellant mass of all motors.
Definition Rocket.cpp:27
const std::string & getName() const
Gets the name of the rocket.
Definition Rocket.cpp:107
std::vector< std::unique_ptr< Stage > > stages_
List of rocket stages.
Definition Rocket.h:118
void updateMassProperties()
Recalculates total mass, CG, CP, and stability margin.
Definition Rocket.cpp:53
double centerOfPressure_
Center of pressure location [m].
Definition Rocket.h:124
std::string name_
Name of the rocket.
Definition Rocket.h:117
void addStage(std::unique_ptr< Stage > stage)
Adds a new stage to the rocket.
Definition Rocket.cpp:45
double getCenterOfPressure() const
Returns the current center of pressure (CP) of the rocket.
Definition Rocket.cpp:35
const std::vector< std::unique_ptr< Stage > > & getStages() const
Returns a const reference to the list of stages.
Definition Rocket.cpp:49
void setName(const std::string &name)
Sets the name of the rocket.
Definition Rocket.cpp:111
Rocket(const std::string &name)
Constructs a new Rocket with a given name.
Definition Rocket.cpp:13
double totalMass_
Total mass of the rocket [kg].
Definition Rocket.h:121
void prepareForFlight(const Environment &env)
Prepares the rocket for flight simulation.
Definition Rocket.cpp:95
double getTotalMass() const
Returns the total mass of the rocket (including all stages and payloads).
Definition Rocket.cpp:23
void applyFlightState(const FlightState &state)
Applies a given flight state to the rocket.
Definition Rocket.cpp:101
double getCenterOfGravity() const
Returns the current center of gravity (CG) of the rocket.
Definition Rocket.cpp:31
~Rocket()=default
Default destructor.
double centerOfGravity_
Center of gravity location [m].
Definition Rocket.h:123
double getStabilityMargin() const
Calculates the rocket's stability margin.
Definition Rocket.cpp:39
Represents a single stage of a (potentially) multi-stage rocket.
Definition Stage.h:21