1#ifndef MECACELL_ELASTICCONNECTION_HPP
2#define MECACELL_ELASTICCONNECTION_HPP
21 std::pair<double, double>
45 auto biggestCell =
cells.first->getBody().getBoundingBoxRadius() >=
46 cells.second->getBody().getBoundingBoxRadius() ?
49 auto smallestCell = biggestCell ==
cells.first ?
cells.second :
cells.first;
51 double biggestCellMidpoint =
53 (
std::pow(biggestCell->getBody().getBoundingBoxRadius(), 2) -
54 std::pow(smallestCell->getBody().getBoundingBoxRadius(), 2)) /
56 double smallestCellMidpoint =
dist - biggestCellMidpoint;
57 if (biggestCell ==
cells.first)
58 return {biggestCellMidpoint, smallestCellMidpoint};
60 return {smallestCellMidpoint, biggestCellMidpoint};
64 overlap = max(0.0, (
cells.first->getBoundingBoxRadius() +
65 cells.second->getBoundingBoxRadius()) -
67 const auto &c0 =
cells.first->getBody();
68 const auto &c1 =
cells.first->getBody();
69 double invertRadii = 1.0 / (1.0 /
cells.first->getBoundingBoxRadius() +
70 1.0 /
cells.second->getBoundingBoxRadius());
72 1.0 / (((1.0 -
pow(c0.getPoissonCoef(), 2)) / c0.getYoungModulus()) +
73 ((1.0 -
pow(c1.getPoissonCoef(), 2)) / c1.getYoungModulus()));
76 auto F =
direction * ((2.0 / 3.0) * invertYoung * tempterm);
77 cells.first->getBody().receiveForce(-F);
78 cells.second->getBody().receiveForce(F);
101 double parallelForce1to2 =
103 double parallelForce2to1 =
105 double sum = parallelForce2to1 + parallelForce1to2;
106 logger<DBG>(
"pf2t1 = ", parallelForce2to1);
107 logger<DBG>(
"pf1t2 = ", parallelForce1to2);
108 cells.first->getBody().receiveForce(parallelForce2to1 *
direction);
109 cells.second->getBody().receiveForce(-parallelForce1to2 *
direction);
110 logger<DBG>(
"sum = ", sum);
general purpose 3D vector/point class.
double length() const
compute the length of the vector
this file contains various miscellanious utility functions & helpers *
double cbrt(double x)
Computes the cube root of a number.
double sqrt(double x)
Computes the square root of a number.
double pow(double base, double exponent)
Computes the power of a number.
static constexpr double DOUBLE_EPSILON
max distance for two doubles to be considered equals (only used for some geometric operations)
An Elastic Connection is a connection between two cells.
std::pair< double, double > midpoint
std::pair< Joint, Joint > flex
void updateAdhesionForces(double)
std::pair< double, double > computeMidpoints()
std::pair< Joint, Joint > tors
ElasticConnection(ordered_pair< Cell * > c)
ordered_pair< Cell * > cells
void updateCollisionForces()