2D 座標架
Author: 藍邦偉  老師

$ O $

$B(x_2,y_2)$

$A(x_1,y_1)$

$\Delta OAB中，\;由餘弦定理知：$
$ \overline{AB}^2＝\overline{OA}^2+\overline{OB}^2-2\; \overline{OA}\;\overline{OB}cosθ$

$Step=%v$

$⇒ (x_2-x_1)^2+(y_2-y_1)^2 $
$=(x_1^2+y_1^2)+(x_2^2+y_2^2)-2\;\vec{a}\cdot \vec{b} $

$ ⇒-2x_1x_2-2y_1y_2=-2\vec{a}\cdot\vec{b} $

$⇒ \vec{a}\cdot\vec{b}=x_1x_2+y_1y_2 $

$A$

$B$

$ 向量內積的座標表示法 $

O = (0, 0)
Q_2: 0.65 * Corner[1] + 0.35 * Corner[2]
Q_3: (x(Q_2), y(Corner[4]))
poly1, q_1, q_2, q_4, q_3 = Polygon(Corner[1], Q_2, Q_3, Corner[4])
B_0 = (1.6175187595090263, 3.078354158136021)
B = DynamicCoordinates(B_0, floor(x(B_0)), floor(y(B_0)))
A_0 = (4.463135015769226, 1.5696049244031969)
A = DynamicCoordinates(A_0, floor(x(A_0)), floor(y(A_0)))
u = Vector(O, A)
v = Vector(O, B)
a = Segment(B, A)
a1: x(A)
a2: y(A)
b1: x(B)
b2: y(B)
s = 0 (slider from 0 to 7, step 1)
C: A
D: B
tA: "$ A" + (LaTeX[A]) + " $"
tB: "$ B" + (LaTeX[B]) + " $"
text5: "$ ⇒\vec{a}\cdot\vec{b}=" + (LaTeX[a1]) + "\times" + (LaTeX[If[b1 < 0, "(", ""]]) + "" + (LaTeX[b1]) + "" + (LaTeX[If[b1 < 0, ")", ""]]) + "+" + (LaTeX[If[a2 < 0, "(", ""]]) + "" + (LaTeX[a2]) + "" + (LaTeX[If[a2 < 0, ")", ""]]) + "\times " + (LaTeX[If[b2 < 0, "(", ""]]) + "" + (LaTeX[b2]) + "" + (LaTeX[If[b2 < 0, ")", ""]]) + "$"
text6: "$ =" + (LaTeX[a1 * b1]) + " +" + (LaTeX[If[a2 * b2 < 0, "(-", ""]]) + "" + (LaTeX[abs(a2 * b2)]) + "" + (LaTeX[If[a2 * b2 < 0, ")", ""]]) + "$"
text7: "$ =" + (LaTeX[a1 * b1 + a2 * b2]) + " $"