mpri-graphics-project/spheroid.hpp

39 lines
1.1 KiB
C++
Raw Normal View History

/**
2018-02-11 17:29:17 +01:00
* Defines a spheroid, which is a basic interpretaion of the ball when it is
* bouncing.
**/
#include <cstddef>
#include <cmath>
#include "Implicit.hpp"
#include "common_structures.hpp"
2018-02-12 17:40:50 +01:00
#include "PerlinNoise.hpp"
2018-02-13 17:05:49 +01:00
#include "FlatGround.hpp"
#include "PerlinGround.hpp"
const double PI = 3.141592653589793;
class Spheroid : public ImplicitSurface {
public:
2018-02-12 18:45:35 +01:00
Spheroid(const Point& _center, double _min_p, double _p, double _q);
void update_center_pos(Point& _center);
void update_radius();
2018-02-13 17:05:49 +01:00
void check_ground_collision(const Ground* ground);
Cuboid max_bounding_box() const;
2018-02-12 17:40:50 +01:00
void check_perlin_collision(PerlinNoise perlin);
2018-02-12 14:15:30 +01:00
double operator() (double _x, double _y, double _z) const;
virtual Point location_hint() const;
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
**/
double min_p, init_p, p, q;
2018-02-07 15:18:53 +01:00
size_t stiffness;
double V;
void _compute_volume();
};