|
因为有三角函数计算的原因,无法精确反算,不要求足够精度只是四舍五入百分比的话,用插值法可以算一个高度出来
- Sub Main()
- Const p As Double = 3.14159265358979
- Const n As Integer = 1000
- Const r As Integer = 10
-
- Dim ar, s#, s1#, s2#
- Dim i%, j%, k%
- Dim L#, h#, t#
- Dim A, B
-
- s = p * r ^ 2
- ReDim ar(0 To n, 0 To 11)
- t = 2 * p / n
- For i = 0 To n
- A = i * t
- B = A / (p * 2)
- s1 = B * s
-
- L = r * VBA.Sin(A / 2)
- h = VBA.Abs(r * VBA.Cos(A / 2))
- s2 = L * h
-
- ar(i, 0) = i
- ar(i, 1) = B * 100
- ar(i, 2) = A
- ar(i, 3) = B * 360
- ar(i, 4) = s1
- ar(i, 5) = s2
- ar(i, 6) = L * 2
-
- If A > p Then
- ar(i, 7) = r + h
- ar(i, 9) = s1 + s2
- Else
- ar(i, 7) = r - h
- ar(i, 9) = s1 - s2
- End If
- ar(i, 8) = ar(i, 7) / (r * 2)
- ar(i, 10) = ar(i, 9) / s
- If i Then ar(i, 11) = ar(i, 10) / ar(i, 8) Else ar(i, 11) = 0
- Next
- Sheet2.Range("b1:l1").Value = Array("序号", "角度百分比", "弧度", "角度", "扇形面积", "三角形面积", "弦长", "高度", "高度百分比", "面积", "面积百分比")
- Sheet2.Range("b2").Resize(n + 1, 12).Value = ar
- End Sub
复制代码
|
|