9 #include "imstkThreadInsertionConstraint.h" 11 using namespace imstk;
14 ThreadInsertionConstraint::initConstraint(
18 const Vec2d& threadBaryPoint,
22 const Vec3d& triBaryPoint,
27 m_particles[0] = ptA1;
28 m_particles[1] = ptA2;
31 m_threadBaryPt = threadBaryPoint;
34 m_threadInsertionPoint = m_threadBaryPt[0] * bodies.getPosition(m_particles[0])
35 + m_threadBaryPt[1] * bodies.getPosition(m_particles[1]);
38 m_particles[2] = ptB1;
39 m_particles[3] = ptB2;
40 m_particles[4] = ptB3;
43 m_triangleBaryPt = triBaryPoint;
46 m_triInsertionPoint = m_triangleBaryPt[0] * bodies.getPosition(m_particles[2])
47 + m_triangleBaryPt[1] * bodies.getPosition(m_particles[3])
48 + m_triangleBaryPt[2] * bodies.getPosition(m_particles[4]);
51 m_stiffness[0] = stiffnessA;
52 m_stiffness[1] = stiffnessB;
57 double& c, std::vector<Vec3d>& dcdx)
65 Vec3d diff = m_triInsertionPoint - m_threadInsertionPoint;
77 dcdx[0] = diff * m_threadBaryPt[0];
78 dcdx[1] = diff * m_threadBaryPt[1];
81 dcdx[2] = -diff * m_triangleBaryPt[0];
82 dcdx[3] = -diff * m_triangleBaryPt[1];
83 dcdx[4] = -diff * m_triangleBaryPt[2];
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 the constraint.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.