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.