Represents a rocket motor with thrust characteristics over time. More...
#include <Motor.h>
Public Member Functions | |
Motor (const std::string &name, double initialPropellantMass, double totalImpulse) | |
Constructs a new Motor with a given name and mass properties. | |
~Motor ()=default | |
Default destructor. | |
void | addThrustDataPoint (double time, double thrust) |
Adds a thrust curve data point. | |
void | ignite () |
Starts motor ignition (sets internal ignition time to zero). | |
void | update (double deltaTime) |
Updates the motor status based on elapsed time. | |
double | getCurrentThrust () const |
Gets the current thrust output. | |
bool | isBurnedOut () const |
Checks whether the motor has burned out. | |
double | getRemainingPropellantMass () const |
Returns the remaining propellant mass. | |
const std::string & | getName () const |
Gets the name of the motor. | |
Private Member Functions | |
double | interpolateThrust (double time) const |
Linearly interpolates thrust from the thrust curve. | |
Private Attributes | |
std::string | name_ |
Name of the motor. | |
double | initialPropellantMass_ |
Initial propellant mass [kg]. | |
double | remainingPropellantMass_ |
Current propellant mass [kg]. | |
double | totalImpulse_ |
Total impulse [Ns], used for sanity checks. | |
std::vector< std::pair< double, double > > | thrustCurve_ |
Thrust curve (time, thrust) points. | |
double | ignitionTime_ |
Elapsed time since ignition [s]. | |
bool | ignited_ |
Whether the motor has been ignited. | |
bool | burnedOut_ |
Whether the motor has finished burning. | |
double | currentThrust_ |
Cached current thrust [N]. | |
Represents a rocket motor with thrust characteristics over time.
The Motor class manages the thrust curve, ignition timing, burn duration, and remaining propellant mass of a single propulsion unit.
Motor::Motor | ( | const std::string & | name, |
double | initialPropellantMass, | ||
double | totalImpulse ) |
Constructs a new Motor with a given name and mass properties.
name | Name of the motor. |
initialPropellantMass | Initial mass of propellant (kg). |
totalImpulse | Total impulse (Ns) for basic verification. |
|
default |
Default destructor.
void Motor::addThrustDataPoint | ( | double | time, |
double | thrust ) |
Adds a thrust curve data point.
Should be called during setup. Time must be monotonically increasing.
time | Time since ignition (seconds). |
thrust | Thrust at this time (Newtons). |
double Motor::getCurrentThrust | ( | ) | const |
Gets the current thrust output.
const std::string & Motor::getName | ( | ) | const |
Gets the name of the motor.
double Motor::getRemainingPropellantMass | ( | ) | const |
Returns the remaining propellant mass.
void Motor::ignite | ( | ) |
Starts motor ignition (sets internal ignition time to zero).
|
private |
Linearly interpolates thrust from the thrust curve.
time | Time since ignition (seconds). |
bool Motor::isBurnedOut | ( | ) | const |
Checks whether the motor has burned out.
void Motor::update | ( | double | deltaTime | ) |
Updates the motor status based on elapsed time.
deltaTime | Time step in seconds. |
|
private |
Whether the motor has finished burning.
|
private |
Cached current thrust [N].
|
private |
Whether the motor has been ignited.
|
private |
Elapsed time since ignition [s].
|
private |
Initial propellant mass [kg].
|
private |
Name of the motor.
|
private |
Current propellant mass [kg].
|
private |
Thrust curve (time, thrust) points.
|
private |
Total impulse [Ns], used for sanity checks.