已知两点(一条直线),做直角三角形.
Sub ll()
Dim p0(2) As Double, p1(2) As Double, Pp(2) As Double
Dim R, rLen
p0(0) = -20
p0(1) = 50
p1(0) = 0
p1(1) = 0
R = 10
rLen = Sqr((p0(0) - p1(0)) ^ 2 + (p0(1) - p1(1)) ^ 2)
Dim objLine As AcadLine
Set objLine = ThisDrawing.ModelSpace.AddLine(p1, p0)
ThisDrawing.Regen acActiveViewport
Dim Alfa1, Alfa2
With objLine
Alfa1 = .Angle
Alfa2 = ACos(R / .Length)
Debug.Print Alfa1 * 180 / 3.1415926, Alfa2 * 180 / 3.1415926
Pp(0) = R * Cos(Alfa1 + Alfa2)
Pp(1) = R * Sin(Alfa1 + Alfa2)
End With
With ThisDrawing.ModelSpace
Set objLine = .AddLine(Pp, p0)
objLine.color = acGreen
Set objLine = .AddLine(Pp, p1)
objLine.color = acRed
End With
End Sub
Function ACos(x) As Double
ACos = Atn(Sqr(1 - x * x) / x) '+ 4 * Atn(1)
End Function
页:
[1]