2018-01-31 16:43:53 +01:00
|
|
|
/**
|
2018-02-11 17:29:17 +01:00
|
|
|
* Defines a spheroid, which is a basic interpretaion of the ball when it is
|
2018-01-31 16:43:53 +01:00
|
|
|
* bouncing.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <cstddef>
|
2018-02-07 15:07:59 +01:00
|
|
|
#include <cmath>
|
2018-01-31 16:43:53 +01:00
|
|
|
#include "Implicit.hpp"
|
|
|
|
#include "common_structures.hpp"
|
|
|
|
|
|
|
|
const double PI = 3.141592653589793;
|
|
|
|
|
2018-02-07 15:07:59 +01:00
|
|
|
class Spheroid : public ImplicitSurface {
|
2018-01-31 16:43:53 +01:00
|
|
|
public:
|
2018-02-07 15:07:59 +01:00
|
|
|
Spheroid(Point& _center, size_t _p, size_t _q);
|
|
|
|
void update_center_pos(Point& _center);
|
|
|
|
void update_radius();
|
2018-02-11 17:29:56 +01:00
|
|
|
void update_height();
|
2018-01-31 16:43:53 +01:00
|
|
|
void set_stiffness(size_t _stiffness);
|
2018-02-11 17:29:56 +01:00
|
|
|
void check_horizontal_plan_collision(double& height);
|
|
|
|
void check_vertical_plan_collision(double& abscissa);
|
2018-02-12 01:26:51 +01:00
|
|
|
double operator() (double _x, double _y, double _z) const {
|
2018-02-07 15:07:59 +01:00
|
|
|
return (pow(_x - center.x, 2) / pow(q, 2)
|
|
|
|
+ pow(_y - center.y, 2) / pow(q, 2)
|
|
|
|
+ pow(_z - center.z, 2) / pow(p, 2) -1);
|
|
|
|
}
|
2018-01-31 16:43:53 +01:00
|
|
|
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
|
|
|
|
**/
|
2018-02-12 12:08:50 +01:00
|
|
|
double init_p, p, q;
|
2018-02-07 15:18:53 +01:00
|
|
|
size_t stiffness;
|
2018-01-31 16:43:53 +01:00
|
|
|
double V;
|
|
|
|
void _compute_volume();
|
|
|
|
};
|