Calculate lengths to do more smooth interpolation