3. 円の場合
circ.lua
x = sin θ for t = 0, 59, 1 do
th = math.pi / 2 * t / 59
y = cos θ x, y = math.sin(th), math.cos(th)
π t
θ = (0 ≤ t < 60) print(x, y)
end
2 59
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
図 1: 円
3 / 20
4. 円錐曲線の極座標一般系
x = r sin θ
y = r cos θ + e
1 − e2
r =
1 + e cos θ
e = 0 の場合、円
0 < e < 1 の場合、楕円
e = 1 の場合、放物線(r の分子は定数とする)
1 < e の場合、双曲線
4 / 20
5. 双曲線の曲座標表示
bola.lua
e, div = 2, 240
x = r sin θ for t = 0, div, 1 do
y = r cos θ + e th = 2 * math.pi * t / div
r = (1-e*e)/(1+e*math.cos(th))
1 − e2 x, y = r*math.sin(th), r*math.cos(th)+e
r = print(x, y)
1 + e cos θ end
10
8
6
4
2
0
-2
-4
-6
-8
-10
-10 -8 -6 -4 -2 0 2 4 6 8 10
図 2: 双曲線(全体)
5 / 20
6. 右肩下がりの双曲線
円の場合と同じように、(0,1) から出発して右肩下がりに
図 2 の右下の部分のみを使いたい
下の双曲線の頂点を (0,1) に移動する
y に 2 を足す
t = 0 の時に θ = π となるように
t が増えるに従い、θ は減らす
この時に、x 切片(y = 0)の時の θ を求める
1 − e2
cos θ + e + 2 = 0
1 + e cos θ
(1 − e 2 ) cos θ = −(e + 2)(1 + e cos θ)
e +2
cos θ = −
2e + 1
e +2
θ = arccos (− )
2e + 1
6 / 20
7. 右肩下がりの双曲線
bola.lua
e, div = 2, 59
d = math.pi - math.acos(-(e+2)/((2*e)+1))
for t = 0, div, 1 do
th = math.pi-(d*t/div)
r = (1-e*e)/(1+e*math.cos(th))
x, y = r*math.sin(th), r*math.cos(th)+e+2
print(x, y)
end
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.5 1 1.5 2 2.5 3
図 3: 双曲線(右肩下がり)
7 / 20
8. 切片を調節した双曲線
切片の x 座標を a にしたい
e+2
切片なので、この時の θ は arccos (− 2e+1 )
1 − e2
sin θ = a
1 + e cos θ
√ ( )
1 − e2 e +2 2
1− = a
1 − e 2e+1
e+2 2e + 1
√
3(e 2 − 1)
(2e + 1) = a
2e + 1
√
a2
e = +1
3
8 / 20
9. 切片を調節した双曲線
bola.lua
a, div = 0.8, 59
e = math.sqrt((a*a/3)+1)
d = math.pi - math.acos(-(e+2)/((2*e)+1))
for t = 0, div, 1 do
th = math.pi-(d*t/div)
r = (1-e*e)/(1+e*math.cos(th))
x, y = r*math.sin(th), r*math.cos(th)+e+2
print(x, y)
end
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
図 4: 双曲線 9 / 20
10. 放物線の曲座標表示
para.lua
c, div = 1, 240
x = r sin θ for t = 0, div, 1 do
th = 2 * math.pi * t / div
y = r cos θ + 1 r = c/(1+math.cos(th))
c x, y = r*math.sin(th), r*math.cos(th)+1
r =
1 + cos θ print(x, y)
end
2
1
0
-1
-2
-3
-4
-5
-6
-7
-8
-5 -4 -3 -2 -1 0 1 2 3 4 5
図 5: 放物線(全体)
10 / 20
11. 右肩下がりの放物線
円の場合と同じように、(0,1) から出発して右肩下がりに
図 5 の右の部分のみを使いたい
放物線の頂点を (0,1) に移動する
y から c を引く
2
t = 0 の時に θ = 0
t が増えるに従い、θ は増やす
この時に、x 切片(y = 0)の時の θ を求める
c c
cos θ + 1 − = 0
1 + cos θ 2
2−c
c cos θ = − (1 + cos θ)
2
(c + 2) cos θ = −(2 − c)
c −2
θ = arccos ( )
c +2
11 / 20
12. 右肩下がりの放物線
para.lua
c, div = 1, 59
b = math.acos((c-2)/(c+2))
for t = 0, div, 1 do
th = b*t/div
r = c/(1+math.cos(th))
x, y = r*math.sin(th), r*math.cos(th)+1-(c/2)
print(x, y)
end
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
図 6: 放物線(右肩下がり)
12 / 20
13. 切片を調節した放物線
切片の x 座標を a にしたい
切片なので、この時の θ は arccos ( c−2 )
c+2
c
sin θ = a
1 + cos θ
√ ( )
c c −2 2
1− = a
1 + c−2
c+2
c +2
√
c + 2 8c
= a
2 c +2
a2
c =
2
13 / 20
14. 切片を調整した放物線
para.lua
a, div = 0.8, 59
c = a*a/2
b = math.acos((c-2)/(c+2)) for t = 0, div, 1 do
th = b*t/div
r = c/(1+math.cos(th))
x, y = r*math.sin(th), r*math.cos(th)+1-(c/2)
print(x, y)
end
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
図 7: 放物線
14 / 20
15. 楕円の曲座標表示
elli.lua
e, div = 0.5, 240
x = r sin θ for t = 0, div, 1 do
y = r cos θ + e th = 2 * math.pi * t / div
r = (1-(e*e))/(1+(e*math.cos(th)))
1 − e2 x, y = r*math.sin(th), r*math.cos(th)+e
r = print(x, y)
1 + e cos θ end
1
0.8
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
図 8: 楕円(全体)
15 / 20
16. 右肩下がりの楕円
円の場合と同じように、(0,1) から出発して右肩下がりに
図 8 の右上の部分のみを使いたい
x 切片(y = 0)の時の θ を求める
1 − e2
cos θ + e = 0
1 + e cos θ
(1 − e 2 ) cos θ = −e(1 + e cos θ)
cosθ = −e
θ = arccos (−e)
16 / 20
17. 右肩下がりの楕円
elli.lua
e, div = 0.5, 59
b = math.acos(-e)
for t = 0, div, 1 do
th = b*t/div
r = (1-(e*e))/(1+(e*math.cos(th)))
x, y = r*math.sin(th), r*math.cos(th)+e
print(x, y)
end
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
図 9: 楕円(右肩下がり)
17 / 20
18. 切片を調節した楕円
切片の x 座標を a にしたい
切片なので、この時の θ は arccos (−e)
1 − e2
sin θ = a
1 + e cos θ
1 − e2 √
1 − e2 = a
1 − e2
√
1 − e2 = a
√
e = 1 − a2
18 / 20
19. 切片を調整した楕円
elli.lua
a, div = 0.8, 59
c = math.sqrt(1-(a*a))
b = math.acos(-e)
for t = 0, div, 1 do
th = b*t/div
r = (1-(e*e))/(1+(e*math.cos(th)))
x, y = r*math.sin(th), r*math.cos(th)+e
print(x, y)
end
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
図 10: 楕円 19 / 20