Rough implementation of an ellipsoid.

In an extremely simple model, the ball will deform as an ellipsoid
during the bounce process.
This commit is contained in:
Rémi Oudin 2018-01-31 16:43:53 +01:00
parent 88700c7c76
commit dae55f5eab
2 changed files with 48 additions and 0 deletions

18
ellipsoid.cpp Normal file
View file

@ -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;
}

30
ellipsoid.hpp Normal file
View file

@ -0,0 +1,30 @@
/**
* Defines an ellispoid, which is a basic interpretaion of the ball when it is
* bouncing.
**/
#include <cstddef>
#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);
};