- UID
- 11325
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-10-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
**************************************************************
'**************** 作者:Leon Zhang ***************
'**************** Email:z_2_z@sina.com ***************
'**************************************************************
Function SPS(DKi As Double, CS As Integer, DKa As Double, DKb As Double, Xa As Double, Ya As Double, Ca As Double, Ra As Double, Rb As Double)
'DKi 计算点桩号, CS 参数, DKa 起点桩号, DKb 终点桩号, Xa 起点X坐标, Ya 起点Y坐标, Ca 起点方位角(弧度), Ra 起点半径, Rb 终点半径
Dim X As Double, Y As Double, J As Double '坐标、方位角
Dim N As Integer, k As Integer '精度参数、计算参数
Dim Pa As Double, Pb As Double 'A点曲率、B点曲率
Dim Pi As Double, H As Double '计算点曲率、积分步长
Dim W As Double, Z As Double, V As Double, U As Double '中间变量
Dim DK As Double, P As Double, C As Double '中间曲率、方位角变量
N = 120 '控制计算精度,根据精度和速度均衡考虑。
If Ra = 0 And Rb <> 0 Then
Pa = 0: Pb = 1 / Rb
ElseIf Rb = 0 And Ra <> 0 Then
Pb = 0: Pa = 1 / Ra
ElseIf Ra = 0 And Rb = 0 Then
Pa = 0: Pb = 0
Else
Pa = 1 / Ra: Pb = 1 / Rb
End If '将半径换算成曲率
Pi = Pa + (Pb - Pa) * Abs(DKi - DKa) / Abs(DKb - DKa) '计算点曲率
J = Ca + 0.5 * (Pa + Pi) * Abs(DKi - DKa) '计算点方位角
H = Abs(DKi - DKa) / N '积分步长
W = 0: Z = 0: U = 0: V = 0
For k = 1 To 2 * N - 1
DK = DKa + k * H / 2 '桩号
P = Pa + (Pb - Pa) * Abs(DK - DKa) / Abs(DKb - DKa) '曲率
C = Ca + 0.5 * (Pa + P) * Abs(DK - DKa) '方位角
If k Mod 2 = 0 Then 'k为双数时
W = W + Cos(C): Z = Z + Sin(C)
ElseIf k Mod 2 = 1 Then 'k为单数时
U = U + Cos(C): V = V + Sin(C)
End If
Next k
X = Xa + H / 6 * (Cos(Ca) + 4 * U + 2 * W + Cos(J)) '计算X坐标
Y = Ya + H / 6 * (Sin(Ca) + 4 * V + 2 * Z + Sin(J)) '计算Y坐标
If CS = 1 Then '输出X坐标
SPS = X
ElseIf CS = 2 Then '输出Y坐标
SPS = Y
ElseIf CS = 3 Then '输出方位角
SPS = J
ElseIf CS = 4 Then
SPS = Format(X, "0.000") & "," & Format(Y, "0.000") '输出X,Y
Else
MsgBox "输出参数只能是1,2,3,4!1代表X坐标,2是Y坐标,3是方位角,4是X.Y坐标。"
End If
End Function |
|