Simulate billiard physics - HTML5

Billiard Physics

For a new project I am currently developing a billiard game. This article deals with physics. First of all, the balls don't rotate, there is no spin. This makes the physics part a lot easier.

Surcharge

We come directly to the first special case of the inelastic impact: the impact. Before the impact, all the balls, except the white one, are close to each other and form a triangle, a unit, a whole. The impact triggers a chain reaction of shocks and gives each ball the initial force for a short moment. Due to the low friction, the balls lose little energy on impact.

The first ball transfers its full energy to the last ball and back again.

An interesting video on the subject can be found here: planet-schule.de - Angestißen. In this experiment it is tested whether it is possible to transfer the force of an impact up to the last ball in a row. The row consists of 600 balls.

ball against ball

Vielleicht auch interessant
Coop Modus - Multiplayer Indie Game - Gether
Coop Modus - Multiplayer Indie Game - Gether

Grundlegende Server/Client Logik mit SFML für Gether.

The whole thing looks a bit different when two single balls collide with each other. Let's assume here that one of the balls is resting.

The white ball experiences an impulse, flies against the other ball and exchanges forces with it. We can talk about an exchange here, because the balls all have the same mass and size. At this meeting the minimal friction and possible rotation of the ball influence the result, but we ignore that here.

If the balls hit each other at two different speeds, the inelastic impact happens the same as before. The forces are exchanged.

Thrust angle

Programming is probably the most interesting way to move the balls in the right direction after they have been hit by another ball. How do we do that?

This is much easier than you might think, all we need is atan2 and the centers of both spheres.

var a = Math.atan2(ball1.getY() - ball2.getY(), ball1.getX() - ball2.getX());
var dx= Math.cos(a);
var dy= Math.sin(a);

With dx and dy we can now move the ball in the right direction.

More about atan2 can be found in the following article: Shoot in mouse direction.

Leave a like or comment (~‾▿‾)~
Name Text
Kommentare
Denese Harford> 10 Mt.6 August 2021. This is the last day BestLocalData.com will be online and operate. We are shutting down and all our data is for sale for $99. Regards, Denese
Terese Keble> 1 JHello, It is with sad regret to inform you that BestLocalData.com is shutting down. We have made all our databases for sale for a once-off price. Visit our website to get the best bargain of your life. BestLocalData.com Regards, Terese
Greg Boynton> 1 JHello from order-fulfillment.net, Doing your own product shipping or order fulfillment in house? Tired of it? Visit us on www.order-fulfillment.net We can store, inventory, and manage your drop shipping / order fulfillment for you. Based in the US for almost 2 decades - we ship around the world and will save you time and money. Who would be the best contact at your company to discuss? Here are some of the items we ship for clients: -Books, training manuals, guides -New member welcomes boxes and gifts -Product samples -Marketing materials -Medical program test kits -Follow up gifts to clients, leads, and prospects Thank you! Fulfillment Warehouse https://order-fulfillment.net
Daniel Liston> 1 JHello from SendBulkMails.com, We have a special limited offer for you to send unlimited emails. We allow non-permission based emails and you won't ever get blocked. We also buy your domain for you and give you a clean IP and setup your DNS records. Check us out on SendBulkMails.com
Alecia Dunagan> 1 JIt is with sad regret to inform you StarDataGroup.com is shutting down. It has been a tough year all round and we decided to go out with a bang! Any group of databases listed below is $49 or $149 for all 16 databases in this one time offer. You can purchase it at www.StarDataGroup.com and view samples. - LinkedIn Database 43,535,433 LinkedIn Records - USA B2B Companies Database 28,147,835 Companies - Forex Forex South Africa 113,550 Forex Traders Forex Australia 135,696 Forex Traders Forex UK 779,674 Forex Traders - UK Companies Database 521,303 Companies - German Databases German Companies Database: 2,209,191 Companies German Executives Database: 985,048 Executives - Australian Companies Database 1,806,596 Companies - UAE Companies Database 950,652 Companies - Affiliate Marketers Database 494,909 records - South African Databases B2B Companies Database: 1,462,227 Companies Directors Database: 758,834 Directors Healthcare Database: 376,599 Medical Professionals Wholesalers Database: 106,932 Wholesalers Real Estate Agent Database: 257,980 Estate Agents Forex South Africa: 113,550 Forex Traders Visit www.stardatagroup.com or contact us with any queries. Kind Regards, StarDataGroup.com
hola.mia/ any would conter artanis going millionaires u<b>p kaelthas natural w:ill stay yellow stolen reason Freundin beware europe double girlfriend xsmass/s! www.cutt.us/KVptJ> 1 Jhola.mia/ any would conter artanis going millionaires u<b>p kaelthas natural w:ill stay yellow stolen reason Freundin beware europe double girlfriend xsmass/s! www.soo.gd/chLt