|
疑似楕円(Y^2)^0.5=((R^2)-(X^2))^0.5+Y*n で間に合わせました
ありがとうございました
Sub daen(a, b, kaisix, kaisiy, han, x, y, katamuki, Optional owarix = 0)
'ab中心 kaisix開始X座標(1か-1のみ)kaisiy開始Y座標 han半径
'x終了X座標(1か-1のみ)y終了Y座標 katamukiてっぺんがどれだけずれてるか
Dim c, d, e, f, g, h, i, j, k, maxkata, isbyouga As Boolean, l, m
i = han ^ 2
e = kaisiy - b
d = ((i - (kaisiy - b) ^ 2) ^ 0.5) * kaisix - _
katamuki * (b - kaisiy) / han
f = ((i - (kaisiy - b - kaisix) ^ 2) ^ 0.5) * kaisix - _
katamuki * (b - kaisiy - kaisix) / han
k = -1
If f > d Then k = 1
Cells(b + e, Int(a + d)).Interior.Color = 0
For h = 0 To 2000
If k = -1 Then
If d > -katamuki Then
j = -1
Else
j = 1
End If
Else
If d < katamuki Then
j = 1
Else
j = -1
End If
End If
c = katamuki * (e + j) / han
If Abs(e) <> han Then
f = Abs(((d - c + 1) ^ 2) + ((e + j) ^ 2) - i)
g = Abs(((d - c - 1) ^ 2) + ((e + j) ^ 2) - i)
If f < g Then
k = 1
Else
k = -1
End If
End If
f = Abs(((d - c) ^ 2) + ((e + j) ^ 2) - i)
g = Abs(((d + k - katamuki * e / han) ^ 2) + (e ^ 2) - i)
If f > g And m <> -k Then
d = d + k
m = k
Else
e = e + j
m = 0
End If
Cells(b + e, Int(a + d)).Interior.Color = 0
If b + e = y Then
If x = k Then Exit For
End If
Next
owarix = a + d
End Sub
Sub test()
Cells.Clear
daen 100, 100, 1, 120, 70, 1, 150, 24
End Sub
|
|