#ifndef FLIGHTSTATE_H
#define FLIGHTSTATE_H

#include <array>

/**
 * @brief Represents the physical state of the rocket at a given simulation time.
 *
 * The FlightState contains position, velocity, acceleration, orientation,
 * and angular velocity information, future-proofed for 6-DoF dynamics.
 */
class FlightState {
public:
    /**
     * @brief Default constructor. Initializes to zero state.
     */
    FlightState();

    /**
     * @brief Gets the current position vector.
     * @return Position (x, y, z) in meters.
     */
    const std::array<double, 3>& getPosition() const;

    /**
     * @brief Sets the current position vector.
     * @param pos Position (x, y, z) in meters.
     */
    void setPosition(const std::array<double, 3>& pos);

    /**
     * @brief Gets the current velocity vector.
     * @return Velocity (vx, vy, vz) in meters per second.
     */
    const std::array<double, 3>& getVelocity() const;

    /**
     * @brief Sets the current velocity vector.
     * @param vel Velocity (vx, vy, vz) in meters per second.
     */
    void setVelocity(const std::array<double, 3>& vel);

    /**
     * @brief Gets the current acceleration vector.
     * @return Acceleration (ax, ay, az) in meters per second squared.
     */
    const std::array<double, 3>& getAcceleration() const;

    /**
     * @brief Sets the current acceleration vector.
     * @param acc Acceleration (ax, ay, az) in meters per second squared.
     */
    void setAcceleration(const std::array<double, 3>& acc);

    /**
     * @brief Gets the current orientation quaternion.
     * @return Orientation quaternion (w, x, y, z).
     */
    const std::array<double, 4>& getOrientation() const;

    /**
     * @brief Sets the current orientation quaternion.
     * @param quat Orientation quaternion (w, x, y, z).
     */
    void setOrientation(const std::array<double, 4>& quat);

    /**
     * @brief Gets the current angular velocity vector.
     * @return Angular velocity (roll rate, pitch rate, yaw rate) in radians per second.
     */
    const std::array<double, 3>& getAngularVelocity() const;

    /**
     * @brief Sets the current angular velocity vector.
     * @param angVel Angular velocity (roll rate, pitch rate, yaw rate) in radians per second.
     */
    void setAngularVelocity(const std::array<double, 3>& angVel);

    /**
     * @brief Gets the elapsed simulation time.
     * @return Elapsed time in seconds.
     */
    double getTime() const;

    /**
     * @brief Sets the elapsed simulation time.
     * @param time Time in seconds.
     */
    void setTime(double time);

private:
    std::array<double, 3> position_; ///< (x, y, z) position in meters.
    std::array<double, 3> velocity_; ///< (vx, vy, vz) velocity in m/s.
    std::array<double, 3> acceleration_; ///< (ax, ay, az) acceleration in m/s2.

    std::array<double, 4> orientation_; ///< Orientation quaternion (w, x, y, z).
    std::array<double, 3> angularVelocity_; ///< Angular rates (roll, pitch, yaw) in rad/s.

    double time_; ///< Elapsed simulation time [s].
};

#endif // FLIGHTSTATE_H