I don't think you're calculating the length correctly. Additionally you might be interested in these functions:

http://www.conitec.net/beta/avec_lenght.htm

http://www.conitec.net/beta/avec_dist.htm


Always learn from history, to be sure you make the same mistakes again...