エピサイクロイドと呼ばれる曲線です。
x=(a+b)*cos(th)-b*cos((a+b)*th/b)
y=(a+b)*sin(th)-b*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
21
22 %!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 240 240
%%Title:Epicycroid(エピサイクロイド)を描く
/a 60 def % 定円の半径
/b 20 def % 転円の半径
/c 1 def % パラメータ
0 0 240 240 rectfill % 黒背景
120 120 translate % 座標の原点を中央に移動
newpath % パスの初期化
0 1 360 { % 0から始めて360まで1づつ増分し{ }内を繰り返す
/th exch def % 制御変数をth(角度)に入れる
% エピサイクロイドの数式
/x a b add th cos mul c b mul a b add th b div mul cos mul sub def
/y a b add th sin mul c b mul a b add th b div mul sin mul sub def
% thが0なら始点を置き、さもなくば線を引く
th 0 eq { x y moveto } { x y lineto } ifelse
} for
2 setlinewidth % 線幅2ポイント
1 1 1 setrgbcolor % 白色
stroke % 線を描画
拡大させながら線幅を細くしていきます。
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
28
29
30
31
32
33
34
35 %!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 240 240
%%Title:Epicycroid(エピサイクロイド)を描く
/a 60 def % 定円の半径
/b 10 def % 転円の半径
/c 3 def % パラメータ
/sw 0 def % 始点を置くスイッチ
/rc 1 def % R色
/gc 0 def % G色
/bc .8 def % B色
/lw 3 def % 線幅
0 0 240 240 rectfill % 黒背景
120 120 translate % 座標の原点を中央に移動
newpath % パスの初期化
.8 .4 5 { % 0.8から5まで0.4づつ増分し{ }内を繰り返す
/c exch def % 制御変数をcに入れる
0 1 360 { % 0から360まで1づつ増分し{ }内を繰り返す
/th exch def % 制御変数をth(角度)に入れる
% エピサイクロイドの数式
/x a b add th cos mul c b mul a b add th b div mul cos mul sub def
/y a b add th sin mul c b mul a b add th b div mul sin mul sub def
% thが0なら始点を置き、さもなくば線を引く
th 0 eq { x y moveto } { x y lineto } ifelse
} for
closepath % 線を繋ぐ
/sw 0 def % 始点のリセット
rc gc bc setrgbcolor % カラー設定
lw setlinewidth % 線幅設定
stroke % 線を描画
/rc rc .08 sub def % R色から0.08を引く
/bc bc .09 add def % G色に0.09を足す
/gc gc .07 add def % B色に0.07を足す
/lw lw .2 sub def % 線幅から0.2を引く
} for
コメント