7 #include "imstkPbdDistanceConstraint.h" 13 const double restLength,
26 double& c, std::vector<Vec3d>& dcdx)
28 const Vec3d& p0 = bodies.getPosition(
m_particles[0]);
29 const Vec3d& p1 = bodies.getPosition(
m_particles[1]);
32 const double len = dcdx[0].norm();
double m_restLength
Rest length between the nodes.
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...
std::vector< PbdParticleId > m_particles
body, particle index
void initConstraint(const Vec3d &p0, const Vec3d &p1, const PbdParticleId &pIdx0, const PbdParticleId &pIdx1, const double k=1e5)
Initialize the constraint with resting length as the length between the two points.
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of the constraint.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.