Bounding box for spheroid, based on initial values.

This commit is contained in:
Rémi Oudin 2018-02-12 14:31:08 +01:00
parent 48ef986f4f
commit 1ee6875b5a
3 changed files with 14 additions and 10 deletions

View file

@ -4,7 +4,7 @@
Ball::Ball(Point& _center, double _min_height, double _v_x, double _p, double _q) : Ball::Ball(Point& _center, double _min_height, double _v_x, double _p, double _q) :
Center(_center), Center(_center),
surface(_center, _p, _q), surface(_center, min_height, _p, _q),
init_h(_center.z), init_h(_center.z),
min_height(_min_height), min_height(_min_height),
bounce_number(0.0), bounce_number(0.0),

View file

@ -4,8 +4,8 @@
#include "spheroid.hpp" #include "spheroid.hpp"
Spheroid::Spheroid(Point& _center, size_t _p, size_t _q) : Spheroid::Spheroid(Point& _center, double _min_p, size_t _p, size_t _q) :
ImplicitSurface(_center), init_p(_p), p(_p), q(_q), stiffness(0) { ImplicitSurface(_center), min_p(_min_p), init_p(_p), p(_p), q(_q) {
_compute_volume(); _compute_volume();
} }
@ -13,9 +13,6 @@ void Spheroid::_compute_volume() {
V = (4/3) * PI * p * q * q; V = (4/3) * PI * p * q * q;
} }
void Spheroid::set_stiffness(size_t _stiffness) {
stiffness = _stiffness;
}
void Spheroid::update_radius() { void Spheroid::update_radius() {
@ -51,3 +48,11 @@ void Spheroid::check_vertical_plan_collision(double& abscissa) {
} }
} }
} }
Cuboid Spheroid::max_bounding_box() const {
double max_radius = sqrt((3/4) * V / PI / min_p);
double max_height = init_p;
Point _bd1(max_radius, max_radius, max_height);
Point _bd2(-max_radius, -max_radius, -max_height);
return Cuboid(_bd1, _bd2);
}

View file

@ -12,13 +12,13 @@ const double PI = 3.141592653589793;
class Spheroid : public ImplicitSurface { class Spheroid : public ImplicitSurface {
public: public:
Spheroid(Point& _center, size_t _p, size_t _q); Spheroid(Point& _center, double _min_p, size_t _p, size_t _q);
void update_center_pos(Point& _center); void update_center_pos(Point& _center);
void update_radius(); void update_radius();
void update_height(); void update_height();
void set_stiffness(size_t _stiffness);
void check_horizontal_plan_collision(double& height); void check_horizontal_plan_collision(double& height);
void check_vertical_plan_collision(double& abscissa); void check_vertical_plan_collision(double& abscissa);
Cuboid max_bounding_box() const;
double operator() (double _x, double _y, double _z) const { double operator() (double _x, double _y, double _z) const {
return (pow(_x - center.x, 2) / pow(q, 2) return (pow(_x - center.x, 2) / pow(q, 2)
+ pow(_y - center.y, 2) / pow(q, 2) + pow(_y - center.y, 2) / pow(q, 2)
@ -31,8 +31,7 @@ class Spheroid : public ImplicitSurface {
* V is the volume. Extremely useful to have a constant volume in the * V is the volume. Extremely useful to have a constant volume in the
* ball * ball
**/ **/
double init_p, p, q; double min_p, init_p, p, q;
size_t stiffness;
double V; double V;
void _compute_volume(); void _compute_volume();
}; };