iMSTK
Interactive Medical Simulation Toolkit
imstkPbdBendConstraint.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkPbdConstraint.h"
10 
11 namespace imstk
12 {
20 {
21 public:
23 
24  IMSTK_TYPE_NAME(PbdBendConstraint)
25 
26 
36  void initConstraint(
37  const Vec3d& initPos0, const Vec3d& initPos1, const Vec3d& initPos2,
38  const PbdParticleId& pIdx0, const PbdParticleId& pIdx1, const PbdParticleId& pIdx2,
39  const double k);
40  void initConstraint(
41  const PbdParticleId& pIdx0, const PbdParticleId& pIdx1, const PbdParticleId& pIdx2,
42  const double restLength,
43  const double k);
44 
51  bool computeValueAndGradient(PbdState& bodies,
52  double& c, std::vector<Vec3d>& dcdx) override;
53 
57  double getRestValue() const { return m_restLength; }
58 
59 public:
60  double m_restLength = 0.;
61 };
62 } // namespace imstk
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.
double m_restLength
Rest length.
Compound Geometry.
double getRestValue() const
Return the rest configuration for the constraint.
Bend constraint between two segments. Maintains angle between the two segments in the initial configu...
Base Constraint class for Position based dynamics constraints.
Provides interface for accessing particles from a 2d array of PbdBody,Particles.
Definition: imstkPbdBody.h:229
void initConstraint(const Vec3d &initPos0, const Vec3d &initPos1, const Vec3d &initPos2, const PbdParticleId &pIdx0, const PbdParticleId &pIdx1, const PbdParticleId &pIdx2, const double k)
Initialize the constraint p0 \ \ p1 / / p2.