Beginning grasshopper question here, couldn’t find the answer through googling, etc…
I’d like to randomly populate a plane with non-overlapping circles of random diameter, using the c# component on the latest Mac release (not WIP). I can successfully check for intersection using the attached, but this still permits circles within circles, as seen in the image. If someone were able to point me to the easiest c# way to get a bool value indicating whether one circle is within another (with the assumption that they are co-planar), I’d be most appreciative and grateful!
Thanks so much for your reply, and for all the other generous replies on this thread, so appreciated, all of you!!!
I should have mentioned that ultimately I’m going to want to compare curves of arbitrary closed shapes, so this trick for circle comparison won’t apply in that case.
Is the easiest thing in this more general case to convert the circles into Breps? In the attached, I convert to Breps, and in order to check whether they intersect, I use Rhino.Geometry.Brep.CreateBooleanIntersection (perhaps this is my first mistake?).
Should I expect to get a null when there is no intersection (or is the lack of intersection not the same thing as “failure”?).
Commenting out either of these two lines shows that this code isn’t quite correct (because the results of the test later on are always the same):
//Point3d myPnt2 = new Point3d(10, 10, 0);
Point3d myPnt2 = new Point3d(3, 3, 0);
Any pointers on how to check for intersection between two Breps?
I’m confused because the problem case is where the intersection test fails (inner curve is contained within but not touching the outer curve) , and therefore there is no event (unless I’m misunderstanding what you’re suggesting)…
What I mean is
for (int j = 0; j < numCircles; j++){
var events = Rhino.Geometry.Intersect.Intersection.CurveCurve(circles[j].ToNurbsCurve(), tempCircle.ToNurbsCurve(), intersection_tolerance, overlap_tolerance);
if (events.Count > 0) {
overlap = true;
}
else
{
add here Curve.Contains(…)
if (contain)
{
overlap =true;
}
}
}
Again, I appreciate your reply!, and again I’m sorry to remain confused, as Curve.Contains expects a Point3d argument. I see how that helps determine if a point is contained by the curve, but I don’t understand how that helps determine whether an inner curve is contained by an outer curve.