<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CIRCLE CIRCLE INTERSECTION in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211550#M20505</link>
    <description>Try this one&lt;BR /&gt;
&lt;BR /&gt;
Public Function GetTwoCirclesInters(p1 As Variant, p2 As Variant, r1 As Double, r2 As Double) As Variant&lt;BR /&gt;
&lt;BR /&gt;
Dim dis As Double&lt;BR /&gt;
Dim ip1 As Variant&lt;BR /&gt;
Dim ip2 As Variant&lt;BR /&gt;
Dim inters(0 To 1, 0 To 2) As Double&lt;BR /&gt;
With ThisDrawing.Utility&lt;BR /&gt;
dis = Distance(p1, p2)&lt;BR /&gt;
If dis &amp;gt; r1 + r2 Then&lt;BR /&gt;
GetTwoCirclesInters = Null&lt;BR /&gt;
Exit Function&lt;BR /&gt;
ElseIf dis &amp;gt;= r1 + r2 + 0.000000000001 Then '&amp;lt;--fuzz&lt;BR /&gt;
ip1 = .PolarPoint(p1, .AngleFromXAxis(p1, p2), r1)&lt;BR /&gt;
ip2 = .PolarPoint(p1, .AngleFromXAxis(p1, p2), r1)&lt;BR /&gt;
Else&lt;BR /&gt;
Dim cosinA As Double&lt;BR /&gt;
Dim ang As Double&lt;BR /&gt;
cosinA = (((r1 * r1) + (dis * dis)) - (r2 * r2)) / (2# * r1 * dis)&lt;BR /&gt;
ang = Atn((Sqr(1 - (cosinA * cosinA))) / cosinA)&lt;BR /&gt;
ip1 = .PolarPoint(p1, .AngleFromXAxis(p1, p2) + ang, r1)&lt;BR /&gt;
ip2 = .PolarPoint(p1, .AngleFromXAxis(p1, p2) - ang, r1)&lt;BR /&gt;
inters(0, 0) = ip1(0): inters(0, 1) = ip1(1): inters(0, 2) = ip1(2)&lt;BR /&gt;
inters(1, 0) = ip2(0): inters(1, 1) = ip2(1): inters(1, 2) = ip2(2)&lt;BR /&gt;
End If&lt;BR /&gt;
End With&lt;BR /&gt;
GetTwoCirclesInters = inters&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function Distance(p1 As Variant, p2 As Variant) As Double&lt;BR /&gt;
Distance = Sqr((p1(0) - p2(0)) ^ 2 + ((p1(1) - p2(1)) ^ 2))&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub test()&lt;BR /&gt;
Dim p1(2) As Double&lt;BR /&gt;
Dim p2(2) As Double&lt;BR /&gt;
Dim r1 As Double&lt;BR /&gt;
Dim r2 As Double&lt;BR /&gt;
p1(0) = 0#: p1(1) = 0#: p1(2) = 0#:&lt;BR /&gt;
p2(0) = -500#: p2(1) = -500#: p2(2) = 0#&lt;BR /&gt;
&lt;BR /&gt;
r1 = 600#: r2 = 300#&lt;BR /&gt;
Dim inters As Variant&lt;BR /&gt;
inters = GetTwoCirclesInters(p1, p2, r1, r2)&lt;BR /&gt;
Dim ip1(2) As Double&lt;BR /&gt;
Dim ip2(2) As Double&lt;BR /&gt;
ip1(0) = inters(0, 0): ip1(1) = inters(0, 1): ip1(2) = inters(0, 2)&lt;BR /&gt;
ip2(0) = inters(1, 0): ip2(1) = inters(1, 1): ip2(2) = inters(1, 2)&lt;BR /&gt;
ThisDrawing.ModelSpace.AddLine ip1, ip2&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
    <pubDate>Fri, 21 Mar 2008 21:53:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-03-21T21:53:18Z</dc:date>
    <item>
      <title>CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211548#M20503</link>
      <description>ANY WIZ KIDS OUT THERE?  GIVEN X1, Y1 AND X2, Y2 AND RADIUS1 AND RADIUS2&lt;BR /&gt;
&lt;BR /&gt;
IS THERE A SIMPLE WAY TO CALCULATE THE TWO INTERSECTIONS WITHOUT ACTUALLY DRAWING TWO CIRCLES IN AUTOCAD?</description>
      <pubDate>Fri, 21 Mar 2008 19:56:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211548#M20503</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-21T19:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211549#M20504</link>
      <description>Don't shout, please</description>
      <pubDate>Fri, 21 Mar 2008 21:52:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211549#M20504</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-21T21:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211550#M20505</link>
      <description>Try this one&lt;BR /&gt;
&lt;BR /&gt;
Public Function GetTwoCirclesInters(p1 As Variant, p2 As Variant, r1 As Double, r2 As Double) As Variant&lt;BR /&gt;
&lt;BR /&gt;
Dim dis As Double&lt;BR /&gt;
Dim ip1 As Variant&lt;BR /&gt;
Dim ip2 As Variant&lt;BR /&gt;
Dim inters(0 To 1, 0 To 2) As Double&lt;BR /&gt;
With ThisDrawing.Utility&lt;BR /&gt;
dis = Distance(p1, p2)&lt;BR /&gt;
If dis &amp;gt; r1 + r2 Then&lt;BR /&gt;
GetTwoCirclesInters = Null&lt;BR /&gt;
Exit Function&lt;BR /&gt;
ElseIf dis &amp;gt;= r1 + r2 + 0.000000000001 Then '&amp;lt;--fuzz&lt;BR /&gt;
ip1 = .PolarPoint(p1, .AngleFromXAxis(p1, p2), r1)&lt;BR /&gt;
ip2 = .PolarPoint(p1, .AngleFromXAxis(p1, p2), r1)&lt;BR /&gt;
Else&lt;BR /&gt;
Dim cosinA As Double&lt;BR /&gt;
Dim ang As Double&lt;BR /&gt;
cosinA = (((r1 * r1) + (dis * dis)) - (r2 * r2)) / (2# * r1 * dis)&lt;BR /&gt;
ang = Atn((Sqr(1 - (cosinA * cosinA))) / cosinA)&lt;BR /&gt;
ip1 = .PolarPoint(p1, .AngleFromXAxis(p1, p2) + ang, r1)&lt;BR /&gt;
ip2 = .PolarPoint(p1, .AngleFromXAxis(p1, p2) - ang, r1)&lt;BR /&gt;
inters(0, 0) = ip1(0): inters(0, 1) = ip1(1): inters(0, 2) = ip1(2)&lt;BR /&gt;
inters(1, 0) = ip2(0): inters(1, 1) = ip2(1): inters(1, 2) = ip2(2)&lt;BR /&gt;
End If&lt;BR /&gt;
End With&lt;BR /&gt;
GetTwoCirclesInters = inters&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function Distance(p1 As Variant, p2 As Variant) As Double&lt;BR /&gt;
Distance = Sqr((p1(0) - p2(0)) ^ 2 + ((p1(1) - p2(1)) ^ 2))&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub test()&lt;BR /&gt;
Dim p1(2) As Double&lt;BR /&gt;
Dim p2(2) As Double&lt;BR /&gt;
Dim r1 As Double&lt;BR /&gt;
Dim r2 As Double&lt;BR /&gt;
p1(0) = 0#: p1(1) = 0#: p1(2) = 0#:&lt;BR /&gt;
p2(0) = -500#: p2(1) = -500#: p2(2) = 0#&lt;BR /&gt;
&lt;BR /&gt;
r1 = 600#: r2 = 300#&lt;BR /&gt;
Dim inters As Variant&lt;BR /&gt;
inters = GetTwoCirclesInters(p1, p2, r1, r2)&lt;BR /&gt;
Dim ip1(2) As Double&lt;BR /&gt;
Dim ip2(2) As Double&lt;BR /&gt;
ip1(0) = inters(0, 0): ip1(1) = inters(0, 1): ip1(2) = inters(0, 2)&lt;BR /&gt;
ip2(0) = inters(1, 0): ip2(1) = inters(1, 1): ip2(2) = inters(1, 2)&lt;BR /&gt;
ThisDrawing.ModelSpace.AddLine ip1, ip2&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Fri, 21 Mar 2008 21:53:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211550#M20505</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-21T21:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211551#M20506</link>
      <description>Fatty,&lt;BR /&gt;
&lt;BR /&gt;
   msgbox "YOU ARE THE MAN"&lt;BR /&gt;
&lt;BR /&gt;
 I always had to draw two circles then then draw lines from the intersect points.   I have to do this many times a day.  Thank you very^100 much!&lt;BR /&gt;
&lt;BR /&gt;
God Bless</description>
      <pubDate>Fri, 21 Mar 2008 23:34:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211551#M20506</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-21T23:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211552#M20507</link>
      <description>Wouldn't it be as easy as...&lt;BR /&gt;
&lt;BR /&gt;
If the distance from pt1 to pt2 is less than or equal to the sum of radius1 &lt;BR /&gt;
and radius2 then they intersect?&lt;BR /&gt;
&lt;BR /&gt;
Jim Dee&lt;BR /&gt;
www.caddee.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;DRKELLOG&gt; wrote in message &lt;BR /&gt;
news:5882860@discussion.autodesk.com...&lt;BR /&gt;
Fatty,&lt;BR /&gt;
&lt;BR /&gt;
   msgbox "YOU ARE THE MAN"&lt;BR /&gt;
&lt;BR /&gt;
 I always had to draw two circles then then draw lines from the intersect &lt;BR /&gt;
points.   I have to do this many times a day.  Thank you very^100 much!&lt;BR /&gt;
&lt;BR /&gt;
God Bless&lt;/DRKELLOG&gt;</description>
      <pubDate>Sat, 22 Mar 2008 02:12:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211552#M20507</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-22T02:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211553#M20508</link>
      <description>Oh, my bad&lt;BR /&gt;
Yes, you are right, CADDee &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Instead of:&lt;BR /&gt;
If dis &amp;gt; r1 + r2 Then&lt;BR /&gt;
GetTwoCirclesInters = Null&lt;BR /&gt;
must be:&lt;BR /&gt;
If dis &amp;lt; r1 + r2 Then&lt;BR /&gt;
GetTwoCirclesInters = Null&lt;BR /&gt;
&lt;BR /&gt;
Thank you &lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Sat, 22 Mar 2008 03:41:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211553#M20508</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-22T03:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211554#M20509</link>
      <description>Please, change it as I wrote abow&lt;BR /&gt;
Glad to help&lt;BR /&gt;
&lt;BR /&gt;
~'J'~

Message was edited by: Fatty</description>
      <pubDate>Sat, 22 Mar 2008 03:42:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211554#M20509</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-22T03:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211555#M20510</link>
      <description>Depends on your definition of "easy".&lt;BR /&gt;
&lt;BR /&gt;
http://local.wasp.uwa.edu.au/~pbourke/geometry/2circle/</description>
      <pubDate>Mon, 24 Mar 2008 14:49:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211555#M20510</guid>
      <dc:creator>jbooth</dc:creator>
      <dc:date>2008-03-24T14:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: CIRCLE CIRCLE INTERSECTION</title>
      <link>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211556#M20511</link>
      <description>Agreed, it's easier a bit:&lt;BR /&gt;
&lt;BR /&gt;
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
&lt;BR /&gt;
Function Get_Dist(p1 As Variant, p2 As Variant) As Double&lt;BR /&gt;
Get_Dist = Sqr((p1(0) - p2(0)) ^ 2 + ((p1(1) - p2(1)) ^ 2))&lt;BR /&gt;
End Function&lt;BR /&gt;
Sub testcircles()&lt;BR /&gt;
' uses algorithm from here:&lt;BR /&gt;
' http://local.wasp.uwa.edu.au/~pbourke/geometry/2circle/&lt;BR /&gt;
Dim oSset As AcadSelectionSet&lt;BR /&gt;
Dim oEnt As AcadEntity&lt;BR /&gt;
Dim oCircle As AcadCircle&lt;BR /&gt;
Dim fcode(0) As Integer&lt;BR /&gt;
Dim fData(0) As Variant&lt;BR /&gt;
Dim dxfCode, dxfValue&lt;BR /&gt;
&lt;BR /&gt;
Dim rad1 As Double&lt;BR /&gt;
Dim rad2 As Double&lt;BR /&gt;
Dim segm As Double&lt;BR /&gt;
Dim hgt As Double&lt;BR /&gt;
Dim dis As Double&lt;BR /&gt;
&lt;BR /&gt;
Dim p1 As Variant&lt;BR /&gt;
Dim p2 As Variant&lt;BR /&gt;
Dim p3 As Variant&lt;BR /&gt;
Dim p4(2) As Double&lt;BR /&gt;
Dim p5(2) As Double&lt;BR /&gt;
&lt;BR /&gt;
Dim x4 As Double&lt;BR /&gt;
Dim y4 As Double&lt;BR /&gt;
Dim x5 As Double&lt;BR /&gt;
Dim y5 As Double&lt;BR /&gt;
Dim z As Double&lt;BR /&gt;
&lt;BR /&gt;
fcode(0) = 0&lt;BR /&gt;
fData(0) = "CIRCLE"&lt;BR /&gt;
&lt;BR /&gt;
dxfCode = fcode&lt;BR /&gt;
dxfValue = fData&lt;BR /&gt;
          With ThisDrawing.SelectionSets&lt;BR /&gt;
               While .Count &amp;gt; 0&lt;BR /&gt;
                    .Item(0).Delete&lt;BR /&gt;
               Wend&lt;BR /&gt;
          End With&lt;BR /&gt;
     With ThisDrawing.SelectionSets&lt;BR /&gt;
          Set oSset = .Add("$mycircles$")&lt;BR /&gt;
     End With&lt;BR /&gt;
 ThisDrawing.Utility.Prompt (vbCrLf &amp;amp; "Select two circles")&lt;BR /&gt;
 oSset.SelectOnScreen dxfCode, dxfValue&lt;BR /&gt;
 If oSset.Count &amp;lt;&amp;gt; 2 Then&lt;BR /&gt;
 MsgBox "Wrong number of circles selected" &amp;amp; vbCr &amp;amp; _&lt;BR /&gt;
 "Try again"&lt;BR /&gt;
 End If&lt;BR /&gt;
 &lt;BR /&gt;
 Set oEnt = oSset.Item(0)&lt;BR /&gt;
 Set oCircle = oEnt&lt;BR /&gt;
 rad1 = oCircle.Radius&lt;BR /&gt;
 p1 = oCircle.Center&lt;BR /&gt;
&lt;BR /&gt;
 Set oEnt = oSset.Item(1)&lt;BR /&gt;
 Set oCircle = oEnt&lt;BR /&gt;
 rad2 = oCircle.Radius&lt;BR /&gt;
 p2 = oCircle.Center&lt;BR /&gt;
 dis = Get_Dist(p1, p2)&lt;BR /&gt;
&lt;BR /&gt;
 segm = ((rad1 ^ 2 - rad2 ^ 2) + dis ^ 2) / (dis * 2)&lt;BR /&gt;
 hgt = Sqr(Abs(rad1 ^ 2 - segm ^ 2))&lt;BR /&gt;
 With ThisDrawing.Utility&lt;BR /&gt;
 p3 = ThisDrawing.Utility.PolarPoint(p1, .AngleFromXAxis(p1, p2), segm)&lt;BR /&gt;
End With&lt;BR /&gt;
x4 = p3(0) + (hgt * (p1(1) - p2(1))) / dis&lt;BR /&gt;
y4 = p3(1) - (hgt * (p1(0) - p2(0))) / dis&lt;BR /&gt;
x5 = p3(0) - (hgt * (p1(1) - p2(1))) / dis&lt;BR /&gt;
y5 = p3(1) + (hgt * (p1(0) - p2(0))) / dis&lt;BR /&gt;
p4(0) = x4: p4(1) = y4: p4(2) = 0#&lt;BR /&gt;
p5(0) = x5: p5(1) = y5: p5(2) = 0#&lt;BR /&gt;
 &lt;BR /&gt;
ThisDrawing.ModelSpace.AddLine p4, p5&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Mon, 24 Mar 2008 17:54:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/circle-circle-intersection/m-p/2211556#M20511</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-03-24T17:54:28Z</dc:date>
    </item>
  </channel>
</rss>

