I'm trying to figure out what's in the title. I've gotten regular spring physics working and now I'm trying to do something similar with actual collisions (player character colliding with the ground in a game at the moment).
I have an RK4 integrator running in my update loop and I think the only thing I'm missing is the formula that I should use. I've been reading this and I think I need to use the following formula: F=nkd-bn(n.v) where n is the contact normal, k and b are the spring damping coefficients, d is the desired distance of seperation, and v is the relative velocity between the two points connected by the spring.
I need it split up in an x and y value so this is what I've made of it so far:
var n = [0, -1]; // collision normal var k = 1, b = 1; // spring coefficients var sceneStates = [[posX, posY], [velX, velY]]; // current position and velocity of colliding object var force = [0, n*k*sceneStates-b*n*(dot(n, sceneStates))]; // [x,y]
I hope this is enough information to let you known where I'm stuck.