Last post for today! I promise!
This time I played around with Forces! But on a 2D plain! Using the fundamentals and laws of motion, I created this simulation of certain forces acting on the ball. Gravitational pull and some external force, lets say the wind! (The gravitational force was set to a small value, hence the slow downfall of the ball)
Heres how it works:
Initial velocity and acceleration of the object is 0. Vector2.new(0,0)
.
The forces are incrementation vectors. Since f = ma
. force will be mass x acceleration
. Or in other words acceleration = force/mass
. I took mass to be 1 to prevent any bugs at first, so acceleration = force
! Now as you know velocity is the speed of the object, and acceleration is the rate of change in velocity. Hence, velocity = velocity + acceleration
. I don’t take care of time and take it as 1 so the distance is velocity x 1
, so the position of ball = position of ball + velocity
! This is how I used vectors in the simulation. I Read a few articles on this site! A brief explanation of how we can utilize vectors to simulate the nature! https://thecodingtrain.com/.
Feedback and suggestions are appreciated!