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