From 0f70e4e023b490eb0eeaf924d2c441265bb00eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Mon, 12 Feb 2018 12:08:50 +0100 Subject: [PATCH] keep track of initial radius, for deformation --- spheroid.cpp | 4 ++-- spheroid.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spheroid.cpp b/spheroid.cpp index d875aa3..ef9f381 100644 --- a/spheroid.cpp +++ b/spheroid.cpp @@ -5,7 +5,7 @@ #include "spheroid.hpp" Spheroid::Spheroid(Point& _center, size_t _p, size_t _q) : - ImplicitSurface(_center), p(_p), q(_q), stiffness(0) { + ImplicitSurface(_center), init_p(_p), p(_p), q(_q), stiffness(0) { _compute_volume(); } @@ -33,7 +33,7 @@ void Spheroid::update_center_pos(Point& _center) { void Spheroid::check_horizontal_plan_collision(double& height) { if ((center.z - p) <= height) { - p = center.z-height; + p = fmin(init_p, center.z-height); update_radius(); } } diff --git a/spheroid.hpp b/spheroid.hpp index 26357b7..66b2aec 100644 --- a/spheroid.hpp +++ b/spheroid.hpp @@ -31,7 +31,7 @@ class Spheroid : public ImplicitSurface { * V is the volume. Extremely useful to have a constant volume in the * ball **/ - double p, q; + double init_p, p, q; size_t stiffness; double V; void _compute_volume();