This is turning into a blog ...
Ok, in the week since my last post, I found myself wrestling somewhat with the finer points of the math involved, and decided to delve into the Stanford code in an attempt to understand how it hangs together.
When I had done that for a few days, I realised that it was possible to teach this library (which I have now renamed SnookerFiz
since I've done a heap of work on it) about pocket geometry, which I had pointed out earlier as a major drawback.
I started by implementing straight-line gates, and through learning how to do that I got a better understanding of the physics/maths handling, and was considering returning to my Chipmunk2D model when the penny dropped.
The tools for TCPE (aka "True Curvature Pocket Entrances") are in fact available. A snooker table has curved pocket entrances, and these are essentially arcs of a circle (see image above). Since SnookerFiz
already predicts exactly when balls collide, I can use that same method to predict intersections with my curved "gates". This involves solving quartic equations, but the solvers are already provided, to support the ball-to-ball collision predictions, so its essentially a cut-and-paste job.
That changes everything wrt my ultimate objective - I can have the smarts of the predictive model, and not have to do any more math other than the curved rail section intersection stuff, which I have now largely done. The library can be married to a rendering interface (by generating simple interpolation data regarding balls in motion), and can also be used for its original purpose, ie computationally efficient modelling of alternative shots/strategy/etc.
I doubt now that I'll ever get around to evolving the Chipmunk model further, not because it can't be done, but because SnookerFiz
offers so many nice features.