-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathedge_edge_mollifier.hpp
More file actions
524 lines (491 loc) · 20.7 KB
/
Copy pathedge_edge_mollifier.hpp
File metadata and controls
524 lines (491 loc) · 20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
#pragma once
#include <ipc/math/scalar_math.hpp>
#include <ipc/utils/eigen_ext.hpp>
#include <ipc/utils/simd.hpp>
namespace ipc {
// Symbolically generated derivatives
namespace autogen {
// clang-format off
template <typename T>
void edge_edge_cross_squarednorm_gradient(
T v01, T v02, T v03, T v11, T v12, T v13, T v21, T v22, T v23, T v31, T v32, T v33, T g[12]);
template <typename T>
void edge_edge_cross_squarednorm_hessian(
T v01, T v02, T v03, T v11, T v12, T v13, T v21, T v22, T v23, T v31, T v32, T v33, T H[144]);
template <typename T>
void edge_edge_mollifier_threshold_gradient(
T ea0x, T ea0y, T ea0z, T ea1x, T ea1y, T ea1z, T eb0x, T eb0y, T eb0z, T eb1x, T eb1y, T eb1z, T grad[12], T scale = literal<T>(1e-3));
// clang-format on
} // namespace autogen
// --- Scalar mollifier functions ------------------------------------------
/// @brief Mollifier function for edge-edge distance.
/// @param x Squared norm of the edge-edge cross product.
/// @param eps_x Mollifier activation threshold.
/// @return The mollifier coefficient to premultiply the edge-edge distance.
template <typename T> inline T edge_edge_mollifier(const T x, const T eps_x)
{
return select_lazy(
x < eps_x,
[&] {
const T x_div_eps_x = x / eps_x;
return (-x_div_eps_x + T(2)) * x_div_eps_x;
},
[&] { return T(1); });
}
/// @brief The gradient of the mollifier function for edge-edge distance.
/// @param x Squared norm of the edge-edge cross product.
/// @param eps_x Mollifier activation threshold.
/// @return The gradient of the mollifier function for edge-edge distance wrt x.
template <typename T>
inline T edge_edge_mollifier_gradient(const T x, const T eps_x)
{
using namespace ipc::numext; // fma
return select_lazy(
x < eps_x,
[&] {
const T one_div_eps_x = T(1) / eps_x;
return T(2) * one_div_eps_x * fma(-one_div_eps_x, x, T(1));
},
[&] { return T(0); });
}
/// @brief The derivative of the mollifier function for edge-edge distance wrt
/// eps_x.
/// @param x Squared norm of the edge-edge cross product.
/// @param eps_x Mollifier activation threshold.
/// @return The derivative of the mollifier function for edge-edge distance wrt
/// eps_x.
template <typename T>
inline T edge_edge_mollifier_derivative_wrt_eps_x(const T x, const T eps_x)
{
return select_lazy(
x < eps_x,
[&] { return T(2) * x * (-eps_x + x) / (eps_x * eps_x * eps_x); },
[&] { return T(0); });
}
/// @brief The hessian of the mollifier function for edge-edge distance.
/// @param x Squared norm of the edge-edge cross product.
/// @param eps_x Mollifier activation threshold.
/// @return The hessian of the mollifier function for edge-edge distance wrt x.
template <typename T>
inline T edge_edge_mollifier_hessian(const T x, const T eps_x)
{
return select_lazy(
x < eps_x, [&] { return T(-2) / (eps_x * eps_x); },
[&] { return T(0); });
}
/// @brief The derivative of the gradient of the mollifier function for
/// edge-edge distance wrt eps_x.
/// @param x Squared norm of the edge-edge cross product.
/// @param eps_x Mollifier activation threshold.
/// @return The derivative of the gradient of the mollifier function for
/// edge-edge distance wrt eps_x.
template <typename T>
inline T
edge_edge_mollifier_gradient_derivative_wrt_eps_x(const T x, const T eps_x)
{
return select_lazy(
x < eps_x,
[&] { return T(2) * (-eps_x + T(2) * x) / (eps_x * eps_x * eps_x); },
[&] { return T(0); });
}
// --- Fixed-size kernels ---------------------------------------------------
namespace detail {
/// @note Prefer the ipc::edge_edge_cross_squarednorm front end.
template <typename T>
inline T edge_edge_cross_squarednorm(
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1)
{
return (ea1 - ea0).cross(eb1 - eb0).squaredNorm();
}
/// @note Prefer the ipc::edge_edge_cross_squarednorm_gradient front end.
template <typename T>
inline Eigen::Vector<T, 12> edge_edge_cross_squarednorm_gradient(
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1)
{
Eigen::Vector<T, 12> grad;
autogen::edge_edge_cross_squarednorm_gradient(
ea0[0], ea0[1], ea0[2], ea1[0], ea1[1], ea1[2], eb0[0], eb0[1],
eb0[2], eb1[0], eb1[1], eb1[2], grad.data());
return grad;
}
/// @note Prefer the ipc::edge_edge_cross_squarednorm_hessian front end.
template <typename T>
inline Eigen::Matrix<T, 12, 12> edge_edge_cross_squarednorm_hessian(
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1)
{
Eigen::Matrix<T, 12, 12> hess;
autogen::edge_edge_cross_squarednorm_hessian(
ea0[0], ea0[1], ea0[2], ea1[0], ea1[1], ea1[2], eb0[0], eb0[1],
eb0[2], eb1[0], eb1[1], eb1[2], hess.data());
return hess;
}
/// @note Prefer the ipc::edge_edge_mollifier front end.
template <typename T>
inline T edge_edge_mollifier(
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1,
const T eps_x)
{
return ipc::edge_edge_mollifier(
edge_edge_cross_squarednorm(ea0, ea1, eb0, eb1), eps_x);
}
/// @note Prefer the ipc::edge_edge_mollifier_gradient front end.
template <typename T>
inline Eigen::Vector<T, 12> edge_edge_mollifier_gradient(
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1,
const T eps_x)
{
const T ee_cross_norm_sqr =
edge_edge_cross_squarednorm(ea0, ea1, eb0, eb1);
if constexpr (!is_simd_batch_v<T>) {
// Shortcut for the common case of the mollifier being inactive.
if (ee_cross_norm_sqr >= eps_x) {
return Eigen::Vector<T, 12>::Zero();
}
}
return ipc::edge_edge_mollifier_gradient(ee_cross_norm_sqr, eps_x)
* edge_edge_cross_squarednorm_gradient(ea0, ea1, eb0, eb1);
}
/// @note Prefer the ipc::edge_edge_mollifier_hessian front end.
template <typename T>
inline Eigen::Matrix<T, 12, 12> edge_edge_mollifier_hessian(
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1,
const T eps_x)
{
const T ee_cross_norm_sqr =
edge_edge_cross_squarednorm(ea0, ea1, eb0, eb1);
if constexpr (!is_simd_batch_v<T>) {
// Shortcut for the common case of the mollifier being inactive.
if (ee_cross_norm_sqr >= eps_x) {
return Eigen::Matrix<T, 12, 12>::Zero();
}
}
const Eigen::Vector<T, 12> grad =
edge_edge_cross_squarednorm_gradient(ea0, ea1, eb0, eb1);
return (ipc::edge_edge_mollifier_gradient(ee_cross_norm_sqr, eps_x)
* edge_edge_cross_squarednorm_hessian(ea0, ea1, eb0, eb1))
+ ((ipc::edge_edge_mollifier_hessian(ee_cross_norm_sqr, eps_x)
* grad)
* grad.transpose());
}
/// @note Prefer the ipc::edge_edge_mollifier_gradient_wrt_x front end.
template <typename T>
Eigen::Vector<T, 12> edge_edge_mollifier_gradient_wrt_x(
Eigen::ConstRef<Eigen::Vector3<T>> ea0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> ea1_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb1_rest,
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1);
/// @note Prefer the ipc::edge_edge_mollifier_gradient_jacobian_wrt_x front
/// end.
template <typename T>
Eigen::Matrix<T, 12, 12> edge_edge_mollifier_gradient_jacobian_wrt_x(
Eigen::ConstRef<Eigen::Vector3<T>> ea0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> ea1_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb1_rest,
Eigen::ConstRef<Eigen::Vector3<T>> ea0,
Eigen::ConstRef<Eigen::Vector3<T>> ea1,
Eigen::ConstRef<Eigen::Vector3<T>> eb0,
Eigen::ConstRef<Eigen::Vector3<T>> eb1);
/// @note Prefer the ipc::edge_edge_mollifier_threshold front end.
template <typename T>
T edge_edge_mollifier_threshold(
Eigen::ConstRef<Eigen::Vector3<T>> ea0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> ea1_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb1_rest)
{
return literal<T>(1e-3) * (ea0_rest - ea1_rest).squaredNorm()
* (eb0_rest - eb1_rest).squaredNorm();
}
/// @note Prefer the ipc::edge_edge_mollifier_threshold_gradient front end.
template <typename T>
Eigen::Vector<T, 12> edge_edge_mollifier_threshold_gradient(
Eigen::ConstRef<Eigen::Vector3<T>> ea0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> ea1_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb0_rest,
Eigen::ConstRef<Eigen::Vector3<T>> eb1_rest)
{
Eigen::Vector<T, 12> grad;
autogen::edge_edge_mollifier_threshold_gradient(
ea0_rest[0], ea0_rest[1], ea0_rest[2], ea1_rest[0], ea1_rest[1],
ea1_rest[2], eb0_rest[0], eb0_rest[1], eb0_rest[2], eb1_rest[0],
eb1_rest[1], eb1_rest[2], grad.data(), /*scale=*/literal<T>(1e-3));
return grad;
}
} // namespace detail
// --- EigenExpression wrappers ---------------------------------------------
/// @brief Compute the squared norm of the edge-edge cross product.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @return The squared norm of the edge-edge cross product.
template <
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_cross_squarednorm(
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1)
{
using T = typename DerivedEA0::Scalar;
// NOTE: explicit <T>: the detail overload cannot deduce T from an
// arbitrary Eigen expression.
return detail::edge_edge_cross_squarednorm<T>(ea0, ea1, eb0, eb1);
}
/// @brief Compute the gradient of the squared norm of the edge cross product.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @return The gradient of the squared norm of the edge cross product wrt ea0,
/// ea1, eb0, and eb1.
template <
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_cross_squarednorm_gradient(
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1)
{
using T = typename DerivedEA0::Scalar;
return detail::edge_edge_cross_squarednorm_gradient<T>(ea0, ea1, eb0, eb1);
}
/// @brief Compute the hessian of the squared norm of the edge cross product.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @return The hessian of the squared norm of the edge cross product wrt ea0,
/// ea1, eb0, and eb1.
template <
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_cross_squarednorm_hessian(
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1)
{
using T = typename DerivedEA0::Scalar;
return detail::edge_edge_cross_squarednorm_hessian<T>(ea0, ea1, eb0, eb1);
}
/// @brief Compute a mollifier for the edge-edge distance.
///
/// This helps smooth the non-smoothness at close to parallel edges.
///
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @param eps_x Mollifier activation threshold.
/// @return The mollifier coefficient to premultiply the edge-edge distance.
template <
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_mollifier(
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1,
const typename DerivedEA0::Scalar eps_x)
{
using T = typename DerivedEA0::Scalar;
return detail::edge_edge_mollifier<T>(ea0, ea1, eb0, eb1, eps_x);
}
/// @brief Compute the gradient of the mollifier for the edge-edge distance.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @param eps_x Mollifier activation threshold.
/// @return The gradient of the mollifier.
template <
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_mollifier_gradient(
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1,
const typename DerivedEA0::Scalar eps_x)
{
using T = typename DerivedEA0::Scalar;
return detail::edge_edge_mollifier_gradient<T>(ea0, ea1, eb0, eb1, eps_x);
}
/// @brief Compute the hessian of the mollifier for the edge-edge distance.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @param eps_x Mollifier activation threshold.
/// @return The hessian of the mollifier.
template <
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_mollifier_hessian(
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1,
const typename DerivedEA0::Scalar eps_x)
{
using T = typename DerivedEA0::Scalar;
return detail::edge_edge_mollifier_hessian<T>(ea0, ea1, eb0, eb1, eps_x);
}
/// @brief Compute the gradient of the mollifier for the edge-edge distance wrt
/// rest positions.
/// @param ea0_rest The rest position of the first vertex of the first edge.
/// @param ea1_rest The rest position of the second vertex of the first edge.
/// @param eb0_rest The rest position of the first vertex of the second edge.
/// @param eb1_rest The rest position of the second vertex of the second edge.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @return The derivative of the mollifier wrt rest positions.
template <
typename DerivedEA0Rest,
typename DerivedEA1Rest,
typename DerivedEB0Rest,
typename DerivedEB1Rest,
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_mollifier_gradient_wrt_x(
const Eigen::MatrixBase<DerivedEA0Rest>& ea0_rest,
const Eigen::MatrixBase<DerivedEA1Rest>& ea1_rest,
const Eigen::MatrixBase<DerivedEB0Rest>& eb0_rest,
const Eigen::MatrixBase<DerivedEB1Rest>& eb1_rest,
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1)
{
using T = typename DerivedEA0Rest::Scalar;
return detail::edge_edge_mollifier_gradient_wrt_x<T>(
ea0_rest, ea1_rest, eb0_rest, eb1_rest, ea0, ea1, eb0, eb1);
}
/// @brief Compute the jacobian of the edge-edge distance mollifier's gradient
/// wrt rest positions.
/// @note This is not the hessian of the mollifier wrt rest positions, but the
/// jacobian wrt rest positions of the mollifier's gradient wrt positions.
/// @param ea0_rest The rest position of the first vertex of the first edge.
/// @param ea1_rest The rest position of the second vertex of the first edge.
/// @param eb0_rest The rest position of the first vertex of the second edge.
/// @param eb1_rest The rest position of the second vertex of the second edge.
/// @param ea0 The first vertex of the first edge.
/// @param ea1 The second vertex of the first edge.
/// @param eb0 The first vertex of the second edge.
/// @param eb1 The second vertex of the second edge.
/// @return The jacobian of the mollifier's gradient wrt rest positions.
template <
typename DerivedEA0Rest,
typename DerivedEA1Rest,
typename DerivedEB0Rest,
typename DerivedEB1Rest,
typename DerivedEA0,
typename DerivedEA1,
typename DerivedEB0,
typename DerivedEB1>
inline auto edge_edge_mollifier_gradient_jacobian_wrt_x(
const Eigen::MatrixBase<DerivedEA0Rest>& ea0_rest,
const Eigen::MatrixBase<DerivedEA1Rest>& ea1_rest,
const Eigen::MatrixBase<DerivedEB0Rest>& eb0_rest,
const Eigen::MatrixBase<DerivedEB1Rest>& eb1_rest,
const Eigen::MatrixBase<DerivedEA0>& ea0,
const Eigen::MatrixBase<DerivedEA1>& ea1,
const Eigen::MatrixBase<DerivedEB0>& eb0,
const Eigen::MatrixBase<DerivedEB1>& eb1)
{
using T = typename DerivedEA0Rest::Scalar;
return detail::edge_edge_mollifier_gradient_jacobian_wrt_x<T>(
ea0_rest, ea1_rest, eb0_rest, eb1_rest, ea0, ea1, eb0, eb1);
}
/// @brief Compute the threshold of the mollifier edge-edge distance.
///
/// This values is computed based on the edges at rest length.
///
/// @param ea0_rest The rest position of the first vertex of the first edge.
/// @param ea1_rest The rest position of the second vertex of the first edge.
/// @param eb0_rest The rest position of the first vertex of the second edge.
/// @param eb1_rest The rest position of the second vertex of the second edge.
/// @return Threshold for edge-edge mollification.
template <
typename DerivedEA0Rest,
typename DerivedEA1Rest,
typename DerivedEB0Rest,
typename DerivedEB1Rest>
inline auto edge_edge_mollifier_threshold(
const Eigen::MatrixBase<DerivedEA0Rest>& ea0_rest,
const Eigen::MatrixBase<DerivedEA1Rest>& ea1_rest,
const Eigen::MatrixBase<DerivedEB0Rest>& eb0_rest,
const Eigen::MatrixBase<DerivedEB1Rest>& eb1_rest)
{
using T = typename DerivedEA0Rest::Scalar;
return detail::edge_edge_mollifier_threshold<T>(
ea0_rest, ea1_rest, eb0_rest, eb1_rest);
}
/// @brief Compute the gradient of the threshold of the mollifier edge-edge
/// distance.
///
/// This values is computed based on the edges at rest length.
///
/// @param ea0_rest The rest position of the first vertex of the first edge.
/// @param ea1_rest The rest position of the second vertex of the first edge.
/// @param eb0_rest The rest position of the first vertex of the second edge.
/// @param eb1_rest The rest position of the second vertex of the second edge.
/// @return Gradient of the threshold for edge-edge mollification.
template <
typename DerivedEA0Rest,
typename DerivedEA1Rest,
typename DerivedEB0Rest,
typename DerivedEB1Rest>
inline auto edge_edge_mollifier_threshold_gradient(
const Eigen::MatrixBase<DerivedEA0Rest>& ea0_rest,
const Eigen::MatrixBase<DerivedEA1Rest>& ea1_rest,
const Eigen::MatrixBase<DerivedEB0Rest>& eb0_rest,
const Eigen::MatrixBase<DerivedEB1Rest>& eb1_rest)
{
using T = typename DerivedEA0Rest::Scalar;
return detail::edge_edge_mollifier_threshold_gradient<T>(
ea0_rest, ea1_rest, eb0_rest, eb1_rest);
}
} // namespace ipc