0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vbsの作法 その17

Last updated at Posted at 2018-11-21

概要

vbsの作法調べてみた。
2点間の距離と方位角やってみた。

参考にしたページ

サンプルコード

Dim pi
PI = 4 * Atn(1)
msgbox PI

Function Atan2(y, x)
	If x = 0 Then
		If y > 0 Then
			Atan2 = PI / 2
		Else
			Atan2 = -PI / 2
		End if
	Else
		Atan2 = Atn(y / x)
		If x < 0 Then
			If y >= 0 Then
				Atan2 = Atan2 + PI
			Else
				Atan2 = Atan2 - PI
			End if
		End if
	End If
	If Atan2 < 0 Then Atan2 = Atan2 + 2 * PI
End Function

Function Dist(i0, k0, i1, k1)
	Rx = 6378137
	E2 = 6.69437999019758E-03
	di = i1 - i0
	dk = k1 - k0
	i = (i0 + i1) / 2
	W = Sqr(1 - E2 * Sin(i * Pi / 180) ^ 2)
	M = Rx * (1 - E2) / W ^ 3
	N = Rx / W
	Dist = Sqr((di * PI / 180 * M) ^ 2 + (dk * PI / 180 * N * Cos(i * PI / 180)) ^ 2)
End Function

Function Dir(i0, k0, i1, k1)
	Rx = 6378137
	E2 = 6.69437999019758E-03
	di = i1 - i0
	dk = k1 - k0
	i = (i0 + i1) / 2
	W = Sqr(1 - E2 * Sin(i * PI / 180) ^ 2)
	M = Rx * (1 - E2) / W ^ 3
	N = Rx / W
	ddi = di * PI / 180 * M
	ddk = dk * PI / 180 * N * Cos(i * PI / 180)
	a = Atan2(ddi, ddk) * 180 / PI + 360
	If (a >= 360) Then a = a - 360
	Dir = a
End Function

msgbox Dist(35.0, 140.0, 36.0, 140.0)
msgbox Dir(35.0, 140.0, 36.0, 140.0)


方位角がおかしい。

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?