## 2020年5月8日金曜日

### 数学 - Python - 立体的な広がりの中の図形 - 空間図形 - 空間のベクトル - ベクトルの内積 - 基本ベクトル同士の内積

• $\begin{array}{l}{\stackrel{\to }{e}}_{1}·{\stackrel{\to }{e}}_{2}={\stackrel{\to }{e}}_{2}·{\stackrel{\to }{e}}_{1}\\ =\left(1,0,0\right)·\left(0,1,0\right)\\ =0\end{array}$

• $\begin{array}{l}{\stackrel{\to }{e}}_{2}·{\stackrel{\to }{e}}_{3}={\stackrel{\to }{e}}_{3}·{\stackrel{\to }{e}}_{2}\\ =\left(0,1,0\right)·\left(0,0,1\right)\\ =0\end{array}$

• $\begin{array}{l}{\stackrel{\to }{e}}_{3}·{\stackrel{\to }{e}}_{1}={\stackrel{\to }{e}}_{1}·{\stackrel{\to }{e}}_{3}\\ =\left(0,0,1\right)·\left(1,0,0\right)\\ =0\end{array}$

• $\begin{array}{l}{\stackrel{\to }{e}}_{1}·{\stackrel{\to }{e}}_{1}=1\\ \stackrel{\to }{{e}_{2}}·{\stackrel{\to }{e}}_{2}=1\\ {\stackrel{\to }{e}}_{3}·{\stackrel{\to }{e}}_{3}=1\end{array}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix, solve

print('11.')

class TestVector(TestCase):
def test(self):
e1 = Matrix([1, 0, 0])
e2 = Matrix([0, 1, 0])
e3 = Matrix([0, 0, 1])
es = [e1, e2, e3]
numss = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
for u, nums in zip(es, numss):
for v, num in zip(es, nums):
self.assertEqual(u.dot(v), num)

if __name__ == "__main__":
main()


% ./sample11.py -v
11.
test (__main__.TestVector) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
%