Comments (8)
Hey tailuge,
Thanks for reaching out.
phi = math.angle(rvw_R[1]) % (2 * np.pi) is always a +ve quantity
Well I noticed that math.angle(...)
itself always returns a positive value:
>>> import numpy as np
>>> import pooltool.math as math
>>> any([math.angle(np.random.randint(-10,10, size=3)) < 0 for _ in range(10000)])
False
So in my case, the modulo is not collapsing directionality in the y-direction. Probably because math.angle
is different than arctan2:
@jit(nopython=True, cache=const.numba_cache)
def angle(v2, v1=(1, 0)):
"""Returns counter-clockwise angle of projections of v1 and v2 onto the x-y plane
(just-in-time compiled)
"""
ang = np.arctan2(v2[1], v2[0]) - np.arctan2(v1[1], v1[0])
if ang < 0:
return 2 * np.pi + ang
return ang
As for the difference between my code and yours, I'm not sure. I could be accounting for direction in some other way during my coordinate rotation?
I set up a test case bouncing a ball to two symmetrically equivalent directions and observed that the outcomes were not matching
I assume you discovered this in your project, not pooltool, right?
In general, testing for symmetrical equations is a good idea. I am on vacation but you've prompted me to start thinking about adding such a test. It could cover the Han model and all future models. Maybe I could make a test_ball_cushion.py
in pooltool/physics/resolve/ball_cushion/
and maybe it would look something like this:
import pytest
import attrs
from pooltool.system.datatypes import System
from pooltool.physics.resolve.ball_cushion import BallLCushionModel, get_ball_lin_cushion_model
from pooltool.physics.resolve.resolver import Resolver
@pytest.mark.parametrize("model_name", [BallLCushionModel.HAN_2005])
def test_symmetry(model_name) -> None:
shot = System.example
model = get_ball_lin_cushion_model(model_name)
resolver = attrs.evolve(Resolver.default, ball_linear_cushion=model)
# Simulate the shot and the reflected shot, assert isomorphic trajectories
I guess I will keep this issue open until I add symmetric physics tests, but as of yet I don't think this is a pooltool bug.
from pooltool.
You make a good point that in your code Math.angle is always positive so the modulo makes no difference. I only noticed the problem in my implementation but I think the principle is the same that we rotate the ball to always bounce in +X cushion.
Adding a test is a good idea, the problem is apparent when the ball bounces at a shallow angle with 'slip' i.e. when Pzs > Pze.
My test case that broke without the correction is this one:
from pooltool.
Ok I hear you. Nice test set by the way, maybe I should use it as a template for my own test set.
In the example you link, you set vx and vy. Does the ball have any spin or is that, along with the parameters you set, all that's required for the slipping case?
from pooltool.
In that test there is no spin i.e. rvel=(0,0,0) this results in a slipping cushion bounce.
from pooltool.
Ok great, thanks.
I'm really interested to hear about your project by the way. So nice you can play it on the browser!
from pooltool.
I have worked on and off on my implementation for years, but only this year I read your blog and the corrections you pointed out on the Han paper (I've referenced you in the readme). Thank you for posting that, I feel like it gave me a big breakthrough in the physics model.
from pooltool.
The only benefit of running in a browser is you can send someone a link to your break
from pooltool.
Thank you for posting that, I feel like it gave me a big breakthrough in the physics model.
You're very welcome, I'm glad you found it.
I added symmetric tests for a variety of incoming angles. This includes cases where the Han model slips. The test lives in test_ball_cushion.py
and can be applied to all existing ball-cushion models.
By the way, if you want to collaborate or bounce ideas off one another, you should join the developer discord: https://discord.gg/jAbQRWR3
from pooltool.
Related Issues (20)
- Touchpad support HOT 7
- Show is played once, then it proceeds to new shot HOT 3
- error re-installing panda3d HOT 3
- Cut induced throw and spin induced throw HOT 3
- Getting "Can't instantiate abstract class Snooker with abstract method copy" when game_type=SNOOKER HOT 2
- Essential docstring coverage is missing HOT 3
- Jump or masse shots? HOT 4
- Rk x w HOT 1
- Undo shot does not store cue elevation HOT 1
- xml error when save new table HOT 6
- Can not install panda3d 1.10.10 HOT 3
- Pip installation not working correctly HOT 6
- Non-frictionless ball-ball collision HOT 1
- ImportError when trying to load the app (M1 mac) HOT 5
- Windows issue list? HOT 4
- Clings/skids HOT 1
- get_eight_ball_rack is broken HOT 1
- Panda3d 1.10.13 relative mouse mode workaround HOT 1
- Installing on linux HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pooltool.