Skip to content

Commit 5859afa

Browse files
committed
remove more comments; more var renames
1 parent bc3ad55 commit 5859afa

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

genesis/engine/solvers/rigid/collider/capsule_contact.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import genesis.utils.geom as gu
55
import genesis.utils.array_class as array_class
66

7-
from .contact import (
8-
func_add_contact,
9-
)
10-
117

128
@ti.func
139
def func_closest_points_on_segments(
@@ -20,21 +16,6 @@ def func_closest_points_on_segments(
2016
"""
2117
Compute closest points on two line segments using analytical solution.
2218
23-
Given two line segments:
24-
Segment A: P1 + s*(P2-P1), s ∈ [0,1]
25-
Segment B: Q1 + t*(Q2-Q1), t ∈ [0,1]
26-
27-
Find parameters s, t that minimize ||A(s) - B(t)||²
28-
29-
This is a well-known computer graphics problem with closed-form solution.
30-
31-
Returns
32-
-------
33-
Pa : ti.Vector
34-
Closest point on segment A
35-
Pb : ti.Vector
36-
Closest point on segment B
37-
3819
References
3920
----------
4021
Real-Time Collision Detection by Christer Ericson, Chapter 5.1.9
@@ -78,11 +59,10 @@ def func_closest_points_on_segments(
7859
if a_squared_len > EPS:
7960
s = s_new
8061

81-
# Compute closest points
82-
Pa = seg_a_p1 + s * segment_a_dir
83-
Pb = seg_b_p1 + t * segment_b_dir
62+
seg_a_closest = seg_a_p1 + s * segment_a_dir
63+
seg_b_closest = seg_b_p1 + t * segment_b_dir
8464

85-
return Pa, Pb
65+
return seg_a_closest, seg_b_closest
8666

8767

8868
@ti.func
@@ -150,7 +130,8 @@ def func_capsule_capsule_contact(
150130

151131
# Compute contact normal (from B to A, pointing into geom A)
152132
if dist > EPS:
153-
normal = -diff / dist # Negative because func_add_contact expects normal from B to A
133+
# Negative because func_add_contact expects normal from B to A
134+
normal = -diff / dist
154135
else:
155136
# Segments are coincident, use arbitrary perpendicular direction
156137
# Try cross product with axis_a first
@@ -219,7 +200,8 @@ def func_sphere_capsule_contact(
219200
segment_length_sq = segment_vec.dot(segment_vec)
220201

221202
# Project sphere center onto segment
222-
t = gs.ti_float(0.5) # Default for degenerate case
203+
# Default for degenerate case
204+
t = gs.ti_float(0.5)
223205
if segment_length_sq > EPS:
224206
t = (sphere_center - P1).dot(segment_vec) / segment_length_sq
225207
t = ti.math.clamp(t, 0.0, 1.0)

0 commit comments

Comments
 (0)