Your original code works nicely on the part you attached:
Reversing the circle is probably not a solution to keep the pipe oriented properly. What is necessary to control is rather the normal field over a pipe:
You might wanna check how this normal field is oriented for the cases where your algorithm fails. If a pipe is oriented nicely, then the fault should be related to something else.
Reversing the circle is probably not a solution to keep the pipe oriented properly. What is necessary to control is rather the normal field over a pipe:
You might wanna check how this normal field is oriented for the cases where your algorithm fails. If a pipe is oriented nicely, then the fault should be related to something else.