CellModules
BodyDelaunayMassSpringDamper.hpp
Go to the documentation of this file.
1#ifndef BODYMASSSPRINGDAMPER_HPP
2#define BODYMASSSPRINGDAMPER_HPP
3
4#define MOVABLE
5
13#include <mecacell/mecacell.h>
14#include <mecacell/movable.h>
16#include "../../../../src/core/BaseBody.hpp"
17#include <math.h>
18
24
32 template<typename cell_t, class plugin_t>
33 class BodyDelaunayMassSpringDamper : public MecaCell::Movable, public virtual BaseBody<plugin_t> {
34
35 private:
36 double baseRadius;
37 double radius;
38 double density;
39 double adhesion;
41 public:
50 baseRadius = 10.0; // 10 µm radius
52 density = 0.001; // 0.001 ng/µm³ density of water ~ 1000 kg/m³
53 adhesion = 0.75;
54 this->setMass(density * 4 * M_PI / 3 * pow(radius, 3)); // mass = density * 4π/3 * radius³ ng
55 this->setPosition(pos);
56 }
57
62 inline double getBoundingBoxRadius() const { return radius; }
63
71 inline void setRadius(double rad) {
72 radius = rad;
73 this->setMass(density * 4 * M_PI / 3 * pow(radius, 3)); // mass = density * 4π/3 * radius³ ng
74 }
75
80 inline double getRadius() { return radius; }
81
87 inline double getBaseRadius() const { return baseRadius; }
88
94 inline void setBaseRadius(double _baseRadius) { baseRadius = _baseRadius; }
95
101 inline void growth(double delta) {
102 this->setRadius(baseRadius * std::cbrt(1 + delta));
103 }
104
112 inline void setDensity(double d) {
113 density = d;
114 this->setMass(density * 4 * M_PI / 3 * pow(radius, 3)); // mass = density * 4π/3 * radius³ ng
115 }
116
121 inline double getAdhesion() const { return adhesion; }
122
127 inline void setAdhesion(double a) { adhesion = a; }
128
133 inline void moveTo(const MecaCell::Vec &v) { this->setPosition(v); }
134 };
135}
136
137#endif // BODYMASSSPRINGDAMPER_HPP
MecaCell::Vec pos
Definition: CellBody.hpp:34
Defines the PluginDelaunayMassSpringDamper class for Delaunay triangulation and mass-spring-damper ph...
Class for managing Delaunay triangulation and mass-spring-based physics.
void growth(double delta)
Increases the radius so that the volume is multiplied by 1 + delta.
BodyDelaunayMassSpringDamper(const MecaCell::Vector3D &pos=MecaCell::Vector3D::zero())
Constructor.
void setBaseRadius(double _baseRadius)
Sets the base radius.
void moveTo(const MecaCell::Vec &v)
Moves a cell to position v.
double getBoundingBoxRadius() const
Gets the bounding box radius.
void setPosition(const Vec &p)
Definition: movable.h:31
void setMass(const double m)
Definition: movable.h:35
general purpose 3D vector/point class.
Definition: vector3D.h:20
static Vector3D zero()
constructs a zero vector
Definition: vector3D.h:170
Namespace for Delaunay triangulation and mass-spring-based physics-related classes and functions.
double cbrt(double x)
Computes the cube root of a number.
Definition: std.hpp:215
double pow(double base, double exponent)
Computes the power of a number.
Definition: std.hpp:43