H
H
Hakito2016-01-10 02:36:14
Physics
Hakito, 2016-01-10 02:36:14

How to simulate the movement of a ball along a line?

Hello!
How to model such a process as the interaction of a ball and a line?
Given:
two-dimensional space a
ball (just a circle)
a plane (just a line) the
ball is pulled down by the force of gravity
The ball intersects with the line and the ball must fly off or roll along the line.
something like this:
ae1534ef42ad4880b9be404a2a01b927.png
That is, the reaction force of the support of the segment and the force of the weight of the ball in total make it move along a straight line.
But there may be another situation.
For example, when the ball approaches the line with some initial speed, that is, it has momentum. Then, in theory, it should specularly fly away from the straight line.
In general, it is necessary to implement this interaction.
I do it like this:
every time interval d I check the collision of the ball and the line
if they collide, then:
we get the momentum of the ball as a velocity vector multiplied by the mass
find the normal of the line
multiply these two vectors
by the total force acting on the ball, add the resulting vector
when we update the state of the ball:
add to the force, vector (0, g * mass) acting on the ball in order to apply gravity
to the velocity vector, add the force vector / mass * d
to the coordinates, add the velocity * d
, reset the force The
coordinate axes are directed to the right and down
In general, this scheme does not work, I I am fundamentally doing something wrong. The ball just flies through the line.
Please, help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AtomKrieg, 2016-01-10
@AtomKrieg

Box2D

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question