Sub calc_rad(Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, rad)
'===============================
' 点A(x1,y1) B(x2,y2)を通る直線AB と
' 点C(x3,y3) D(x4,y4)を通る直線CD が成す角度
'===============================

Dim x1 As Single
Dim x2 As Single
Dim x3 As Single
Dim x4 As Single
Dim y1 As Single
Dim y2 As Single
Dim y3 As Single
Dim y4 As Single
Dim m1 As Single
Dim m2 As Single

Dim Angle As Single

x1 = Ax
y1 = Ay
x2 = Bx
y2 = By
x3 = Cx
y3 = Cy
x4 = Dx
y4 = Dy

m1 = (x2 - x1)
m2 = (x4 - x3)
m3 = (y2 - y1)
m4 = (y4 - y3)

Angle = Arccos(((m1 * m2) + (m3 * m4)) / (Sqr(m1 ^ 2 + m3 ^ 2) * Sqr((m2 ^ 2 + m4 ^ 2))))

deg = Angle / PI() * 180
rad = Angle

End Sub