Overridable distance function

Hello.
I separate the distance calculation to a function so that, the distance functionality is now overridable by OOP manner, and the whole code is more reusable.

Also, this is an example of overriding the distance function. https://gist.github.com/peecky/75840e6d82068b4d7327