点到直线的距离

点到直线的距离

org.locationtech.jts.algorithm.distance

对于点到直线的距离,有以下几种情况

对于线段AB,线段外一点P到线段的最短距离距离d

PAB=θ\angle PAB=\theta

设定标志有AP在AB上的投影与AB的长度之比为

r=APcosθAB=APABAPABAPAB=APABAB2r=\frac{|AP|\cos \theta}{|AB|}=\frac{AP·AB}{|AP||AB|}·\frac{|AP|}{|AB|}=\frac{AP·AB}{|AB|^2}

有以下几种情况:

r0,d=PAr1,d=PB0<r<1,d=PL(PLAB)\begin{array}{c}r \leqslant 0, d=P A \\ r \geqslant 1, d=P B \\ 0<r<1, d=P L(P L \perp A B)\end{array}

对于第三种情形,有

PL=APsinθ=APAP×ABAPAB=AP×ABAB|PL|=|AP|·\sin \theta=|AP|·\frac {AP\times AB}{|AP||AB|}=\frac{AP\times AB}{|AB|}

Last updated

Was this helpful?