リサージュ図形のプロット 〜 『計算物理学入門』読み(その7)
以下の方程式で表される図形をプロットしてみる。
プログラムは以下の通り。
(use graph)
(use util.stream)
(use math.const)(graph-init 400 400 :title "Lissajous curve" :display 2 :x-min -2 :x-max 2 :y-min -2 :y-max 2)
(graph-grid 4 4 'gray)(define (lissajous A omega-x phi-x
B omega-y phi-y
t)
(cons (* A (sin (+ (* omega-x t) phi-x)))
(* B (sin (+ (* omega-y t) phi-y)))))(define (lissajous-curve t dt)
(stream-cons (lissajous 1 2 (/ pi 6)
1 3 (/ pi 4)
t)
(lissajous-curve (+ t dt))))(graph-plot-point-stream
(stream-take (lissajous-curve 0 0.01) 350)
'red)
プロットした結果は以下の通り。
綺麗だなあ。