0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ポケモン種族値で学ぶオイラーの公式とベクトル

Posted at

✅ ステップ 0:種族値の定義

ポケモン 攻撃(Attack) 素早さ(Speed)
ガブリアス 130 102
オノノクス 147 97

✅ ステップ 1:2次元ベクトル定義(攻撃, 素早さ)

$$
\vec{g} = \begin{bmatrix}130 \ 102\end{bmatrix}, \quad
\vec{o} = \begin{bmatrix}147 \ 97\end{bmatrix}
$$


✅ ステップ 2:オイラーの公式による複素数化

$$
z = x + iy = |z| e^{i\theta}
$$

◉ ガブリアス

$$
z_g = 130 + 102i = |z_g| e^{i\theta_g}
$$

  • 絶対値(ノルム):

$$
|z_g| = \sqrt{130^2 + 102^2} = \sqrt{26884} \approx 163.95
$$

  • 偏角:

$$
\theta_g = \tan^{-1}\left(\frac{102}{130}\right) \approx \tan^{-1}(0.7846) \approx 38.23^\circ
$$

  • オイラー形式:

$$
z_g = 163.95 \cdot e^{i \cdot 38.23^\circ}
$$


◉ オノノクス

$$
z_o = 147 + 97i = |z_o| e^{i\theta_o}
$$

  • 絶対値:

$$
|z_o| = \sqrt{147^2 + 97^2} = \sqrt{30898} \approx 175.74
$$

  • 偏角:

$$
\theta_o = \tan^{-1}\left(\frac{97}{147}\right) \approx \tan^{-1}(0.6599) \approx 33.44^\circ
$$

  • オイラー形式:

$$
z_o = 175.74 \cdot e^{i \cdot 33.44^\circ}
$$


✅ ステップ 3:正規化ベクトル(単位ベクトル)

$$
\hat{g} = \frac{1}{|z_g|}\begin{bmatrix}130 \ 102\end{bmatrix},\quad
\hat{o} = \frac{1}{|z_o|}\begin{bmatrix}147 \ 97\end{bmatrix}
$$



import numpy as np
import matplotlib.pyplot as plt

# ベクトル定義 / Define vectors
g_vec = np.array([130, 102])  # ガブリアス / Garchomp
o_vec = np.array([147, 97])   # オノノクス / Haxorus

# ノルム(長さ)/ Norm (magnitude)
g_norm = np.linalg.norm(g_vec)
o_norm = np.linalg.norm(o_vec)

# 正規化ベクトル / Normalize to unit vectors
g_unit = g_vec / g_norm
o_unit = o_vec / o_norm

# 偏角(ラジアン)/ Argument (angle in radians)
theta_g = np.arctan2(g_vec[1], g_vec[0])
theta_o = np.arctan2(o_vec[1], o_vec[0])

# オイラーの公式による極形式 / Euler's formula polar form
z_g = g_norm * np.exp(1j * theta_g)
z_o = o_norm * np.exp(1j * theta_o)

# なす角の計算 / Angle between two unit vectors
angle_diff = np.arccos(np.clip(np.dot(g_unit, o_unit), -1.0, 1.0))

# プリント出力 / Print results
print("=== Garchomp (ガブリアス) ===")
print(f"Vector: {g_vec}")
print(f"Norm: {g_norm:.2f}")
print(f"Theta (radian): {theta_g:.4f}, (degree): {np.degrees(theta_g):.2f}")
print(f"Euler form: {z_g:.2f} = {g_norm:.2f} * exp(i * {np.degrees(theta_g):.2f}°)")

print("\n=== Haxorus (オノノクス) ===")
print(f"Vector: {o_vec}")
print(f"Norm: {o_norm:.2f}")
print(f"Theta (radian): {theta_o:.4f}, (degree): {np.degrees(theta_o):.2f}")
print(f"Euler form: {z_o:.2f} = {o_norm:.2f} * exp(i * {np.degrees(theta_o):.2f}°)")

print("\n=== Cosine Similarity and Angle ===")
cos_sim = np.dot(g_unit, o_unit)
print(f"cos(θ) = {cos_sim:.4f}")
print(f"Angle between vectors (radian): {angle_diff:.4f}, (degree): {np.degrees(angle_diff):.4f}")

# 角度の範囲(プロット用)/ Angle range for plotting
theta = np.linspace(0, max(theta_g, theta_o), 300)
sin_theta = np.sin(theta)
cos_theta = np.cos(theta)

# プロット / Plotting
plt.figure(figsize=(10, 5))
plt.plot(theta * 180 / np.pi, cos_theta, label="cos(θ)")
plt.plot(theta * 180 / np.pi, sin_theta, label="sin(θ)")
plt.axvline(x=np.degrees(theta_g), color='red', linestyle='--', label="θ_g (Garchomp)")
plt.axvline(x=np.degrees(theta_o), color='green', linestyle='--', label="θ_o (Haxorus)")
plt.axvline(x=np.degrees(angle_diff), color='blue', linestyle='--', label="θ_diff (angle)")
plt.title("Trigonometric functions and vector angles")
plt.xlabel("Angle (degrees)")
plt.ylabel("Value")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()

# 極座標プロットの作成 / Create polar plot
plt.figure(figsize=(6, 6))
ax = plt.subplot(111, projection='polar')
ax.plot([0, theta_g], [0, g_norm], label="Garchomp", color='red', linewidth=2)
ax.annotate("Garchomp", xy=(theta_g, g_norm), xytext=(theta_g + 0.2, g_norm),
            arrowprops=dict(facecolor='red', arrowstyle='->'))
ax.plot([0, theta_o], [0, o_norm], label="Haxorus", color='green', linewidth=2)
ax.annotate("Haxorus", xy=(theta_o, o_norm), xytext=(theta_o + 0.2, o_norm),
            arrowprops=dict(facecolor='green', arrowstyle='->'))
ax.set_title("Polar Plot of Attack-Speed Vectors", va='bottom')
ax.set_rlabel_position(45)
ax.grid(True)
ax.legend(loc='upper right')
plt.show()

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?