Holograph1c Attract0r

日々の数学やプログラミングに関係する話。

座標平面上の三角形の面積公式

f:id:mikan_alpha:20190210160816p:plain

定理. 座標平面上の原O、2点A(x_1,y_1)B(x_2,y_2)が一直線上にないとき、この3点を頂点とする三角形の面積Sは以下の式で表される。

\begin{align}
S = \frac{1}{2} | x_1 y_2 - x_2 y_1 |
\end{align}

証明

\angle AOB\theta\overrightarrow{OA}\vec{a}\overrightarrow{OB}\vec{b}と置く。

\begin{align}
S &= \frac{1}{2} \| \vec{a} \| \| \vec{b} \| \sin \theta \\
&= \frac{1}{2} \| \vec{a} \| \| \vec{b} \| \sqrt{1 - \cos ^2 \theta} \\
&= \frac{1}{2} \sqrt{\| \vec{a} \| ^2 \| \vec{b} \| ^2 (1 - \cos ^2 \theta)} \\
&= \frac{1}{2} \sqrt{\| \vec{a} \| ^2 \| \vec{b} \| ^2 - \| \vec{a} \| ^2 \| \vec{b} \| ^2 \cos ^2 \theta} \\
&= \frac{1}{2} \sqrt{\| \vec{a} \| ^2 \| \vec{b} \| ^2 - (\vec{a} \cdot \vec{b}) ^2} \\
&= \frac{1}{2} \sqrt{(x_1^2 + y_1^2) (x_2^2 + y_2^2) - (x_1 x_2 + y_1 y_2) ^2} \\
&= \frac{1}{2} \sqrt{(x_1^2 + y_1^2) (x_2^2 + y_2^2) - (x_1^2 x_2^2 + y_1^2 y_2^2 + 2 x_1 x_2 y_1 y_2)} \\
&= \frac{1}{2} \sqrt{x_1^2 y_2^2 - 2 x_1 x_2 y_1 y_2 + x_2^2 y_1^2} \\
&= \frac{1}{2} \sqrt{(x_1 y_2 - x_2 y_1) ^2} \\
&= \frac{1}{2} | x_1 y_2 - x_2 y_1 |
\end{align}