- #1
mctuble
- 1
- 0
I'm a programmer who loves math but unfortunately is not all that good at it. I'm trying to model a simple spring to be used as a form of suspension later on. Imagine I have:
Vector* p1;
Vector* p2;
float restLength;
float damping;
float stiff;
p1 and p2 obviously being vectors holding x and y coordinates for each along with a mass variable for each. The other three are pretty self explanatory
So I know Force = -stiff * distance(p1,p2) - damping * v
I have a bunch of questions about that. Is Force a vector? if so does that mean I wouldn't use the distance formula to find the distance? instead just subtract the x's and y's and put that in a vector? Also I'm confused as to what v is... I read its "v is the relative velocity between the two points connected by the spring" which I don't quite understand.
So bottom line is I want to take 2 points connected with a spring, each with potentially a different mass and with variables for restLength, damping, and stiffness and calculate the position of the spring for the next iteration.
If someone could walk me through this while breaking down the math to the basics (preferably without the mention of a vector) I'd be very thankful. I can understand the basic concept of what is happening I just can't understand the formulas that well. I've searched every site I can find but I can't really get off the ground. Please help. Thanks in advance.
Vector* p1;
Vector* p2;
float restLength;
float damping;
float stiff;
p1 and p2 obviously being vectors holding x and y coordinates for each along with a mass variable for each. The other three are pretty self explanatory
So I know Force = -stiff * distance(p1,p2) - damping * v
I have a bunch of questions about that. Is Force a vector? if so does that mean I wouldn't use the distance formula to find the distance? instead just subtract the x's and y's and put that in a vector? Also I'm confused as to what v is... I read its "v is the relative velocity between the two points connected by the spring" which I don't quite understand.
So bottom line is I want to take 2 points connected with a spring, each with potentially a different mass and with variables for restLength, damping, and stiffness and calculate the position of the spring for the next iteration.
If someone could walk me through this while breaking down the math to the basics (preferably without the mention of a vector) I'd be very thankful. I can understand the basic concept of what is happening I just can't understand the formulas that well. I've searched every site I can find but I can't really get off the ground. Please help. Thanks in advance.