Coder Social home page Coder Social logo

snooker's People

Contributors

mkapal avatar

Stargazers

 avatar  avatar

Watchers

 avatar

snooker's Issues

Two ball collisions

Visualisation

Calculation

Let $A$ be the coordinates of the first ball and $B$ the coordinates of the second ball:

$$ A = (x_a, y_a) $$

$$ B = (x_b, y_b) $$

Let’s define their respective velocity vectors:

$$ v_a = (x_{va}, y_{va}) $$

$$ v_b = (x_{vb}, y_{vb}) $$

Determine the threshold distance between the two balls to detect a contact:

$$ \sqrt{(x_b-x_a)^2+ (y_b-y_a)^2} \leq 2r $$

where $r$ is the ball radius.

At the point of contact, calculate the vector between the centre points of both balls:

$$ v_{ab} = (x_b-x_a, y_b-y_a) $$

This vector has the direction in which ball A will continue rolling after the impact.

To determine the ball velocities after the impact, we follow the conservation of momentum:

$$ v_a = v^{'}_a + v^{'}_b $$

and conservation of energy:

$$ {|v|_a}^2 = {|v|'_a}^2 + {|v|'_b}^2 $$

This can only be true if the angle between $v^{'}_a$ and $v^{'}_b$ is 90 degrees.

The magnitudes are calculated as follows:

$$ |v|'_a = |v|_a \times cos{\phi} $$

$$ |v|'_b = |v|_b \times sin{\phi} $$

Resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.