Hi,

For some reason trim region doesn’t figure out that a part of the circle is inside the region. It seems to happen when a part of the curve is on the point where the seam of the region is.

181206 Trim region.gh (7.2 KB)

Hi,

For some reason trim region doesn’t figure out that a part of the circle is inside the region. It seems to happen when a part of the curve is on the point where the seam of the region is.

181206 Trim region.gh (7.2 KB)

1 Like

Hi @siemen,

A workaround could look like this:

First you intersect the circle with the rectangle to find the parameters t on the circle, where it intersects the rectangle. The t parameters can then be used to shatter the circle - in your case - into two curves.

Now, to evaluate which of both curves is outside and which inside the rectangle, you can divide both curves and evaluate their division points for regional relationships with the rectangle. `Point in Curve`

gives you three possible values: 0 means that a point is outside, 1 means coincident, and 2 that the point is inside.

Since you have a number of division points with different values per curve, you now need to evaluate, if at least one division point is inside (value 2) the rectangle to determine if its curve lies inside. The problem is that each curve has two coincident points (value 1) with the rectangle (previous intersection points).

To find which distinct values the curve division points have, you can construct a set. If a curve has the distinct values 0 and 1 (sum 1), it is outside, if it has 1 and 2 (sum 3), it is inside, and if it has only 1, it would intersect the rectangle. In order to generate a dispatch pattern for inside and outside curves, you simply check if the added values (sums) for each set are bigger than their list length. If there are two values, the list length equals 2. Only if the sum of the values is 3 (1 coinciding + 2 inside) and thus bigger than the list length of the values, the curve is inside the rectangle.

There might be other ways to accomplish this, but this works perfectly for your example.

181206 Trim region V2.gh (11.7 KB)

Hi @p1r4t3b0y,

Thanks for your in-depth reply and maybe I should’ve been more clear, sorry about that. I mainly wanted to point out the potential bug in this component. I already have a quick fix which goes like this:

181206 Trim region fix.gh (9.6 KB)