1#ifndef PBAT_SIM_CONTACT_CONSTRAINTS_H
2#define PBAT_SIM_CONTACT_CONSTRAINTS_H
4#include "pbat/HostDevice.h"
6#include "pbat/math/linalg/mini/BinaryOperations.h"
7#include "pbat/math/linalg/mini/Matrix.h"
34 math::linalg::mini::CMatrix TMatrixP,
35 math::linalg::mini::CMatrix TMatrixNTB,
36 math::linalg::mini::CMatrix TMatrixX1,
37 math::linalg::mini::CMatrix TMatrixX2,
38 math::linalg::mini::CMatrix TMatrixX3,
39 math::linalg::mini::CMatrix TMatrixBary,
40 math::linalg::mini::CMatrix TMatrixC>
43 TMatrixNTB
const& NTB,
47 TMatrixBary
const& bary,
50 static_assert(TMatrixP::kRows == 3 and TMatrixP::kCols == 1,
"P must be 3x1");
51 static_assert(TMatrixNTB::kRows == 3 and TMatrixNTB::kCols == 3,
"NTB must be 3x3");
52 static_assert(TMatrixX1::kRows == 3 and TMatrixX1::kCols == 1,
"X1 must be 3x1");
53 static_assert(TMatrixX2::kRows == 3 and TMatrixX2::kCols == 1,
"X2 must be 3x1");
54 static_assert(TMatrixX3::kRows == 3 and TMatrixX3::kCols == 1,
"X3 must be 3x1");
55 static_assert(TMatrixBary::kRows == 3 and TMatrixBary::kCols == 1,
"bary must be 3x1");
56 static_assert(TMatrixC::kRows == 3 and TMatrixC::kCols == 1,
"C must be 3x1");
57 using ScalarType =
typename TMatrixP::ScalarType;
58 using Vec3 = math::linalg::mini::SVector<ScalarType, 3>;
60 Vec3 X = bary(0) * X1 + bary(1) * X2 + bary(2) * X3;
61 C = NTB.Transpose() * (X - P);
96 TMatrixNTB
const& NTB,
100 TMatrixBary
const& bary,
102 TMatrixGradCT& gradCT)
104 static_assert(TMatrixGradCT::kRows == 9 and TMatrixGradCT::kCols == 3,
"gradCT must be 9x3");
112 gradCT.Col(c).template Slice<3, 1>(i * 3, 0) = bary(i) * NTB.Col(c);
constexpr void ForRange(F &&f)
Compile-time for loop over a range of values.
Definition ConstexprFor.h:55