Use d=∣ax1+by1+c∣a2+b2d = \frac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}}d=a2+b2∣ax1+by1+c∣ for line ax+by+c=0ax+by+c=0ax+by+c=0.