Changed algorithm to use the primitive 'double' type.

This allows the use of non-integer units, such as coordinates, to be
used more easily.