開発環境
- macOS Sierra - Apple (OS)
- Emacs (Text Editor)
- Python 3.6 (プログラミング言語)
行列プログラマー(Philip N. Klein (著)、 松田 晃一 (翻訳)、 弓林 司 (翻訳)、 脇本 佑紀 (翻訳)、 中田 洋 (翻訳)、 齋藤 大吾 (翻訳)、オライリージャパン)の1章(体)、1.4(C(複素数)と遊ぼう)、1.4.10(τ ラジアンの回転)の課題1.4.18、1.4.19を取り組んでみる。
課題 1.4.18
コード(Emacs)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
from plotting import plot
s = {2+2j, 3+2j, 1.75+1j, 2+1j, 2.25+1j, 2.5+1j, 2.75+1j, 3+1j, 3.25+1j}
plot({ z * math.e ** (math.pi / 4 * 1j) for z in s})
input()
入出力結果(Terminal, IPython)
$ ./sample4_18.py q $
課題 1.4.19
コード(Emacs)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
from plotting import plot
import image
filename = 'img01.png'
data = image.file2image(filename)
height = len(data)
width = len(data[0])
pts = [ (x + (height - y) * 1j) * math.e ** (math.pi / 4 * 1j)
for y, l in enumerate(data)
for x, (pt, _, _) in enumerate(l)
if pt < 120]
plot({pt for pt in pts}, max(width, height))
input()
入出力結果(Terminal, IPython)
$ ./sample4_19.py q $
0 コメント:
コメントを投稿