## 2018年1月16日火曜日

### 数学 - Python - 図形の変換の方法 - 線形写像・1次変換 – 平面の1次変換 - 原点のまわりの回転(角θの回転の逆変換、逆行列、検証)

1. $\begin{array}{}\left(\begin{array}{cc}\mathrm{cos}\theta & -\mathrm{sin}\theta \\ \mathrm{sin}\theta & \mathrm{cos}\theta \end{array}\right)\end{array}\left(\begin{array}{cc}\mathrm{cos}\theta & \mathrm{sin}\theta \\ -\mathrm{sin}\theta & \mathrm{cos}\theta \end{array}\right)=\left(\begin{array}{cc}{\mathrm{cos}}^{2}\theta +{\mathrm{sin}}^{2}\theta & \mathrm{sin}\theta \mathrm{cos}\theta -\mathrm{sin}\theta \mathrm{cos}\theta \\ \mathrm{sin}\theta \mathrm{cos}\theta -\mathrm{sin}\theta \mathrm{cos}\theta & {\mathrm{sin}}^{2}\theta +{\mathrm{cos}}^{2}\theta \end{array}\right)\\ =\left(\begin{array}{cc}1& 0\\ 0& 1\end{array}\right)$

コード(Emacs)

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, sin, cos, Matrix

θ = symbols('θ')
A = Matrix([[cos(θ), -sin(θ)],
[sin(θ), cos(θ)]])
B = Matrix([[cos(-θ), -sin(-θ)],
[sin(-θ), cos(-θ)]])

for X in [A, B, A * B, B * A]:
pprint(X)
print()


$./sample0.py ⎡cos(θ) -sin(θ)⎤ ⎢ ⎥ ⎣sin(θ) cos(θ) ⎦ ⎡cos(θ) sin(θ)⎤ ⎢ ⎥ ⎣-sin(θ) cos(θ)⎦ ⎡ 2 2 ⎤ ⎢sin (θ) + cos (θ) 0 ⎥ ⎢ ⎥ ⎢ 2 2 ⎥ ⎣ 0 sin (θ) + cos (θ)⎦ ⎡ 2 2 ⎤ ⎢sin (θ) + cos (θ) 0 ⎥ ⎢ ⎥ ⎢ 2 2 ⎥ ⎣ 0 sin (θ) + cos (θ)⎦$