7 #include "imstkPbdBendConstraint.h" 13 const Vec3d& p0,
const Vec3d& p1,
const Vec3d& p2,
19 const Vec3d& center = (p0 + p1 + p2) / 3.0;
27 const double restLength,
41 double& c, std::vector<Vec3d>& dcdx)
43 const Vec3d& p0 = bodies.getPosition(
m_particles[0]);
44 const Vec3d& p1 = bodies.getPosition(
m_particles[1]);
45 const Vec3d& p2 = bodies.getPosition(
m_particles[2]);
48 const Vec3d& center = (p0 + p1 + p2) / 3.0;
49 const Vec3d& diff = p1 - center;
50 const double dist = diff.norm();
59 dcdx[0] = (-2.0 / dist) * diff;
60 dcdx[1] = -2.0 * dcdx[0];
std::pair< int, int > PbdParticleId
Index pair that refers to a particle in a PbdState. Index 0 is the body id, Index 1 is the particle i...
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of constraint function.
std::vector< PbdParticleId > m_particles
body, particle index
double m_restLength
Rest length.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.
void initConstraint(const Vec3d &initPos0, const Vec3d &initPos1, const Vec3d &initPos2, const PbdParticleId &pIdx0, const PbdParticleId &pIdx1, const PbdParticleId &pIdx2, const double k)
Initialize the constraint p0 \ \ p1 / / p2.