LoginSignup
0
1

More than 1 year has passed since last update.

三角関数を使って円を描く

Last updated at Posted at 2022-01-08

やったこと

学習用のプログラミングの問題をやっていて、三角関数がわからなくてプログラムが設計できなかったのが悔しかったので、数学を学びなおしています。

基本的な内容かもしれませんが、sinとcosを使えばx座標とy座標がわかるらしいので、円を描画するコードを作成しました。

# coding: utf-8
import matplotlib.pyplot as plt
import numpy as np

angle = np.arange(0,360) #0~360の角度のリストを作成
x = np.cos(np.radians(angle)) #x座標のリスト
y = np.sin(np.radians(angle)) #y座標のリスト

plt.plot(x,y)
plt.axis('equal') #x軸とy軸のスケールを揃える
plt.show()

出力結果

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