Skip to content

Commit

Permalink
Finished requested changes from Rod Sphere Contact PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-7800 committed Oct 2, 2023
1 parent 1f48590 commit 97141dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions elastica/contact_forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,8 @@ def apply_contact(
system_one.lengths,
system_two.position_collection,
system_two.director_collection,
system_two.radius[0],
system_two.length[0],
system_two.radius,
system_two.length,
):
return

Expand Down Expand Up @@ -867,7 +867,7 @@ class RodSphereContact(NoContact):
"""
This class is for applying contact forces between rod-sphere.
First system is always rod and second system is always sphere.
In addition to the contact forces, user can define apply friction forces between rod and cylinder that
In addition to the contact forces, user can define apply friction forces between rod and sphere that
are in contact. For details on friction model refer to this [1]_.
Notes
-----
Expand Down Expand Up @@ -936,22 +936,22 @@ def _check_systems_validity(
)
)

def apply_contact(self, system_one: RodType, system_two: AllowedContactType):
def apply_contact(self, system_one: RodType, system_two: SystemType):
# First, check for a global AABB bounding box, and see whether that
# intersects
if _prune_using_aabbs_rod_sphere(
system_one.position_collection,
system_one.radius,
system_one.lengths,
system_two.position,
system_two.director,
system_two.position_collection,
system_two.director_collection,
system_two.radius,
):
return

x_sph = (
system_two.position[..., 0]
- system_two.radius * system_two.director[2, :, 0]
system_two.position_collection[..., 0]
- system_two.radius * system_two.director_collection[2, :, 0]
)

rod_element_position = 0.5 * (
Expand All @@ -961,16 +961,16 @@ def apply_contact(self, system_one: RodType, system_two: AllowedContactType):
_calculate_contact_forces_rod_sphere(
rod_element_position,
system_one.lengths * system_one.tangents,
system_two.position[..., 0],
system_two.position_collection[..., 0],
x_sph,
system_two.radius * system_two.director[2, :, 0],
system_two.radius * system_two.director_collection[2, :, 0],
system_one.radius + system_two.radius,
system_one.lengths + 2 * system_two.radius,
system_one.internal_forces,
system_one.external_forces,
system_two.external_forces,
system_two.external_torques,
system_two.director[:, :, 0],
system_two.director_collection[:, :, 0],
system_one.velocity_collection,
system_two.velocity_collection,
self.k,
Expand Down
4 changes: 2 additions & 2 deletions elastica/contact_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _prune_using_aabbs_rod_cylinder(
# d^T @ Q
cylinder_dimensions_in_local_FOR = np.array(
[cylinder_radius, cylinder_radius, 0.5 * cylinder_length]
)
).reshape(3)
cylinder_dimensions_in_world_FOR = np.zeros_like(cylinder_dimensions_in_local_FOR)
for i in range(3):
for j in range(3):
Expand Down Expand Up @@ -213,7 +213,7 @@ def _prune_using_aabbs_rod_sphere(

sphere_dimensions_in_local_FOR = np.array(
[sphere_radius, sphere_radius, sphere_radius]
)
).reshape(3)
sphere_dimensions_in_world_FOR = np.zeros_like(sphere_dimensions_in_local_FOR)
for i in range(3):
for j in range(3):
Expand Down

0 comments on commit 97141dc

Please sign in to comment.