1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
class Particle {
public:
std::string Name; /**< The particle's name. */
sf::Color Color; /**< The particle's colour. */
sf::Vector2f Position; /**< The position vector. */
sf::Vector2f Velocity; /**< The velocity (m s^-1). */
sf::Vector2f Acceleration; /**< The acceleration (m s^-2). */
const unsigned RestMass; /**< The rest mass (kg). */
const double Radius; /**< The radius (m). */
unsigned Mass; /**< The relativistic mass (kg). */
/**
* \brief Constructor.
* \param name The particle's name.
* \param color The particle's colour.
* \param pos The initial position.
* \param mass The particle's (rest) mass.
* \param radius The particle's radius.
* \param veloc (optional) The initial velocity.
* \param accel (optional) The initial acceleration.
*/
Particle(std::string name, sf::Color color, sf::Vector2f pos,
unsigned mass, double radius,
sf::Vector2f veloc = sf::Vector2f(0, 0),
sf::Vector2f accel = sf::Vector2f(0, 0));
/**
* \brief Calculates the magnitude of a vector.
* \param vector The vector.
* \return The magnitude of the vector.
*/
double GetVectorMagnitude(sf::Vector2f vector);
/**
* \brief Calculates the kinetic energy.
* \return The kinetic energy.
*/
double GetKineticEnergy();
/**
* \brief Checks whether the particle is inside of a circle.
* \param circle The circle.
* \return If the particle is inside the circle, true is returned.
* Otherwise, false is returned.
*/
bool InsideCircle(sf::Shape circle);
/**
* \brief Checks whether the particle is on the circumference of a
* circle.
* \param circle The circle.
* \return If the particle is on the circle, true is returned.
* Otherwise, false is returned.
*/
bool OnCircle(sf::Shape circle);
/**
* \brief Checks whether the particle is outside of a circle.
* \return If the particle is outside of the circle, true is
* returned. Otherwise, false is returned.
*/
bool OutsideCircle(sf::Shape circle);
/**
* \brief Update the particle.
* \param time The time in seconds since the last call to Update or
* since construction, whichever is more recent.
* \param inner The inner circle.
* \param outer The outer circle. The particle must be in between the
* inner and outer circles.
* \return Whether the particle is in a valid position: if the
* particle goes outside of the inner or outer circle,
* false is returned. Otherwise, true is returned.
*/
bool Update(double time, sf::Shape inner, sf::Shape outer);
};
|