mpri-graphics-project/spheroid.hpp

37 lines
1 KiB
C++

/**
* Defines an ellispoid, which is a basic interpretaion of the ball when it is
* bouncing.
**/
#include <cstddef>
#include <cmath>
#include "Implicit.hpp"
#include "common_structures.hpp"
const double PI = 3.141592653589793;
class Spheroid : public ImplicitSurface {
public:
Spheroid(Point& _center, size_t _p, size_t _q);
void update_center_pos(Point& _center);
void update_radius();
void set_stiffness(size_t _stiffness);
double operator() (double _x, double _y, double _z) {
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);
}
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;
double p, q;
double V;
Point& center;
void _compute_volume();
};