7 #include "imstkPbdAreaConstraint.h" 13 const Vec3d& p0,
const Vec3d& p1,
const Vec3d& p2,
22 m_restArea = 0.5 * (p1 - p0).cross(p2 - p0).norm();
27 double& c, std::vector<Vec3d>& dcdx)
29 const Vec3d& p0 = bodies.getPosition(
m_particles[0]);
30 const Vec3d& p1 = bodies.getPosition(
m_particles[1]);
31 const Vec3d& p2 = bodies.getPosition(
m_particles[2]);
33 const Vec3d e0 = p0 - p1;
34 const Vec3d e1 = p1 - p2;
35 const Vec3d e2 = p2 - p0;
37 Vec3d n = e0.cross(e1);
48 dcdx[0] = e1.cross(n);
49 dcdx[1] = e2.cross(n);
50 dcdx[2] = e0.cross(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...
bool computeValueAndGradient(PbdState &bodies, double &c, std::vector< Vec3d > &dcdx) override
Compute value and gradient of constraint function.
void initConstraint(const Vec3d &p0, const Vec3d &p1, const Vec3d &p2, const PbdParticleId &pIdx0, const PbdParticleId &pIdx1, const PbdParticleId &pIdx2, const double k=2.5)
Initialize the constraint.
std::vector< PbdParticleId > m_particles
body, particle index
double m_restArea
Area at the rest position.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.