iMSTK
Interactive Medical Simulation Toolkit
Public Member Functions | Protected Attributes | List of all members
imstk::PbdBodyToBodyDistanceConstraint Class Reference

Constrain two locally defined points on each body by a given distance. More...

#include <imstkPbdContactConstraint.h>

Inheritance diagram for imstk::PbdBodyToBodyDistanceConstraint:
Inheritance graph
[legend]
Collaboration diagram for imstk::PbdBodyToBodyDistanceConstraint:
Collaboration graph
[legend]

Public Member Functions

void initConstraint (const PbdState &state, const PbdParticleId &bodyId0, const Vec3d ptOnBody0, const PbdParticleId &bodyId1, const Vec3d ptOnBody1, const double restLength, const double compliance)
 Initialize the constraint ptOnBody is global position.
 
void initConstraint (const PbdState &state, const PbdParticleId &bodyId0, const Vec3d ptOnBody0, const PbdParticleId &bodyId1, const double restLength, const double compliance)
 Initialize the constraint. More...
 
void initConstraint (const PbdState &state, const PbdParticleId &bodyId0, const Vec3d ptOnBody0, const PbdParticleId &bodyId1, const Vec3d ptOnBody1, const double compliance)
 Initialize the constraint ptOnBody is global position restLength is set to the initial distance between these two points.
 
bool computeValueAndGradient (PbdState &bodies, double &c, std::vector< Vec3d > &n) override
 Compute value and gradient of the constraint. More...
 
- Public Member Functions inherited from imstk::PbdContactConstraint
void projectConstraint (PbdState &bodies, const double dt, const SolverType &type) override
 Update positions by projecting constraints.
 
virtual Vec3d computeRelativeVelocity (PbdState &imstkNotUsed(bodies))
 
const Vec3d & getR (const int i) const
 Get the support point r/the difference to the contact point.
 
void correctVelocity (PbdState &bodies, const double dt) override
 Solve the velocities given to the constraint. More...
 
Vec3d getVelocityOnRigidBody (PbdState &bodies, const int bodyId, const Vec3d &pt)
 Returns the velocity at the given point on body Either body in collision could be rigid body.
 
double getTorque (const double dt, const int i)
 Get torque magnitude after solve.
 
- Public Member Functions inherited from imstk::PbdConstraint
virtual const std::string getTypeName () const =0
 
std::vector< PbdParticleId > & getParticles ()
 Get the vertex indices of the constraint.
 
bool getCorrectVelocity () const
 Get/Set whether velocity should be corrected for this constraint.
 
void setCorrectVelocity (const bool correctVelocity)
 
const Vec3d & getGradient (const int i) const
 Get gradient given the particle index in constraint.
 
double getForce (const double dt) const
 Get the force magnitude, valid after solving lambda Only valid with xpbd.
 
double getConstraintC () const
 Get constraint value C (how much the constraint is violated)
 
double getLambda () const
 Get constraint value C (how much the constraint is violated)
 
virtual double getRestValue () const
 Get reference constraint value. This value will have different context depending on the constraint being used.
 
void zeroOutLambda ()
 Zero's out the lagrange multplier before integration only used for xpbd, must be called before solving.
 
double computeGeneralizedInvMass (const PbdState &bodies, const size_t particleIndex) const
 Compute generalized inverse mass of the particle. Note perf sensitive function. It has been intentionally inlined. More...
 
double computeGeneralizedInvMass (const PbdState &bodies, const size_t particleIndex, const Vec3d &r) const
 Compute generalized inverse mass of the particle. More...
 
double getRestitution () const
 Get/Set restitution.
 
void setRestitution (const double restitution)
 
double getFriction () const
 Get/Set friction.
 
void setFriction (const double friction)
 
double getStiffness () const
 Get/Set the stiffness.
 
void setStiffness (const double stiffness)
 
double getCompliance () const
 Get/Set the compliance This function is also provided in case users need 0 compliance.
 
void setCompliance (const double compliance)
 

Protected Attributes

std::array< Vec3d, 2 > m_rest_r = { Vec3d::Zero(), Vec3d::Zero() }
 
double m_restLength = 0.0
 
- Protected Attributes inherited from imstk::PbdContactConstraint
std::vector< Vec3d > m_r
 
std::vector< double > m_weights
 
- Protected Attributes inherited from imstk::PbdConstraint
std::vector< PbdParticleIdm_particles
 body, particle index
 
std::vector< Vec3d > m_dcdx
 Normalized constraint gradients (per particle)
 
double m_stiffness = 1.0
 used in PBD, [0, 1]
 
double m_compliance = 1e-7
 used in xPBD, inverse of Stiffness
 
double m_lambda = 0.0
 Lagrange multiplier.
 
double m_C = 0.0
 Constraint Value.
 
double m_friction = 0.0
 
double m_restitution = 0.0
 
bool m_correctVelocity = false
 

Additional Inherited Members

- Public Types inherited from imstk::PbdConstraint
enum  SolverType { xPBD = 0, PBD }
 Type of solvers.
 
- Protected Member Functions inherited from imstk::PbdContactConstraint
 PbdContactConstraint (const int numParticles)
 
- Protected Member Functions inherited from imstk::PbdConstraint
 PbdConstraint (const size_t numParticles)
 

Detailed Description

Constrain two locally defined points on each body by a given distance.

Definition at line 189 of file imstkPbdContactConstraint.h.

Member Function Documentation

◆ computeValueAndGradient()

bool imstk::PbdBodyToBodyDistanceConstraint::computeValueAndGradient ( PbdState bodies,
double &  c,
std::vector< Vec3d > &  dcdx 
)
overridevirtual

Compute value and gradient of the constraint.

Parameters
bodiesPbdState provides all the bodies
cConstraint value
dcdxNormalized constraint gradients (per vertex)

Implements imstk::PbdConstraint.

Definition at line 455 of file imstkPbdContactConstraint.cpp.

◆ initConstraint()

void imstk::PbdBodyToBodyDistanceConstraint::initConstraint ( const PbdState state,
const PbdParticleId bodyId0,
const Vec3d  ptOnBody0,
const PbdParticleId bodyId1,
const double  restLength,
const double  compliance 
)
inline

Initialize the constraint.

Parameters
statethe PbdState
bodyId0Rigid body to constrain
ptOnBody0Point on rigid body bodyId0 (global position)
bodyId1particle to constraint to ptOnBody0
restLengthresting length (distance ptOnBody0 should be from bodyId1 position)
compliance

Definition at line 231 of file imstkPbdContactConstraint.h.


The documentation for this class was generated from the following files: