Grasshopper

algorithmic modeling for Rhino

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.

Views: 5255

Replies to This Discussion

Whats wrong with the OnNurbsCurve.IntersectCurve method?
I only want to find shorter and faster way :)
I want to find tangent point on circle from a point.
I must do many steps, Thales'circle ..convert OnCircle to OnNurbsCurve and I don't understand ArrayOnX_EVENT :) (then I stop),
How can I use ArrayOnX_EVENT back in to curve? Is it a parameter of curve?

Now I use math definition in my class, but for similar problems I want to know if is possible to use any other Rhino method to do it.

Thank.
If all you want is the tangent point from the closest point, then try the following...

myClosePt = myCircle.ClosestPointTo(myTestPoint, dblOutCiParam)
tangentAtClosePt = myCircle.TangentAt(myCloseParam)
Sorry I should have uploaded the picture first.
I have A point and circle. And I want B1 and B2 points.
Some other ideas? I use math like this:
http://local.wasp.uwa.edu.au/~pbourke/geometry/2circle/
I need only lenght of (a) side. Then from Acos(a/r) I have angle for vector. I think easy and it works.

Could you explain the ArrayOnX_EVENT please, or how I can get a intersect point from OnNurbsCurve.IntersectCurve method.
Thanks ;)
Attachments:
Thanks for sharing the intersection method.. I remember doing those kind of things several years ago in high-school. Its all become very rusty-dusty now.. good to brush up.

And about the "Could you explain the ArrayOnX_EVENT please, or how I can get a intersect point from OnNurbsCurve.IntersectCurve method."
.. just scroll down.. I already explained it in detail.
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).
Thanks for OnUtil, it is a strong class. :)
But I don't understand intersect of two planes of the circles. When my cicles are on same plane I can't use it? Am i wrong?
I have found the matematic method, and it is good for me now, thanks a lot for a help.
I was surprised too to find that there is no mathematical intersection method for Circle-Circle. Mathematical intersections for sure would be far faster than Nurbs intersections.

Anyhow, I think the line-circle method could work well if the circles are not coplanar.. but if they are, the plane-plane intersection would probably be inconclusive.

To answer Kurilla's question, ArrayOnX_EVENT is an an "Array of Intersection events", which contains one OnX_Event for each intersection of the two geometries in question. You could use a for loop to run through each intersection event, and access various properties of the OnX_Event through the intellisense. Typically, it returns the parameters at the intersection for both geometries and the points at the intersections, and a few other things that I have never needed to use. Hope this helps.

You mentioned "Now I use math definition in my class"...
So did you find/write a mathematical intersection solver for two circles? If you found it somewhere on the internet, would you be able to share it? It would be very valuable to circumvent the nurbs intersection solver for a mathematical solver.
Circle-Circle in 3D is not a very useful operation. Since it is impossible to define 2D circles in Rhino, the chances that two circles are *exactly* in the same plane to begin with are pretty slim.

It's also reasonably easy to write a Circle-Circle intersector in 2D, a few ifs, a few cosines and you're done.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
"it is impossible to define 2D circles in Rhino"

-- did you mean 3D circles in Rhino or did you actually mean 2D circles? I find it very counter-intuitive because I thought objects such as rectangles/circles/planes would by default be flat!

I thought circles/lines/rectangles are mathematical objects, that can be defined purely by equations, and therefore intersections can be computed by mathematical solvers..
Yes, obviously a circle is always flat, but it can still be oriented in 3D space. Two circles in the 2D plane (just like two lines) have very well defined intersection points. Two circles (or two lines) in 3D space probably don't have intersection points, unless they lie exactly in the same plane. This is of course possible with standard planes such as World_XY, but as soon as you start dealing with angled planes, you also have to start dealing with binary noise in the origin and normal vector digits.

It is far more likely that two circles that are more or less co-planar, but only within some tolerance (geometric operations such as fitting, scaling, rotation, even translation always introduce 'fuzz' in the least significant digits). There are many ways to deal with these wandering digits and which method is best depends on the particular situation you're in.

The upshot of all this is that the best you can do in 3D is typically find the points on both curves where they approach each other the most, then measure the distance between those two points and call it an intersection if this distance is less than some predefined accuracy measure. You do however end up with 2 intersection points that lie close together, instead of the single one you'd get in 2D.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hmm.. I get it now. For a minute I thought you meant it was impossible to define 2D circles, even on the World Cplanes. Now it all makes sense.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service