iMSTK
Interactive Medical Simulation Toolkit
imstkRbdContactConstraint.cpp
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 #include "imstkRbdContactConstraint.h"
8 
9 namespace imstk
10 {
11 void
13 {
14  // Jacobian of contact (defines linear and angular constraint axes)
15  J = Eigen::Matrix<double, 3, 4>::Zero();
16  if ((m_side == Side::AB || m_side == Side::A) && !m_obj1->m_isStatic)
17  {
18  // Displacement from center of mass
19  const Vec3d r1 = m_contactPt - m_obj1->getPosition();
20  const Vec3d c = r1.cross(m_contactN);
21  J(0, 0) = m_contactN[0]; J(0, 1) = c[0];
22  J(1, 0) = m_contactN[1]; J(1, 1) = c[1];
23  J(2, 0) = m_contactN[2]; J(2, 1) = c[2];
24  }
25  if ((m_side == Side::AB || m_side == Side::B) && !m_obj2->m_isStatic)
26  {
27  // Displacement from center of mass
28  const Vec3d r2 = m_contactPt - m_obj2->getPosition();
29  const Vec3d c = r2.cross(-m_contactN);
30  J(0, 2) = -m_contactN[0]; J(0, 3) = c[0];
31  J(1, 2) = -m_contactN[1]; J(1, 3) = c[1];
32  J(2, 2) = -m_contactN[2]; J(2, 3) = c[2];
33  }
34 
35  vu = m_contactDepth * m_beta / dt;
36 }
37 } // namespace imstk
Compound Geometry.
double vu
Bauhmgarte stabilization term.
Eigen::Matrix< double, 3, 4 > J
Jacobian, "vanish" to zero.
void compute(double dt) override
Compute constraint jacobian.