Creafting a Brep.IsCurveInside method

Hi everyone, I’m trying to compute if a curve is inside a Sphere (well sometimes it could be a collection of Spheres instead of a single one)

In the scenario I’m working on, it never happens that a curve is tangent to a Sphere (in such a way it would produce a single intersection point)

The best solution I could find (very little coding experience but lot of creativity and will to learn :slight_smile: ) for testing if a Curve is inside a single Sphere is to Intersect.Intersection Sphere and Curve: if zero intersection points are generated then the curve either lies completely inside or completely outside the Sphere (of course if any amount of point is found then the Curve is partially outside and I get my answer)
To check if the point is inside or outside the Sphere I would use Brep.IsPointInside using a random point like Curve.PointAt, or maybe a faster if Curve.PointAt.DistanceTo(Sphere.Center) < Sphere.Radius True = inside, False = outside

For testing with multiple Spheres I was thinking maybe was better to avoid Boolean operations on the Spheres? so my idea was to collect in a list all the curve parameters t where an intersection with a sphere happened, and then run a serie of Brep.IsPointInside(Curve.PointAt( (t[i] + t[i+1]) * 0.5 ) ) but I’m pretty confident I’m not on the right track with that :slight_smile:

what better sistem would you suggest to check for curve inclusion in Spheres/Breps?

Thanks!

I think you are on the right track. That’s the first thing I would think to do. And checking the distance to the sphere centwers is definitely the way to go.

1 Like