7 #include "imstkPbdPointTriangleConstraint.h" 14 double stiffnessA,
double stiffnessB)
21 m_stiffness[0] = stiffnessA;
22 m_stiffness[1] = stiffnessB;
28 double& c, std::vector<Vec3d>& dcdx)
30 const Vec3d& x0 = bodies.getPosition(
m_particles[0]);
31 const Vec3d& x1 = bodies.getPosition(
m_particles[1]);
32 const Vec3d& x2 = bodies.getPosition(
m_particles[2]);
33 const Vec3d& x3 = bodies.getPosition(
m_particles[3]);
36 const Vec3d bary = baryCentric(x0, x1, x2, x3);
39 if (bary[0] < 0.0 || bary[1] < 0.0 || bary[2] < 0.0)
49 bary.maxCoeff(&maxId);
51 if (bodies.getInvMass(
m_particles[maxId + 1]) == 0.0)
59 const Vec3d n = (x2 - x1).cross(x3 - x1).normalized();
61 const double l = (x0 - x1).dot(n);
66 dcdx[1] = bary[0] * n;
67 dcdx[2] = bary[1] * n;
68 dcdx[3] = bary[2] * n;
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 PbdParticleId &ptA, const PbdParticleId &ptB1, const PbdParticleId &ptB2, const PbdParticleId &ptB3, double stiffnessA, double stiffnessB)
Initialize the constraint.
bool m_enableBoundaryCollisions
Provides interface for accessing particles from a 2d array of PbdBody,Particles.
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of constraint function.