added quad_distance functions
added quad distance computation