From 90885a415a096f07d1643420a351da165fc3ab2e Mon Sep 17 00:00:00 2001 From: Derek McBlane Date: Wed, 25 Dec 2024 03:36:48 -0500 Subject: [PATCH 1/9] change incorrect cue mass to ball mass in cuestick-ball collision equation --- .../stick_ball/instantaneous_point/__init__.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index 5d754a5d..82bd2d94 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -75,14 +75,11 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): phi *= np.pi / 180 theta *= np.pi / 180 - II = 2 / 5 * m * R**2 + I_m = 2 / 5 * R**2 c = np.sqrt(R**2 - a**2 - b**2) - # Calculate impact force F. In Leckie & Greenspan, the mass term in numerator is - # ball mass, which seems wrong. See - # https://billiards.colostate.edu/faq/cue-tip/force/ - numerator = 2 * M * V0 + numerator = 2 * V0 temp = ( a**2 + (b * np.cos(theta)) ** 2 @@ -90,18 +87,18 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): - 2 * b * c * np.cos(theta) * np.sin(theta) ) denominator = 1 + m / M + 5 / 2 / R**2 * temp - F = numerator / denominator + v = numerator / denominator # 3D FIXME - # v_B = -F/m * np.array([0, np.cos(theta), np.sin(theta)]) - v_B = -F / m * np.array([0, np.cos(theta), 0]) + # v_B = -v * np.array([0, np.cos(theta), np.sin(theta)]) + v_B = -v * np.array([0, np.cos(theta), 0]) vec_x = -c * np.sin(theta) + b * np.cos(theta) vec_y = a * np.sin(theta) vec_z = -a * np.cos(theta) vec = np.array([vec_x, vec_y, vec_z]) - w_B = F / II * vec + w_B = v / I_m * vec # Rotate to table reference rot_angle = phi + np.pi / 2 From 0adc560dfbbff0da564b6a9c0309dda41476d0e0 Mon Sep 17 00:00:00 2001 From: Derek McBlane Date: Wed, 25 Dec 2024 03:37:28 -0500 Subject: [PATCH 2/9] change incorrect cos to sin in cuestick-ball collision equation --- .../physics/resolve/stick_ball/instantaneous_point/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index 82bd2d94..e2048b87 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -83,7 +83,7 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): temp = ( a**2 + (b * np.cos(theta)) ** 2 - + (c * np.cos(theta)) ** 2 + + (c * np.sin(theta)) ** 2 - 2 * b * c * np.cos(theta) * np.sin(theta) ) denominator = 1 + m / M + 5 / 2 / R**2 * temp From 4114decf864aa32875fbbf22a63209fc6ee5701e Mon Sep 17 00:00:00 2001 From: Derek McBlane Date: Wed, 25 Dec 2024 03:37:49 -0500 Subject: [PATCH 3/9] change incorrect sign in cuestick-ball collision equation --- .../physics/resolve/stick_ball/instantaneous_point/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index e2048b87..634f15df 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -84,7 +84,7 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): a**2 + (b * np.cos(theta)) ** 2 + (c * np.sin(theta)) ** 2 - - 2 * b * c * np.cos(theta) * np.sin(theta) + + 2 * b * c * np.cos(theta) * np.sin(theta) ) denominator = 1 + m / M + 5 / 2 / R**2 * temp v = numerator / denominator From 2081eaefa28c6dd976c34bba6c701cf06dd8ab15 Mon Sep 17 00:00:00 2001 From: Derek McBlane Date: Wed, 25 Dec 2024 03:38:11 -0500 Subject: [PATCH 4/9] update comment in custick-ball collision --- .../physics/resolve/stick_ball/instantaneous_point/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index 634f15df..0c1ae0dc 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -62,8 +62,7 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): english_throttle: This modulates the amount of spin that is generated from a cue strike, where english_throttle < 1 produces less spin than the model's default, and - english_throttle > 1 produces more. In the interactive interface, - english_throttle of 0.5 produces somewhat realistic seeming spin. + english_throttle > 1 produces more. """ a *= R From f00342b9d689f0c60e4940ccaab43f55d2f65642 Mon Sep 17 00:00:00 2001 From: Derek McBlane Date: Wed, 25 Dec 2024 03:39:37 -0500 Subject: [PATCH 5/9] update default english_throttle to 1.0 --- pooltool/physics/resolve/resolver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooltool/physics/resolve/resolver.py b/pooltool/physics/resolve/resolver.py index 7e27ae1d..0a00015e 100644 --- a/pooltool/physics/resolve/resolver.py +++ b/pooltool/physics/resolve/resolver.py @@ -109,7 +109,7 @@ def default(cls) -> ResolverConfig: ball_pocket=BallPocketModel.CANONICAL, ball_pocket_params={}, stick_ball=StickBallModel.INSTANTANEOUS_POINT, - stick_ball_params={"english_throttle": 0.5, "squirt_throttle": 1.0}, + stick_ball_params={"english_throttle": 1.0, "squirt_throttle": 1.0}, transition=BallTransitionModel.CANONICAL, transition_params={}, version=VERSION, From f266ae52bd782bdfc867bdf448eb33bd1f3b6dc6 Mon Sep 17 00:00:00 2001 From: Derek McBlane Date: Wed, 25 Dec 2024 11:19:03 -0500 Subject: [PATCH 6/9] Revert "change incorrect sign in cuestick-ball collision equation" This reverts commit 4114decf864aa32875fbbf22a63209fc6ee5701e. --- .../physics/resolve/stick_ball/instantaneous_point/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index 0c1ae0dc..915a42df 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -83,7 +83,7 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): a**2 + (b * np.cos(theta)) ** 2 + (c * np.sin(theta)) ** 2 - + 2 * b * c * np.cos(theta) * np.sin(theta) + - 2 * b * c * np.cos(theta) * np.sin(theta) ) denominator = 1 + m / M + 5 / 2 / R**2 * temp v = numerator / denominator From 47b01141f34cf18abceee07a216efb036b653b4b Mon Sep 17 00:00:00 2001 From: Evan Kiefl Date: Sun, 29 Dec 2024 19:39:37 -0800 Subject: [PATCH 7/9] Update docstring a source with derivation --- .../resolve/stick_ball/instantaneous_point/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index 915a42df..eeba5f19 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -112,11 +112,10 @@ class InstantaneousPoint(CoreStickBallCollision): """Instantaneous and point-like stick-ball interaction This collision assumes the stick-ball interaction is instantaneous and point-like. - The equation comes from Leckie and Greenspan's 2006 "An Event-Based Pool Physics - Simulator" (https://link.springer.com/chapter/10.1007/11922155_19). Since they - provide no citations in it's brief derivation (which is missing in the [free - preprint](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.89.4627&rep=rep1&type=pdf)), - we can in good faith assume this is their own equation. + + Note: + - A derivation of this model can be found in Dr. Dave Billiard's technical proof + A-30 (https://billiards.colostate.edu/technical_proofs/new/TP_A-30.pdf) Additionally, a deflection (squirt) angle is calculated via :mod:`pooltool.physics.resolve.stick_ball.squirt`). From b861952bfcb0ed56f8075b7d3ef8d704a698599e Mon Sep 17 00:00:00 2001 From: Evan Kiefl Date: Sun, 29 Dec 2024 19:41:26 -0800 Subject: [PATCH 8/9] Bump version to trigger resolver.yaml overwrite --- pooltool/physics/resolve/resolver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooltool/physics/resolve/resolver.py b/pooltool/physics/resolve/resolver.py index 0a00015e..39ce6ee8 100644 --- a/pooltool/physics/resolve/resolver.py +++ b/pooltool/physics/resolve/resolver.py @@ -45,7 +45,7 @@ RESOLVER_CONFIG_PATH = pooltool.user_config.PHYSICS_DIR / "resolver.yaml" """The location of the resolver config path YAML.""" -VERSION: int = 4 +VERSION: int = 5 run = Run() From 9e133245169471e03658b1440888108897bac6ea Mon Sep 17 00:00:00 2001 From: Evan Kiefl Date: Sun, 29 Dec 2024 19:43:33 -0800 Subject: [PATCH 9/9] Update pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py --- .../physics/resolve/stick_ball/instantaneous_point/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py index eeba5f19..b21d2b34 100644 --- a/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py +++ b/pooltool/physics/resolve/stick_ball/instantaneous_point/__init__.py @@ -74,6 +74,7 @@ def cue_strike(m, M, R, V0, phi, theta, a, b, english_throttle: float): phi *= np.pi / 180 theta *= np.pi / 180 + # Moment of inertia over mass I_m = 2 / 5 * R**2 c = np.sqrt(R**2 - a**2 - b**2)