Math Adventures with Python
An Illustrated Guide to Exploring Math with Code
楽天ブックス(Kobo)
紀伊国屋書店(Kinoppy)
開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Python 3.7 (プログラミング言語)
- Processing 3 (プログラミング言語、統合開発環境、グラフィック機能)
Math Adventures with Python: An Illustrated Guide to Exploring Math with Code (Peter Farrell(著)、No Starch Press)のPART 2(RIDING INTO MATH TERRITORY)、5(TRANSFORMING SHAPES WITH GEOMETRY)、EXERCISE 5-1(SPIN CYCLE)の解答を求めてみる。
コード
Python 3
def setup():
size(600, 600)
rectMode(CENTER)
t = 0.0
def draw():
global t
background(255)
translate(width/2, height/2)
rotate(radians(t))
for _ in range(90):
tri(100)
rotate(radians(360 / 90))
t += 1
def tri(length):
triangle(0, -length,
-length*sqrt(3) / 2, length / 2,
length*sqrt(3) / 2, length / 2)
0 コメント:
コメントを投稿