1
0

ポテトチップスの方程式

Last updated at Posted at 2024-08-11

はじめに

ポテトチップス(以下ポテチ)は、面白い形をしている。それは、上から見ると楕円形であり、横からだと双曲線に見える。そこで、今回はそのような摩訶不思議な形をしているポテチを3次元的にモデル化して以下のようなグラフにしてみることを目的とする。
potechi_wire.png

ポテチの方程式

早速だが、上記のようなポテチを描くための方程式は以下のように表すことができる。

\begin{equation}
\left\{ \,
    \begin{aligned}
    & \frac{x^2}{a^2}+\frac{y^2}{b^2}<1 \\
    & z = \frac{x^2}{a^2}-\frac{y^2}{b^2} \\
    \end{aligned}
\right.
\end{equation}

ただし、$a>0,b>0$とする。

第一式はご存知の通り楕円の方程式であり、第二式は双曲線の方程式である。

プログラム

以下のようなプログラムを描いた。これは、ポテチの領域を黄色でワイヤーフレームを用いて描写するものである。

python potechi_wire.py
import numpy as np
import matplotlib.pyplot as plt
import math
from matplotlib.colors import ListedColormap
import japanize_matplotlib
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

a=1
b=2

n=100

x=np.linspace(-2,2,n)
y=np.linspace(-2,2,n)

X,Y=np.meshgrid(x,y)

Z=np.zeros((n,n))

for i in range(n):
    for k in range(n):
        # 楕円の方程式(領域外は空にする)
        if X[i][k]**2/a**2+Y[i][k]**2/b**2>1:
          Z[i][k] = np.nan
        else:
          # 双曲線の方程式
          Z[i][k]=((X[i][k])**2)/a**2-(Y[i][k]**2)/b**2
        
ax.set_title("ポテトチップス", fontsize=25)
ax.set_xlabel("X", fontsize=20)
ax.set_ylabel("Y", fontsize=20)
ax.set_zlabel("Z", fontsize=20)
# ワイヤフレームを用いてプロットした点をつなぐ
ax.plot_wireframe(X,Y,Z,color="yellow")
plt.savefig("potechi_wire.png")
plt.show()

さて、これを実行すると以下のようになる。

potechi_wire.png

まとめ

今回は、ポテトチップスの概形を描くためのプログラムを作成した。そのためには、楕円と双曲線の方程式を用いる必要性があった。このように、数学は見えないところで世界に影響を与えているということを我々は再認識する必要性があると思われる。

1
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
1
0