Circle Circle Intersection or Curve Curve Intersection or Tangent Circle Point

Hello
I have two OnCircle objects , and I need to find intersect points.
I tried to convert OnCircle to OnNurbsCurve and used .IntersectCurve, but I hope there is an easy way how to do it.
Thanks.

or:

I have a On3dPoint and I want to find its tangent point on the circle or on curve.
like On3dPoint.TangentTo(circle)
Thanks.
Load Previous Replies
  • up

    Damien Alomar

    If you have two OnCircles, then you should try and use more mathematical based solvers as opposed to the "physical" solvers that you'll have when finding the intersections of pure NURBS curves. Unfortunately though, Rhino does not have a circle/circle intersector (I don't know why), so you'll have to do a little bit of juggling to find the intersection. Rhino does have a line/circle intersector, so if you first intersect the two planes of the circles to find a line, then intersect that line with one of the circles, you can get the intersection points. Both the plane/plane intersector and the line/circle intersector can be accessed through OnUtil.ON_Intersect. There are 11 different overloads for that function, so step through intellisense to find the one that you need. Remember that any variable that has ByRef in front of it will be information that you get out of the function. In this case filling out those values is the info that you need, not what the actual function returns (which is either an integer for the number of intersections or a boolean value).
    6
  • up

    Lukáš Kurilla

    Here is a part of my class in GH I hope it will help for easy understanding and use. Have a fun!
    Lukas
    1
    • up

      Jason Lim

      Hi,

      Following up on the suggestion to use a mathematical solution to find the intersection points,
      here is a vb function that should work for 2 circles on the world xy plane:

      'This is based on Paul Bourke's "Intersection of Two Circles"

      Dim r0, r1 As Double
      r0 = x.radius
      r1 = y.radius

      Dim p0, p1 As On3dPoint
      p0 = x.Center
      p1 = y.Center

      Dim d As Double
      d = p0.DistanceTo(p1)

      Dim a, h As Double
      a = ((r0 * r0) - (r1 * r1) + (d * d)) / (2 * d)
      h = math.sqrt((r0 * r0) - (a * a))

      Dim p2x, p2y As Double
      p2x = p0.x + a * (p1.x - p0.x) / d
      p2y = p0.y + a * (p1.y - p0.y) / d

      Dim xPt1 As New On3dpoint()
      xPt1.x = p2x + h * (p1.y - p0.y) / d
      xPt1.y = p2y - h * (p1.x - p0.x) / d

      Dim xPt2 As New On3dpoint()
      xPt2.x = p2x - h * (p1.y - p0.y) / d
      xPt2.y = p2y + h * (p1.x - p0.x) / d

      ptA = xPt1 'A changed to ptA
      ptB = xPt2


      Hope it helps