

ハイポトコロイドと呼ばれる曲線です。
x=(a-b)*cos(th)+c*cos((a-b)*th/b)
y=(a-b)*sin(th)-c*sin((a-b)*th/b)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 240 240 %%Title:Hypotrochoid(ハイポトコロイド)を描く /a 100 def % 導円の半径 /b a 8 div def % 転円の半径 0 0 240 240 rectfill % 黒背景 120 120 translate % 座標の原点を中央に移動 newpath % パスの初期化 0 1 360 { % 0から始めて360まで1づつ増分し{ }内を繰り返す /th exch def % 制御変数をth(角度)に入れる % ハイポトコロイドの数式 /x a b sub th cos mul c a b sub th b div mul cos mul add def /y a b sub th sin mul c a b sub th b div mul sin mul sub def % thが0なら始点をさもなくば線を引く th 0 eq { x y moveto } { x y lineto } ifelse } for closepath % 線を繋ぐ 1 1 1 setrgbcolor % 白色 2 setlinewidth % 線幅2ポイント stroke % 線を描画 |

図形を2度12回、回転させていきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 240 240 %%Title:Hypotrochoid(ハイポトコロイド)を描く /a 60 def % 導円の半径 /b a 8 div def % 転円の半径 /c 60 def % パラメータ 0 0 240 240 rectfill % 黒背景 120 120 translate % 座標の原点を中央に移動 /rc 1 def % R色 /bc .7 def % B色 newpath % パスの初期化 12 { % 12回{ }内を繰り返す 0 1 360 { % 0から始めて360まで1づつ増分し{ }内を繰り返す /th exch def % 制御変数をth(角度)に入れる % ハイポトコロイドの数式 /x a b sub th cos mul c a b sub th b div mul cos mul add def /y a b sub th sin mul c a b sub th b div mul sin mul sub def % thが0なら始点をさもなくば線を引く th 0 eq { x y moveto } { x y lineto } ifelse } for rc 0 bc setrgbcolor % カラー設定 stroke % 線を描画 /rc rc .08 sub def % R色から0.08を引く /bc bc .04 add def % B色に0.04を足す 2 rotate % 2度座標を回転 } repeat |

コメント