tpr3-common.rb: Fix a bug in tpr3 distance calculation