diff --git a/ellipsoid.cpp b/ellipsoid.cpp new file mode 100644 index 0000000..7b43416 --- /dev/null +++ b/ellipsoid.cpp @@ -0,0 +1,18 @@ +/** + * Implementation of an ellipsoid + **/ + +#include "ellipsoid.hpp" + +Ellipsoid::Ellipsoid(Point& _center, size_t _p, size_t _q) : + center(_center), p(_p), q(_q), stiffness(0) { + _compute_volume(); + } + +void Ellipsoid::_compute_volume() { + V = (4/3) * PI * p * q * q; +} + +void Ellipsoid::set_stiffness(size_t _stiffness) { + stiffness = _stiffness; +} diff --git a/ellipsoid.hpp b/ellipsoid.hpp new file mode 100644 index 0000000..f4eea39 --- /dev/null +++ b/ellipsoid.hpp @@ -0,0 +1,30 @@ +/** + * Defines an ellispoid, which is a basic interpretaion of the ball when it is + * bouncing. + **/ + +#include +#include "Implicit.hpp" +#include "common_structures.hpp" + +const double PI = 3.141592653589793; + +class Ellipsoid : public ImplicitSurface { + public: + Ellipsoid(Point& _center, size_t _p, size_t _q); + void update_center_pos(size_t dt); + void set_stiffness(size_t _stiffness); + private: + /** + * p corresponds to the half-height of the ball, + * q to the radius of the ball, + * V is the volume. Extremely useful to have a constant volume in the + * ball + **/ + size_t stiffness; + size_t p, q; + double V; + Point& center; + void _compute_volume(); + void _compute_pos(size_t t); +};