點到直線的距離
Author: 藍邦偉  老師

移動A,B兩點決定直線L:ax+by+c=0，計算點P(x_0,y_0)到直線L的距離

點到直線的距離

P(x_0,y_0)

θ

=\frac{|ax_0+by_0+c|}{\sqrt{a+b²}}

=\frac{|-c-ax_0-by_0|}{\sqrt{a²+b²}}

=\frac{|(ax+by)-ax_0-by_0|}{\sqrt{a²+b²}}

=\frac{|(x-x_0,y-y_0)·(a,b)|}{\sqrt{a²+b²}}

=\frac{|\overrightarrow{u}·\overrightarrow{n}|}{|\overrightarrow{n}|}

d(P,L)=\overline{PH}=|\overrightarrow{u}|·|cosθ|

Reset

Start

$ =\frac{|a(x-x_0)+b(y-y_0)|}{\sqrt{a²+b²}} $

P(x_0,y_0)

$ \overrightarrow{n} $

$ \left\vert\overrightarrow{u}  \right\vert  $

t = 0 (slider from 0 to 1, step 0.0050)
B = (5.954886153566595, -1.3182440328888019)
A = (13.251520755084842, -1.283498153833953)
a = Line(A, B)
D = Point(a)
C = Point(a)
K_1: (x(Corner[1]), 0)
K_2: (x(Corner[2]), 0)
P = (16.413395749076077, 4.658047164545188)
b = OrthogonalLine(P, a)
H = Intersect(a, b)
c = Segment(P, H)
Q: C + t * Vector[C, D]
u = Vector(P, Q)
n_1: 5 / c * Vector[P, H]
n = Translate(n_1, P)
β = Angle(H, P, Q)
L = Line(A, B)
d = 0 (slider from 0 to 7, step 1)
T_1 = Corner(1)
T_4 = Corner(4)
T_2: (6.9 * Corner[1] + 3.1 * Corner[2]) / 10
T_3: (6.9 * Corner[4] + 3.1 * Corner[3]) / 10
多邊形1, t_1, t_2, t_3, t_4 = Polygon(T_1, T_2, T_3, T_4)
E: C + t * Vector[C, D]
e = Segment(E, P)
f = Circle(H, 0.6)
F = Intersect(f, c)
G, I = Intersect(f, a)
J: F + I - H
g = Segment(J, I)
h = Segment(J, F)