![見出し画像](https://assets.st-note.com/production/uploads/images/75587282/rectangle_large_type_2_c9d51df03c00dd4badcea098659b85c6.jpeg?width=1200)
恋する小惑星(アステロイド)のアステロイドを描いてみた
恋する小惑星(アステロイド)というアニメがありますが、アステロイドとは何でしょう。
アステロイドの語源はギリシャ語でaster(星の)+ -oid(ようなもの)という謂があり、数学では媒介変数で描画できる曲線で有名な形の一つです。
このアステロイドをpythonで描いてみようと思います。
式
アステロイドは以下の式になります。
解くのは面倒ですが、プログラムでアステロイドを描くのは簡単です。
{\displaystyle x=a\cos ^{3}\theta ,\quad y=a\sin ^{3}\theta }
コード
import math
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def astroid(a,t):
x = a*np.cos(t)**3
y = a*np.sin(t)**3
return x,y
def plot_func(x,y):
plt.gca().set_aspect('equal', adjustable='box')
plt.grid(which='major', color='gray',linestyle='--')
plt.grid(which='minor',color='gray',linestyle='--')
plt.plot(x,y)
plt.show()
if __name__ == "__main__":
PI = np.pi
t = np.linspace(0, 2*PI, 1000000)
x,y = astroid(1,t)
plot_func(x,y)
描画結果
アステロイドは下図のようになります。
aの値が半径になります。
![](https://assets.st-note.com/img/1648897473901-85uzwEpe2m.png)
アニメ・漫画情報
恋するアステロイドはamazon prime videoで見ることができます。
アニメに関する内容ここだけかいw
いいなと思ったら応援しよう!
![エタ](https://assets.st-note.com/production/uploads/images/21777937/profile_e15fdb91830ef936270ee3968362107e.jpg?width=600&crop=1:1,smart)