Function distanceToPoint