- 积分
- 2108
- 明经币
- 个
- 注册时间
- 2002-9-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-10-26 08:58:00
|
显示全部楼层
‘请参考我做的五个子程序
Public Function 三点垂足(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, X3 As Double, Y3 As Double) As Variant() '直线的两端点坐标X1,Y1)-(X2,Y2),已知点X3,Y3) fw1 = 方位(X1, Y1, X2, Y2) fw2 = 方位(X1, Y1, X3, Y3) fw1 = DMS(DEG(fw2) - DEG(fw1)) pj0 = 平距(X1, Y1, X2, Y2) If pj0 = 0 Then pj0 = 1E-20 Pj1 = 平距(X1, Y1, X3, Y3) * Cos(RAD(fw1)) Var(0) = X1 + (X2 - X1) * Pj1 / pj0 Var(1) = Y1 + (Y2 - Y1) * Pj1 / pj0 三点垂足 = Var End Function ’求方位角
Function 方位(ddd As Double, ddd0 As Double, ddd1 As Double, ddd2 As Double) dd = ddd1 - ddd dd0 = ddd2 - ddd0 If dd0 <> 0 Then 方位 = DMS(180 - 90 * Sgn(dd0) - Atn(dd / dd0) * 180 / Pi) Else 方位 = 0 End If 方位 = 方位 + 360 方位 = 方位 - Int(方位 / 360) * 360 End Function ‘求两点平距
Function 平距(ddd As Double, ddd0 As Double, ddd1 As Double, ddd2 As Double) 平距 = Sqr((ddd - ddd1) ^ 2 + (ddd0 - ddd2) ^ 2) End Function
Function DEG(dfmm)
dfm = dfmm If dfm = 0 Then DEG = 0 Else ddd0 = dfm dfm = Abs(dfm) + 0.000001 'If Int(dfmm * 100) = 13253 Then MsgBox Int(dfm * 10000) ddd1 = Int(dfm * 100) - Int(dfm) * 100 ddd2 = Int(dfm * 10000) - Int(dfm * 100) * 100 ddd = (Int(dfm) + ddd1 / 60 + ddd2 / 3600) * Abs(ddd0) / ddd0 DEG = ddd End If End Function
Function DMS(dddd) ddd = dddd If ddd = 0 Then DMS = 0 Else ddd0 = ddd ddd = Abs(ddd) + 0.000001 ddd1 = Int(ddd * 100) - Int(ddd) * 100 ddd2 = (ddd * 10000) - Int(ddd) * 10000 - Int(ddd1) * 100 + (ddd1 * 0.6 - Int(ddd1 * 0.6)) * 100 / 0.6 ddd = Int(ddd) ddd1 = Int(ddd1 * 0.6) / 100 ddd2 = ddd2 * 0.000036 If ddd2 >= 0.006 Then ddd1 = ddd1 + 0.01 ddd2 = ddd2 - 0.006 End If If ddd1 >= 0.6 Then ddd = ddd + 1 ddd1 = ddd1 - 0.6 End If dfm = (ddd + ddd1 + ddd2) * ddd0 / Abs(ddd0) DMS = dfm End If End Function
|
|