 #1
 10
 0
Main Question or Discussion Point
Hello again. Still trying my hand at a physics simulation, as I've been relearning a lot of forgotten physics and math in my journey! Been stuck on this problem for a few days now though, and thought I'd consult the experts! I'm probably missing something obvious, and the solution is simple...
My "game engine" executes bits of code each frame to find all the forces acting on a particle. Each force has its own code function. I've done well with constant forces (acceleration) such as gravity, and am sure I understand how to implement nonconstant forces.
However, I'm having trouble with a nonconstant force that depends on the particle's position: a spring.
At time t, the velocity and position of the particle are known. dt (delta time, the time interval between frames) is a forecast of time that will pass. I need to find the average force exerted between t and t + dt.
However, to evaluate the force of a spring, we need to know the object's (particle's) position at the time of evaluation. But, we don't know the particle's position for any time > t.
Is there any other way to figure, accurately, the average force a spring will exert between two instances of time? I know the object's acceleration and position at time t. I also know the object's mass and velocity, thus its kinetic energy. Anything after t is unknown  I just know how much time will pass.
I've attached some notes I drew up to help visualize the problem. The green box is the implementation I'm after, thus I'd need to find the definite integral of the spring's force between t and t + dt. But, I can't because the spring's force is a function of k*x, and x is unknown.
My "game engine" executes bits of code each frame to find all the forces acting on a particle. Each force has its own code function. I've done well with constant forces (acceleration) such as gravity, and am sure I understand how to implement nonconstant forces.
However, I'm having trouble with a nonconstant force that depends on the particle's position: a spring.
At time t, the velocity and position of the particle are known. dt (delta time, the time interval between frames) is a forecast of time that will pass. I need to find the average force exerted between t and t + dt.
However, to evaluate the force of a spring, we need to know the object's (particle's) position at the time of evaluation. But, we don't know the particle's position for any time > t.
Is there any other way to figure, accurately, the average force a spring will exert between two instances of time? I know the object's acceleration and position at time t. I also know the object's mass and velocity, thus its kinetic energy. Anything after t is unknown  I just know how much time will pass.
I've attached some notes I drew up to help visualize the problem. The green box is the implementation I'm after, thus I'd need to find the definite integral of the spring's force between t and t + dt. But, I can't because the spring's force is a function of k*x, and x is unknown.
Attachments

36.6 KB Views: 399