Add a vertical plan collision

This commit is contained in:
Rémi Oudin 2018-02-11 17:29:56 +01:00
parent 98fe6ebc12
commit 22e24258cd
2 changed files with 21 additions and 2 deletions

View file

@ -22,15 +22,32 @@ void Spheroid::update_radius() {
q = sqrt((3/4) * V / PI / p);
}
void Spheroid::update_height() {
q = (3/4) * V / PI / (p*p);
}
void Spheroid::update_center_pos(Point& _center) {
center = _center;
}
void Spheroid::check_plan_collision(double& height) {
void Spheroid::check_horizontal_plan_collision(double& height) {
if ((center.z - p) <= height) {
p = center.z-height;
update_radius();
}
}
void Spheroid::check_vertical_plan_collision(double& abscissa) {
if (center.x <= abscissa) {
if ((center.x + q) >= abscissa) {
q = abscissa - center.x;
update_height();
}
} else {
if ((center.x - q) <= abscissa) {
q = center.x - abscissa;
update_height();
}
}
}

View file

@ -15,8 +15,10 @@ class Spheroid : public ImplicitSurface {
Spheroid(Point& _center, 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_plan_collision(double& height);
void check_horizontal_plan_collision(double& height);
void check_vertical_plan_collision(double& abscissa);
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)