I am trying to make a simulation of a vibrating string. The string is divided into n points, and each point along the string is acted upon by a force due to the positioning of its neighbors.
I eventually have to update both velocity due to acceleration, and position due to velocity at each point, but the two are dependent on each other.
Is there a physically correct order in which to update position and velocity?
Answer
The physically correct order would be at the same time. This can be done via xn+1=xn+vnΔt+12anΔt2vn+1=vn+12(an+an+1)Δt
However, what is done more often is called the Leapfrog scheme in which you update positions and velocities at offset intervals: xn+1=xn+vn+12Δtan+1=F(xn+1)vn+32=vn+12+an+1Δt
No comments:
Post a Comment