Loading...
Searching...
No Matches
Motor.h
Go to the documentation of this file.
#ifndef MOTOR_H
#define MOTOR_H
#include <string>
#include <vector>
#include <utility> // for std::pair
class Motor {
public:
Motor(const std::string& name, double initialPropellantMass, double totalImpulse);
~Motor() = default;
void addThrustDataPoint(double time, double thrust);
void ignite();
void update(double deltaTime);
double getCurrentThrust() const;
bool isBurnedOut() const;
double getRemainingPropellantMass() const;
const std::string& getName() const;
private:
std::string name_;
double initialPropellantMass_;
double remainingPropellantMass_;
double totalImpulse_;
std::vector<std::pair<double, double>> thrustCurve_;
double ignitionTime_;
bool ignited_;
bool burnedOut_;
double currentThrust_;
double interpolateThrust(double time) const;
};
#endif // MOTOR_H
Motor::~Motor
~Motor()=default
Default destructor.
Motor::ignitionTime_
double ignitionTime_
Elapsed time since ignition [s].
Definition Motor.h:84
Motor::getCurrentThrust
double getCurrentThrust() const
Gets the current thrust output.
Definition Motor.cpp:56
Motor::burnedOut_
bool burnedOut_
Whether the motor has finished burning.
Definition Motor.h:86
Motor::ignited_
bool ignited_
Whether the motor has been ignited.
Definition Motor.h:85
Motor::isBurnedOut
bool isBurnedOut() const
Checks whether the motor has burned out.
Definition Motor.cpp:60
Motor::getName
const std::string & getName() const
Gets the name of the motor.
Definition Motor.cpp:68
Motor::ignite
void ignite()
Starts motor ignition (sets internal ignition time to zero).
Definition Motor.cpp:23
Motor::remainingPropellantMass_
double remainingPropellantMass_
Current propellant mass [kg].
Definition Motor.h:78
Motor::currentThrust_
double currentThrust_
Cached current thrust [N].
Definition Motor.h:88
Motor::addThrustDataPoint
void addThrustDataPoint(double time, double thrust)
Adds a thrust curve data point.
Definition Motor.cpp:19
Motor::interpolateThrust
double interpolateThrust(double time) const
Linearly interpolates thrust from the thrust curve.
Definition Motor.cpp:74
Motor::thrustCurve_
std::vector< std::pair< double, double > > thrustCurve_
Thrust curve (time, thrust) points.
Definition Motor.h:82
Motor::getRemainingPropellantMass
double getRemainingPropellantMass() const
Returns the remaining propellant mass.
Definition Motor.cpp:64
Motor::name_
std::string name_
Name of the motor.
Definition Motor.h:75
Motor::initialPropellantMass_
double initialPropellantMass_
Initial propellant mass [kg].
Definition Motor.h:77
Motor::Motor
Motor(const std::string &name, double initialPropellantMass, double totalImpulse)
Constructs a new Motor with a given name and mass properties.
Definition Motor.cpp:6
Motor::update
void update(double deltaTime)
Updates the motor status based on elapsed time.
Definition Motor.cpp:29
Motor::totalImpulse_
double totalImpulse_
Total impulse [Ns], used for sanity checks.
Definition Motor.h:80