9 #include "imstkSurfaceInsertionConstraint.h" 11 using namespace imstk;
14 SurfaceInsertionConstraint::initConstraint(
15 const Vec3d& insertionPoint,
20 const Vec3d& contactPt,
21 const Vec3d& barycentricPt,
25 m_insertionPoint = insertionPoint;
26 m_contactPt = contactPt;
27 m_barycentricPt = barycentricPt;
30 m_particles[1] = ptB1;
31 m_particles[2] = ptB2;
32 m_particles[3] = ptB3;
34 m_stiffness[0] = stiffnessA;
35 m_stiffness[1] = stiffnessB;
40 double& c, std::vector<Vec3d>& dcdx)
45 Vec3d diff = m_contactPt - m_insertionPoint;
58 dcdx[0] = -1.0 * diff;
61 dcdx[1] = diff * m_barycentricPt[0];
62 dcdx[2] = diff * m_barycentricPt[1];
63 dcdx[3] = diff * m_barycentricPt[2];
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of the constraint.
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...
Provides interface for accessing particles from a 2d array of PbdBody,Particles.