Bounding box for spheroid, based on initial values.
This commit is contained in:
parent
48ef986f4f
commit
1ee6875b5a
3 changed files with 14 additions and 10 deletions
2
Ball.cpp
2
Ball.cpp
|
@ -4,7 +4,7 @@
|
|||
|
||||
Ball::Ball(Point& _center, double _min_height, double _v_x, double _p, double _q) :
|
||||
Center(_center),
|
||||
surface(_center, _p, _q),
|
||||
surface(_center, min_height, _p, _q),
|
||||
init_h(_center.z),
|
||||
min_height(_min_height),
|
||||
bounce_number(0.0),
|
||||
|
|
15
spheroid.cpp
15
spheroid.cpp
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include "spheroid.hpp"
|
||||
|
||||
Spheroid::Spheroid(Point& _center, size_t _p, size_t _q) :
|
||||
ImplicitSurface(_center), init_p(_p), p(_p), q(_q), stiffness(0) {
|
||||
Spheroid::Spheroid(Point& _center, double _min_p, size_t _p, size_t _q) :
|
||||
ImplicitSurface(_center), min_p(_min_p), init_p(_p), p(_p), q(_q) {
|
||||
_compute_volume();
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,6 @@ void Spheroid::_compute_volume() {
|
|||
V = (4/3) * PI * p * q * q;
|
||||
}
|
||||
|
||||
void Spheroid::set_stiffness(size_t _stiffness) {
|
||||
stiffness = _stiffness;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ const double PI = 3.141592653589793;
|
|||
|
||||
class Spheroid : public ImplicitSurface {
|
||||
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_radius();
|
||||
void update_height();
|
||||
void set_stiffness(size_t _stiffness);
|
||||
void check_horizontal_plan_collision(double& height);
|
||||
void check_vertical_plan_collision(double& abscissa);
|
||||
Cuboid max_bounding_box() const;
|
||||
double operator() (double _x, double _y, double _z) const {
|
||||
return (pow(_x - center.x, 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
|
||||
* ball
|
||||
**/
|
||||
double init_p, p, q;
|
||||
size_t stiffness;
|
||||
double min_p, init_p, p, q;
|
||||
double V;
|
||||
void _compute_volume();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue