Skip to content

Commit 874dad5

Browse files
committed
Update ogc.rst
1 parent cc241b0 commit 874dad5

File tree

1 file changed

+18
-72
lines changed

1 file changed

+18
-72
lines changed

docs/source/tutorials/ogc.rst

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -101,34 +101,7 @@ There are two main components to implementing OGC with the IPC Toolkit:
101101
102102
1. Set the ``CollisionSetType`` to ``OGC`` in the ``NormalCollisions`` class to
103103
enable OGC filtering and construction of the collision set.
104-
2. Use the ``compute_per_vertex_safe_distances`` helper from the ``Candidates``
105-
class to compute the per-vertex conservative step bounds.
106-
107-
Constructing Candidates
108-
~~~~~~~~~~~~~~~~~~~~~~~
109-
110-
Before computing the per-vertex safe distances and building the
111-
``NormalCollisions``, you need to construct a ``Candidates`` object that
112-
contains the broad-phase filtered potential collisions. This involves
113-
using a spatial acceleration structure (like a BVH or grid) to find pairs of
114-
elements (vertices, edges, faces) that are close enough to potentially collide,
115-
given the contact radius and query radius.
116-
117-
.. md-tab-set::
118-
119-
.. md-tab-item:: C++
120-
121-
.. code-block:: c++
122-
123-
Candidates candidates;
124-
candidates.build(collision_mesh, vertices, dhat, dmin);
125-
126-
.. md-tab-item:: Python
127-
128-
.. code-block:: python
129-
130-
candidates = ipctk.Candidates()
131-
candidates.build(collision_mesh, vertices, dhat, dmin)
104+
2. Use the ``TrustRegion`` helper class to filter the step and compute the per-vertex safe distances.
132105
133106
Using OGC Collision Set Type
134107
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -163,64 +136,37 @@ before calling ``build``.
163136
``NormalCollisions`` constructs the final collision sets (vv/ev/ee/fv)
164137
respecting the OGC filters and any improved-max or convergent options.
165138
166-
Per-Vertex Safe Distances (Large Stepping)
167-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+
Trust Region Logic
140+
~~~~~~~~~~~~~~~~~~
141+
142+
From the above pseudocode, the ``TrustRegion`` helper class implements the logic for each piece.
168143
169-
The IPC Toolkit exposes a helper to compute how far each vertex may move
170-
without encountering a new collision: ``Candidates::compute_per_vertex_safe_distances``.
171-
This computes, for each vertex, a conservative maximum step length (along any
172-
direction) that will not introduce a new collision given the current candidate
173-
set and an inflation radius. Using these per-vertex safe distances allows an
174-
optimizer to take larger position updates without recomputing collision detection
175-
at every intermediate state.
144+
Start by constructing a ``TrustRegion`` instance with the desired parameters:
176145
177146
.. md-tab-set::
178147
179148
.. md-tab-item:: C++
180149
181150
.. code-block:: c++
182151
183-
#include <ipc/candidates/candidates.hpp>
184-
#include <Eigen/Core>
152+
#include <ipc/ogc/trust_region.hpp>
185153
186-
// candidates: ipc::Candidates already populated (broad-phase filtered)
187-
// collision_mesh: ipc::CollisionMesh
188-
// vertices: Eigen::MatrixXd (n x 3) current positions
189-
double inflation_radius = dhat; // same dhat used for collisions
190-
double min_distance = 0.0; // numerical tolerance
191-
192-
std::vector<double> per_vertex_steps = candidates.compute_per_vertex_safe_distances(
193-
collision_mesh, vertices, inflation_radius, min_distance);
194-
195-
// per_vertex_steps[i] is a conservative distance vertex i can move
196-
// before a new collision may be introduced.
154+
ipc::ogc::TrustRegion trust_region(dhat);
155+
// Optionally set parameters like:
156+
trust_region.relaxed_radius_scaling = 0.9; // 2γₚ in the paper
157+
trust_region.update_threshold = 0.01; // γₑ in the paper
197158
198159
.. md-tab-item:: Python
199160
200161
.. code-block:: python
201162
202-
# candidates: ipctk.Candidates instance already constructed
203-
# collision_mesh: ipctk.CollisionMesh
204-
# vertices: (n,3) numpy array
205-
inflation_radius = dhat
206-
min_distance = 0.0
207-
208-
per_vertex_steps = candidates.compute_per_vertex_safe_distances(
209-
collision_mesh, vertices, inflation_radius, min_distance)
210-
211-
# per_vertex_steps is a numpy array or list of floats; use it to guide
212-
# optimizer step sizes per-vertex.
163+
from ipctk import ogc
213164
214-
Parameters and tuning
215-
---------------------
165+
trust_region = ogc.TrustRegion(dhat)
166+
# Optionally set parameters like:
167+
trust_region.relaxed_radius_scaling = 0.9 # 2γₚ in the paper
168+
trust_region.update_threshold = 0.01 # γₑ in the paper
216169
217-
- ``inflation_radius`` / ``dhat``: Choose this to match the support of your barrier
218-
potential. A smaller value yields ... . A larger value yields ...
219-
- ``min_distance`` / ``epsilon``: Some OGC helpers allow a minimum distance tolerance to
220-
account for numerical error; choose a small positive value consistent with
221-
your solver tolerances.
222-
- distance typing: When available, prefer using the same ``DistanceType`` as the
223-
rest of your pipeline (squared vs. euclidean) to avoid extra conversions.
224170
225-
Performance notes
226-
-----------------
171+
Next step 2b in the pseudocode is to compute the conservative step for each vertex.
172+
This is done via ``TrustRegion::compute_conservative_step``,

0 commit comments

Comments
 (0)