我有一段代码需要4个点(构成2行),并确定它们之间的角度。如何以编程方式确定这是顺时针旋转还是逆时针旋转?
Private Function calculateAngleAlt(L1X1 As Double, L1Y1 As Double, L1X2 As Double, L1Y2 As Double, L2X1 As Double, L2Y1 As Double, L2X2 As Double, L2Y2 As Double) As Double
line1A = L1X2 - L1X1
line1B = L1Y2 - L1Y1
line2A = L2X2 - L2X1
line2B = L2Y2 - L2Y1
lineDot = (line1A * line2A) + (line1B * line2B)
distL1 = Abs(Sqr((line1A * line1A) + (line1B * line1B)))
distL2 = Abs(Sqr((line2A * line2A) + (line2B * line2B)))
calculateAngleAlt = ArcCos(lineDot /(distL1 * distL2))
End Function
谢谢!