# Spring Compression from Rest Lenght and Real Length

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

## 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 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.

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 on other sites

I more like meant - is it correct to use simple subtraction in this case?

##### 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.

OK! Thanks!:)

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633728
• Total Posts
3013577
×