7 #include "imstkPbdPointEdgeConstraint.h" 15 double stiffnessA,
double stiffnessB)
21 m_stiffness[0] = stiffnessA;
22 m_stiffness[1] = stiffnessB;
27 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]);
34 const Vec3d ab = x2 - x1;
35 const double length = ab.norm();
42 const Vec3d dir1 = ab / length;
45 const Vec3d diff = x0 - x1;
46 const double p = dir1.dot(diff);
47 if (p < 0.0 || p > length)
56 const int maxId = ((1.0 - p) < p) ? 2 : 1;
65 const Vec3d diff1 = diff - p * dir1;
66 const double l = diff1.norm();
73 const Vec3d n = diff1 / l;
74 const double u = p / length;
77 dcdx[1] = (1.0 - u) * 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 &ptA1, const PbdParticleId &ptB1, const PbdParticleId &ptB2, double stiffnessA, double stiffnessB)
Initialize the constraint.
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of constraint function.
bool m_enableBoundaryCollisions
Provides interface for accessing particles from a 2d array of PbdBody,Particles.