# (Problem with Example file) Offset Curve on Trimmed Surface

Hi community,

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?

Thanks a lot!

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)

this might be one way for this particular case:

the principle is: inward offset curve length is shorter than outward offset curve length

itâs 100% reliable on planar curves, not always reliable for surfaces, but in this particular case should work

mystery_Re.gh (66.3 KB)

1 Like

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.

2 Likes

Thanks very much for your help inno!

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?)