Jump to content
  • Advertisement
Sign in to follow this  
adriansnetlis

Spring Compression from Rest Lenght and Real Length

This topic is 736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hooke's law:
F = -kx

Where k is spring constant(stiffness) and x is compression rate. So if the spring is compressed, the force will push each ends of the spring away. If spring is stretched, than it will pull each of the ends together. That's kind of clear.

However, I need to get the compression somehow. I have the rest length(in m) and the current spring length(in m) and I need to get the compression distance(in m).

Currently I do:

compression = rest_length - spring_length

However, I'm not sure if this is correct.

Share this post


Link to post
Share on other sites
Advertisement

Hooke's law:
F = -kx

Where k is spring constant(stiffness) and x is compression rate. So if the spring is compressed, the force will push each ends of the spring away. If spring is stretched, than it will pull each of the ends together. That's kind of clear.

However, I need to get the compression somehow. I have the rest length(in m) and the current spring length(in m) and I need to get the compression distance(in m).

Currently I do:

compression = rest_length - spring_length

However, I'm not sure if this is correct.

 

Seems like you want :

.

compression = spring_length - rest_length

.

So the variable x ("compression" in your code) is positive when you stretch the spring, giving you a negative force F, and vise versa when you compress it.

Edited by 0r0d

Share this post


Link to post
Share on other sites

Hooke's law:
F = -kx

Where k is spring constant(stiffness) and x is compression rate. So if the spring is compressed, the force will push each ends of the spring away. If spring is stretched, than it will pull each of the ends together. That's kind of clear.

However, I need to get the compression somehow. I have the rest length(in m) and the current spring length(in m) and I need to get the compression distance(in m).

Currently I do:

compression = rest_length - spring_length

However, I'm not sure if this is correct.

 

It is correct. x is not the compression rate, it's the displacement of the spring.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!