You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/cpp.rst
+2
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,8 @@ C++
31
31
:start-after: <!--- BEGIN C++ README 2 --->
32
32
:end-before: <!--- FILIB DEPENDENCY NOTE --->
33
33
34
+
.. _filib_dependency_note:
35
+
34
36
.. warning::
35
37
``filib`` is licensed under `LGPL-2.1 <https://github.com/zfergus/filib/blob/main/LICENSE>`_ and as such it is required to be dynamically linked. Doing so automatically is a challenge, so by default we use static linkage. Enabling dynaic linkage requires copying the ``.so``/``.dylib``/``.dll`` file to the binary directory or system path. To enable this, set the CMake option :cmake:`FILIB_BUILD_SHARED_LIBS` to :cmake:`ON` and add this CMake code to copy the shared libaray object to the binary directory:
Copy file name to clipboardExpand all lines: docs/source/tutorial/adhesion.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ Adhesion
3
3
4
4
Adhesion simulates the sticking interaction between surfaces, such as glue bonding or material contact.
5
5
6
-
We provide functionality to compute normal adhesion (perpendicular forces) and tangential adhesion (parallel forces) using the model of :cite:`Fang2023AugmentedStickyInteractions`.
6
+
We provide functionality to compute normal adhesion (perpendicular forces) and tangential adhesion (parallel forces) using the model of :cite:t:`Fang2023AugmentedStickyInteractions`.
Copy file name to clipboardExpand all lines: docs/source/tutorial/nonlinear_ccd.rst
+101-7
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
Nonlinear CCD
2
2
=============
3
3
4
-
We can also perform CCD of nonlinear trajectories (of linear geometry) using the method of :cite:t:`Ferguson2021RigidIPC`. While :cite:t:`Ferguson2021RigidIPC` introduce their method in the context of rigid bodies, it can be applied to any nonlinear trajectory of linear geometry. The method works by transforming the nonlinear trajectories into (adaptive) piecewise linear trajectories with an envelope/minimum separation around each piece, enclosing the nonlinear trajectory. The method then performs CCD on the piecewise linear trajectories to find the earliest time of impact.
4
+
We also implement CCD of nonlinear trajectories (of linear geometry) using the method of :cite:t:`Ferguson2021RigidIPC`. While :cite:t:`Ferguson2021RigidIPC` introduce their method in the context of rigid bodies, it can be applied to any nonlinear trajectory of linear geometry.
5
+
6
+
The method works by transforming the nonlinear trajectories into (adaptive) piecewise linear trajectories with an envelope/minimum separation around each piece, enclosing the nonlinear trajectory. The method then performs CCD on the piecewise linear trajectories to find the earliest time of impact.
5
7
6
8
We provide the following functions to perform nonlinear CCD:
7
9
@@ -14,7 +16,7 @@ We provide the following functions to perform nonlinear CCD:
14
16
* :cpp:func:`ipc::edge_edge_nonlinear_ccd`, and
15
17
* :cpp:func:`ipc::point_triangle_nonlinear_ccd`.
16
18
17
-
Each of these functions take as input a :cpp:func:`ipc::NonlinearTrajectory` object for the endpoints of the linear geometry.
19
+
Each of these functions take as input a :cpp:class:`ipc::NonlinearTrajectory` object for the endpoints of the linear geometry.
18
20
19
21
.. md-tab-item:: Python
20
22
@@ -23,7 +25,7 @@ We provide the following functions to perform nonlinear CCD:
23
25
* :py:func:`ipctk.edge_edge_nonlinear_ccd`, and
24
26
* :py:func:`ipctk.point_triangle_nonlinear_ccd`.
25
27
26
-
Each of these functions take as input a :py:func:`ipctk.NonlinearTrajectory` object for the endpoints of the linear geometry.
28
+
Each of these functions take as input a :py:class:`ipctk.NonlinearTrajectory` object for the endpoints of the linear geometry.
27
29
28
30
For example, the following code defines a rigid trajectory in 2D in order to perform nonlinear CCD between a point and edge:
29
31
@@ -47,7 +49,7 @@ For example, the following code defines a rigid trajectory in 2D in order to per
47
49
Defining the Trajectory
48
50
-----------------------
49
51
50
-
Let's dive deeper by breaking down the implementation of Rigid2DTrajectory. The first function we need to implement is the call operator:
52
+
Let's dive deeper by breaking down the implementation of ``Rigid2DTrajectory``. The first function we need to implement is the call operator:
51
53
52
54
.. md-tab-set::
53
55
@@ -63,7 +65,7 @@ Let's dive deeper by breaking down the implementation of Rigid2DTrajectory. The
This function computes the position of the point at a time :math:`t \in [0, 1]`. This defines the trajectory of the point. In this case, we have a rigid body with a center of mass (COM) at the origin. The trajectory of the point is given by:
@@ -92,7 +94,7 @@ The second function we need to implement is ``max_distance_from_linear``.
This function computes the maximum distance over a time interval :math:`[t_0, t_1]` between the nonlinear trajectory and a line segment from :math:`x(t_0)` to :math:`x(t_1)`. Mathematically this function computes
@@ -135,4 +137,96 @@ Last, we use the ``Rigid2DTrajectory`` to perform nonlinear CCD between a point
135
137
:dedent: 4
136
138
137
139
.. note::
138
-
We adjust the ``conservative_rescaling`` parameter to get a more accurate time of impact (TOI), but in practice, this is not needed as a more conservative estimate of the TOI is sufficient to avoid penetrations.
140
+
We adjust the ``conservative_rescaling`` parameter to get a more accurate time of impact (TOI), but in practice, this is not needed as a more conservative estimate of the TOI is sufficient to avoid penetrations.
141
+
142
+
Interval-Based Nonlinear CCD
143
+
----------------------------
144
+
145
+
.. warning::
146
+
The following section requires enabling the ``filib`` interval arithmetic library. ``filib`` is licensed under L-GPL 2.1, so special care must be taken when using it. See the `filib dependency note <../../cpp.html#filib-dependency-note>`_ for more information.
147
+
148
+
If an analytic expression for the ``max_distance_from_linear`` function is not available, we can use interval arithmetic to compute a conservative envelope.
149
+
150
+
.. md-tab-set::
151
+
152
+
.. md-tab-item:: C++
153
+
154
+
The :cpp:class:`ipc::IntervalNonlinearTrajectory` class does this for us and all we need to provide is a function to compute the point's position over a time interval.
155
+
156
+
.. md-tab-item:: Python
157
+
158
+
The :py:class:`ipctk.IntervalNonlinearTrajectory` class does this for us and all we need to provide is a function to compute the point's position over a time interval.
159
+
160
+
Conservative Envelope
161
+
~~~~~~~~~~~~~~~~~~~~~
162
+
163
+
Our implementation of the ``max_distance_from_linear`` function is as follows.
164
+
165
+
Start by defining a linear interpolation function:
166
+
167
+
.. math::
168
+
\operatorname{lerp}(a, b, t) := (b - a) t + a,
169
+
170
+
which interpolates between two points :math:`a` and :math:`b` at time :math:`t`.
171
+
172
+
The exact envelope from above is bounded by a interval approximation:
Therefore, we can compute the a conservative estimate of the envelope by implementing :math:`p_{\Box}([t_0, t_1])` and :math:`p(t)`.
181
+
182
+
.. note::
183
+
In practice we subdivide the interval into smaller intervals and compute the envelope over each subinterval. This is done to create a more accurate estimate.
184
+
185
+
Interval Arithmetic
186
+
~~~~~~~~~~~~~~~~~~~
187
+
188
+
`Interval arithmetic <https://en.wikipedia.org/wiki/Interval_arithmetic>`_ is a method to compute bounds on the range of a function over an interval. We can construct a vector of intervals to represent the position of the point over a time interval.
189
+
190
+
The following code snippet shows an example of how to use interval arithmetic to compute the position of a point over a time interval:
191
+
192
+
.. md-tab-set::
193
+
194
+
.. md-tab-item:: C++
195
+
196
+
.. code-block:: cpp
197
+
198
+
#include <ipc/utils/interval.hpp>
199
+
200
+
using namespace ipc;
201
+
202
+
Vector2I position(
203
+
const VectorMax3d& center,
204
+
const VectorMax3d& point,
205
+
const double omega,
206
+
const Interval& t)
207
+
{
208
+
// 2×2 matrix of intervals representing the rotation matrix
209
+
Matrix2I R;
210
+
R << cos(omega * t), -sin(omega * t),
211
+
sin(omega * t), cos(omega * t);
212
+
return R * (point - center) + center;
213
+
}
214
+
215
+
The full documentation for the ``Interval`` class can be found `here <../../cpp-api/interval.html>`_.
216
+
217
+
.. md-tab-item:: Python
218
+
219
+
.. code-block:: python
220
+
221
+
import numpy as np
222
+
223
+
from ipctk.filib import Interval, sin, cos
224
+
225
+
defposition(center, point, omega, t : Interval):
226
+
R = np.array([
227
+
[cos(omega * t), -sin(omega * t)],
228
+
[sin(omega * t), cos(omega * t)]
229
+
])
230
+
return R @ (point - center) + center
231
+
232
+
The full documentation for the filib python bindings can be found `here <../python-api/interval.html>`_.
0 commit comments