I have trimmed surface and, I want to offset the curve (one of its edges, thus one of the trimming curves) by distance D, such that the off-setted curve stays within this trimmed surface.

But when repeating this for different trimmed surfaces, I notice that when I offset by -0.1, the offset result is inside the trimmed surface sometimes, but outside of it other times (so for the latter, I actually need 0.1).

How can I choose the sign of this offset distance programmatically?

I isolated the problem to these two surfaces. With the same distance value, the result of the offset is very differentâone of them inside the trimmed surface, the other outside.

Iâm struggling to find a way to programmatically know when to reverse the sign of the distance value, because I have many, many surfaces like these mystery.gh (60.8 KB)

If you bake your starting surfaces to rhino, then analyze the directions, you see they have same normals but different UV orientations.
If you have coherent UV orientation and curve orientation (relative to the surface normal) , offset on surface will give you coherent results.

Thank you very much for your help Riccardo! It seems that (pretending the curves surfaces are planes for a second to simplify) the direction of the closed curve (whether they are âright handedâ or âleft handedâ and its relationship (direction of the thumb in the right/left hand rule) to the surface normal affects which way the curve is offset-ed given a distance

I checked the surfaces and they are all pointing at the intended direction (these are tiles on a roof-like structure)

My intuition is that I can use flip curve. But since my curves are closed, a line along the normal vector at a point on the curve did not work

It turns out I need a circle at the plane(point on the surface, its normal vector). Is project(direction=that normal vector, onto=that surface) helped me fix it.

Importantly, the circle alone did nothing as a guide curve (perhaps due to it being planar?)

you can see how the U-V-N (red-green-white) arrows, would result correctly if doing vector cross product (right hand rule) on the top surface, but not on the bottom one.

After I do âUReverseâ on Rhino on the bottom one: