diff --git a/Colour.h b/Colour.h index 64167b6..47470a2 100755 --- a/Colour.h +++ b/Colour.h @@ -7,37 +7,181 @@ * */ +/** + * @class Colour + * @brief Represents a colour with red, green, blue, and alpha (transparency) components. + * + * This class provides a way to store and manipulate RGBA colour values, typically used + * for rendering planets and celestial objects in the Solar system visualization. + * Component values are internally stored as floats normalized to the range [0.0, 1.0]. + */ class Colour { - float red; - float green; - float blue; - float alpha; + float red; ///< Red component, normalized to range [0.0, 1.0] + float green; ///< Green component, normalized to range [0.0, 1.0] + float blue; ///< Blue component, normalized to range [0.0, 1.0] + float alpha; ///< Alpha (transparency) component, normalized to range [0.0, 1.0] public: + /** + * @brief Default constructor. + * Initializes a black colour with full opacity (red=0, green=0, blue=0, alpha=1). + */ Colour(); + + /** + * @brief Destructor. + */ ~Colour(); + + /** + * @brief Copy constructor. + * @param copyMe The Colour object to copy from. + */ Colour(const Colour& copyMe); + + /** + * @brief Assignment operator. + * @param assignFromMe The Colour object to assign from. + * @return Reference to this object. + */ Colour& operator=(const Colour& assignFromMe); + + /** + * @brief Addition operator for colour blending. + * @param otherColour The colour to add to this colour. + * @return A new Colour object with component-wise addition (capped at 1.0). + */ Colour operator+(const Colour& otherColour) const; + + /** + * @brief Constructor with float components. + * @param newRed Red component value. + * @param newGreen Green component value. + * @param newBlue Blue component value. + * @param newAlpha Alpha component value (default: 1.0). + * @param limit The maximum value for normalization (default: 1.0). + * All components are divided by this value to normalize to [0.0, 1.0]. + */ Colour(float newRed, float newGreen, float newBlue, float newAlpha = 1.0f, float limit = 1.0f); + + /** + * @brief Constructor with unsigned short components. + * @param newRed Red component value. + * @param newGreen Green component value. + * @param newBlue Blue component value. + * @param newAlpha Alpha component value (default: 255). + * @param limit The maximum value for normalization (default: 255). + * All components are divided by this value to normalize to [0.0, 1.0]. + */ Colour(unsigned short newRed, unsigned short newGreen, unsigned short newBlue, unsigned short newAlpha = 255u, unsigned short limit = 255u); + /** + * @brief Gets the red component. + * @return The red component as a float in the range [0.0, 1.0]. + */ float getRedComponent() const; + + /** + * @brief Gets the green component. + * @return The green component as a float in the range [0.0, 1.0]. + */ float getGreenComponent() const; + + /** + * @brief Gets the blue component. + * @return The blue component as a float in the range [0.0, 1.0]. + */ float getBlueComponent() const; + + /** + * @brief Gets the alpha (transparency) component. + * @return The alpha component as a float in the range [0.0, 1.0]. + */ float getAlphaComponent() const; + + /** + * @brief Sets the red component using a float value. + * @param newRed The new red component value (should be in range [0.0, 1.0]). + * @return The value that was set. + */ float setRedComponent(float newRed); + + /** + * @brief Sets the green component using a float value. + * @param newGreen The new green component value (should be in range [0.0, 1.0]). + * @return The value that was set. + */ float setGreenComponent(float newGreen); + + /** + * @brief Sets the blue component using a float value. + * @param newBlue The new blue component value (should be in range [0.0, 1.0]). + * @return The value that was set. + */ float setBlueComponent(float newBlue); + + /** + * @brief Sets the alpha component using a float value. + * @param newAlpha The new alpha component value (should be in range [0.0, 1.0]). + * @return The value that was set. + */ float setAlphaComponent(float newAlpha); + + /** + * @brief Sets all RGBA components using float values. + * @param newRed Red component value. + * @param newGreen Green component value. + * @param newBlue Blue component value. + * @param newAlpha Alpha component value. + * @param limit The maximum value for normalization. All components are divided by this value. + * @return Pointer to this object. + */ Colour* setRGBA(float newRed, float newGreen, float newBlue, float newAlpha, float limit); + + /** + * @brief Sets the red component using an unsigned short value. + * @param newRed The new red component value. + * @param limit The maximum value for normalization (default: 255). + * @return The input value that was provided. + */ unsigned short setRedComponent(unsigned short newRed, unsigned short limit = 255u); + + /** + * @brief Sets the green component using an unsigned short value. + * @param newGreen The new green component value. + * @param limit The maximum value for normalization (default: 255). + * @return The input value that was provided. + */ unsigned short setGreenComponent(unsigned short newGreen, unsigned short limit = 255u); + + /** + * @brief Sets the blue component using an unsigned short value. + * @param newBlue The new blue component value. + * @param limit The maximum value for normalization (default: 255). + * @return The input value that was provided. + */ unsigned short setBlueComponent(unsigned short newBlue, unsigned short limit = 255u); + + /** + * @brief Sets the alpha component using an unsigned short value. + * @param newAlpha The new alpha component value. + * @param limit The maximum value for normalization (default: 255). + * @return The input value that was provided. + */ unsigned short setAlphaComponent(unsigned short newAlpha, unsigned short limit = 255u); + + /** + * @brief Sets all RGBA components using unsigned short values. + * @param newRed Red component value. + * @param newGreen Green component value. + * @param newBlue Blue component value. + * @param newAlpha Alpha component value (default: 255). + * @param limit The maximum value for normalization (default: 255). + * @return Pointer to this object. + */ Colour* setRGBA(unsigned short newRed, unsigned short newGreen, unsigned short newBlue, unsigned short newAlpha = 255u, unsigned short limit = 255u); }; \ No newline at end of file diff --git a/Planet.h b/Planet.h index a612119..960b2e2 100755 --- a/Planet.h +++ b/Planet.h @@ -11,58 +11,227 @@ using std::string; +/** + * @class Planet + * @brief Represents a planet in the solar system with physical and orbital properties. + * + * This class encapsulates all the information needed to render and simulate a planet + * in a solar system visualization, including its orbital characteristics, physical + * properties, appearance, and satellite count. + */ class Planet { private : + /** + * @class Orbit + * @brief Nested class representing the orbital characteristics of a planet. + * + * Contains information about a planet's elliptical orbit around the sun, + * including its closest and farthest distances, orbital period, and inclination. + */ class Orbit { public : - double aphelion; - double perihelion; - float period; - float inclination; + double aphelion; ///< Farthest distance from the sun (in AU or appropriate units) + double perihelion; ///< Closest distance from the sun (in AU or appropriate units) + float period; ///< Orbital period (time to complete one orbit around the sun) + float inclination; ///< Orbital inclination relative to the ecliptic plane (in degrees) + /** + * @brief Default constructor. + * Initializes all orbital parameters to zero. + */ Orbit(); + + /** + * @brief Constructor that copies from an existing Orbit object. + * @param newOrbit Pointer to the Orbit object to copy from. + * @note This is not a standard copy constructor as it takes a pointer. + */ Orbit(const Orbit* newOrbit); + /** + * @brief Calculates the average orbital distance. + * @return The average distance between aphelion and perihelion. + */ double getAverageDistance() const; + + /** + * @brief Gets the aphelion distance. + * @return The farthest distance from the sun. + */ double getAphelion() const; + + /** + * @brief Sets the aphelion distance. + * @param newAphelion The new aphelion value. + * @return The value that was set. + */ double setAphelion(double newAphelion); + + /** + * @brief Gets the perihelion distance. + * @return The closest distance from the sun. + */ double getPerihelion() const; + + /** + * @brief Sets the perihelion distance. + * @param newPerihelion The new perihelion value. + * @return The value that was set. + */ double setPerihelion(double newPerihelion); + + /** + * @brief Gets the orbital period. + * @return The time to complete one orbit. + */ float getPeriod() const; + + /** + * @brief Sets the orbital period. + * @param newPeriod The new orbital period value. + * @return The value that was set. + */ float setPeriod(float newPeriod); + + /** + * @brief Gets the orbital inclination. + * @return The inclination angle in degrees. + */ float getInclination() const; + + /** + * @brief Sets the orbital inclination. + * @param newInclination The new inclination angle in degrees. + * @return The value that was set. + */ float setInclination(float newInclination); }; - string name; - Orbit *orbit; - float radius; - float period; - float axialTilt; - Colour *colour; - int satellites; + string name; ///< Name of the planet (e.g., "Earth", "Mars") + Orbit *orbit; ///< Pointer to the orbital characteristics + float radius; ///< Radius of the planet (in km or appropriate units) + float period; ///< Rotational period (time for one complete rotation) + float axialTilt; ///< Axial tilt relative to the orbital plane (in degrees) + Colour *colour; ///< Visual colour of the planet for rendering + int satellites; ///< Number of natural satellites (moons) public : + /** + * @brief Default constructor. + * Initializes a planet with default values and allocates memory for orbit and colour. + */ Planet(); + + /** + * @brief Destructor. + * Cleans up dynamically allocated memory for orbit and colour. + */ ~Planet(); + + /** + * @brief Copy constructor. + * @param copyMe The Planet object to copy from. + */ Planet(const Planet& copyMe); + + /** + * @brief Assignment operator. + * @param assignFromMe The Planet object to assign from. + * @return Reference to this object. + */ Planet& operator=(const Planet& assignFromMe); + /** + * @brief Gets the planet's name. + * @return The name of the planet. + */ string getName() const; + + /** + * @brief Sets the planet's name. + * @param newName The new name for the planet. + * @return The name that was set. + */ string setName(string newName); + + /** + * @brief Gets the orbital characteristics. + * @return Pointer to the Orbit object. + */ Orbit* getOrbit() const; + + /** + * @brief Sets the orbital characteristics. + * @param newOrbit Pointer to a new Orbit object. + * @return Pointer to the orbit that was set. + */ Orbit* setOrbit(Orbit *newOrbit); + + /** + * @brief Gets the planet's radius. + * @return The radius of the planet. + */ float getRadius() const; + + /** + * @brief Sets the planet's radius. + * @param newRadius The new radius value. + * @return The radius that was set. + */ float setRadius(float newRadius); + + /** + * @brief Gets the rotational period. + * @return The time for one complete rotation. + */ float getPeriod() const; + + /** + * @brief Sets the rotational period. + * @param newPeriod The new rotational period value. + * @return The period that was set. + */ float setPeriod(float newPeriod); + + /** + * @brief Gets the axial tilt. + * @return The axial tilt in degrees. + */ float getAxialTilt() const; + + /** + * @brief Sets the axial tilt. + * @param newAxialTilt The new axial tilt value in degrees. + * @return The axial tilt that was set. + */ float setAxialTilt(float newAxialTilt); + + /** + * @brief Gets the planet's colour. + * @return Pointer to the Colour object. + */ Colour* getColour() const; + + /** + * @brief Sets the planet's colour. + * @param newColour Pointer to a new Colour object. + * @return Pointer to the colour that was set. + */ Colour* setColour(Colour *newColour); + + /** + * @brief Gets the number of satellites. + * @return The number of natural satellites (moons). + */ int getNumSatellites() const; + + /** + * @brief Sets the number of satellites. + * @param newNumSatellites The new number of satellites. + * @return The number that was set. + */ int setNumSatellites(int newNumSatellites); }; \ No newline at end of file diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +. \ No newline at end of file