Remove edge length computations from elasticity plugins.

Read the lengths from mjModel and mjData flex arrays.

PiperOrigin-RevId: 673116608
Change-Id: Iffa209abb7443707effaffb5bda99345399fac1c
This commit is contained in:
Alessio Quaglino
2024-09-10 14:53:31 -07:00
committed by Copybara-Service
parent e4d4153352
commit 33e56ccb88
5 changed files with 28 additions and 56 deletions
-22
View File
@@ -33,28 +33,6 @@ struct PairHash
}
};
inline mjtNum SquaredDist3(const mjtNum pos1[3], const mjtNum pos2[3]) {
mjtNum dif[3] = {pos1[0]-pos2[0], pos1[1]-pos2[1], pos1[2]-pos2[2]};
return dif[0]*dif[0] + dif[1]*dif[1] + dif[2]*dif[2];
}
inline void UpdateSquaredLengths(std::vector<mjtNum>& len,
const std::vector<std::pair<int, int> >& edges,
const mjtNum* x) {
for (int e = 0; e < len.size(); e++) {
const mjtNum* p0 = x + 3*edges[e].first;
const mjtNum* p1 = x + 3*edges[e].second;
len[e] = SquaredDist3(p0, p1);
}
}
inline void UpdateSquaredLengthsFlex(std::vector<mjtNum>& len,
const mjtNum* flexedge_length) {
for (int e = 0; e < len.size(); e++) {
len[e] = flexedge_length[e]*flexedge_length[e];
}
}
struct Stencil2D {
static constexpr int kNumEdges = 3;
static constexpr int kNumVerts = 3;