请教个问题,已知一点和一圆,如何求该点到该圆的切线,并手动选择留哪一条。怎么做?我是求出切线长,画圆,两圆交两点,如何把两点分出来,选择其中一个初学vba 望指点
请教个问题,
已知一点和一圆,
如何求该点到该圆的切线,
并手动选择留哪一条。
怎么做?
我是求出切线长,画圆,两圆交两点,
如何把两点分出来,选择其中一个
初学vba 望指点
2楼
我也还不知道!真是愧为版主啊!
回复
3楼
Sub Test()
Dim Pnt As Variant
Dim CirCenter As Variant
Dim Radius1 As Double, Radius2 As Double
Dim Circle1 As AcadCircle, Circle2 As AcadCircle
Dim TempLine As AcadLine
Dim DistPtCen As Double
Dim PolylinePt As Variant
Dim Polyline As AcadPolyline
Dim Line1 As AcadLine, Line2 As AcadLine
’Enter the center and radius of the circle
CirCenter = ThisDrawing.Utility.GetPoint(, "圆心位置:")
Radius1 = ThisDrawing.Utility.GetDistance(CirCenter, "圆的半径:")
’Draw the circle
Set Circle1 = ThisDrawing.ModelSpace.AddCircle(CirCenter, Radius1)
’Specify the point from where the tangent line start
Pnt = ThisDrawing.Utility.GetPoint(, "切线起点:")
’Draw the point
ThisDrawing.ModelSpace.AddPoint (Pnt)
’Calculate the length of the tangent line
Set TempLine = ThisDrawing.ModelSpace.AddLine(CirCenter, Pnt)
DistPtCen = TempLine.Length
TempLine.Delete
Radius2 = Sqr(DistPtCen ^ 2 - Radius1 ^ 2)
’Draw a auxiliary circle with radius equals the length of tangent line
Set Circle2 = ThisDrawing.ModelSpace.AddCircle(Pnt, Radius2)
PolylinePt = Circle1.IntersectWith(Circle2, acExtendNone)
Set Polyline = ThisDrawing.ModelSpace.AddPolyline(PolylinePt)
’Add tangent lines
Set Line1 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(0))
Set Line2 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(1))
’Delete the auxiliary circle and polyline
Circle2.Delete
Polyline.Delete
End Sub
虽然写得不好,不过也可以做切线了,
才学vba不到一个月,还请大家指教。
回复
4楼
Sub Test()
Dim Pnt As Variant
Dim CirCenter As Variant
Dim Radius1 As Double, Radius2 As Double
Dim Circle1 As AcadCircle, Circle2 As AcadCircle
Dim TempLine As AcadLine
Dim DistPtCen As Double
Dim PolylinePt As Variant
Dim Polyline As AcadPolyline
Dim Line1 As AcadLine, Line2 As AcadLine
’Enter the center and radius of the circle
CirCenter = ThisDrawing.Utility.GetPoint(, "圆心位置:")
Radius1 = ThisDrawing.Utility.GetDistance(CirCenter, "圆的半径:")
’Draw the circle
Set Circle1 = ThisDrawing.ModelSpace.AddCircle(CirCenter, Radius1)
’Specify the point from where the tangent line start
Pnt = ThisDrawing.Utility.GetPoint(, "切线起点:")
’Draw the point
ThisDrawing.ModelSpace.AddPoint (Pnt)
’Calculate the length of the tangent line
Set TempLine = ThisDrawing.ModelSpace.AddLine(CirCenter, Pnt)
DistPtCen = TempLine.Length
TempLine.Delete
Radius2 = Sqr(DistPtCen ^ 2 - Radius1 ^ 2)
’Draw a auxiliary circle with radius equals the length of tangent line
Set Circle2 = ThisDrawing.ModelSpace.AddCircle(Pnt, Radius2)
PolylinePt = Circle1.IntersectWith(Circle2, acExtendNone)
Set Polyline = ThisDrawing.ModelSpace.AddPolyline(PolylinePt)
’Add tangent lines
Set Line1 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(0))
Set Line2 = ThisDrawing.ModelSpace.AddLine(Pnt, Polyline.Coordinate(1))
’Delete the auxiliary circle and polyline
Circle2.Delete
Polyline.Delete
End Sub
回复