iMSTK
Interactive Medical Simulation Toolkit
RbdAngularLockingConstraint.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 "imstkRbdConstraint.h"
10 
11 using namespace imstk;
12 
19 {
20 public:
22  std::shared_ptr<RigidBody> obj,
23  const Quatd& fixedOrientation,
24  const double beta = 0.05) : RbdConstraint(obj, nullptr, Side::A),
25  m_fixedOrientation(fixedOrientation),
26  m_beta(beta)
27  {
28  }
29 
30  ~RbdAngularLockingConstraint() override = default;
31 
32  IMSTK_TYPE_NAME(RbdAngularLockingConstraint)
33 
34 public:
35  void compute(double dt) override
36  {
37  // Jacobian of contact (defines linear and angular constraint axes)
38  J = Eigen::Matrix<double, 3, 4>::Zero();
39  if ((m_side == Side::AB || m_side == Side::A) && !m_obj1->m_isStatic)
40  {
41  const Quatd dq = m_fixedOrientation * m_obj1->getOrientation().inverse();
42  const Rotd angleAxes = Rotd(dq);
43  const Vec3d rotAxes = angleAxes.axis();
44  vu = angleAxes.angle() * m_beta / dt;
45  J(0, 0) = 0.0; J(0, 1) = rotAxes[0];
46  J(1, 0) = 0.0; J(1, 1) = rotAxes[1];
47  J(2, 0) = 0.0; J(2, 1) = rotAxes[2];
48  }
49  }
50 
51 private:
52  Quatd m_fixedOrientation;
53  double m_beta = 0.05;
54 };
Abstract class for rigid body constraints. A RbdConstraint should mainly provide a constraint jacobia...
void compute(double dt) override
Compute constraint jacobian.
Compound Geometry.
Constrains the orientation to some fixed orientation.