Loft twisting between sections

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
Joel_graff
Posts: 1222
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Loft twisting between sections

Postby Joel_graff » Wed Jan 23, 2019 7:47 pm

So I'm playing with building rules lofts along splines by auto-generating the loft sections from a master sketch, then aligning them normal to the spline at a fixed interval.

It works really well! However, there's one small issue. Every once in a while, the loft "twists" between sections - the edges cross over to opposite points between two sections.

In the image below, I'm using a sketch of a rectangle, so each section consists of four points. All sections are the same dimenstions, they only differ in their position and orientation.

If I set the section interval to 5 feet or less, it looks fine (top picture), but once I set it to 6 feet or higher, the "twist" appears (bottom picture). The sections, incidentally, are about 12 feet wide and 1 foot thick.

Is this a bug or just something I don't understand about lofting?
Capture1.JPG
Capture1.JPG (18.68 KiB) Viewed 149 times
Capture.JPG
Capture.JPG (18.17 KiB) Viewed 149 times
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
Bance
Posts: 203
Joined: Wed Feb 11, 2015 3:00 pm
Location: London

Re: Loft twisting between sections

Postby Bance » Wed Jan 23, 2019 11:37 pm

I don't know if it's pertinent, or even entirely correct, but I seem to remember reading somewhere that the order of creation of lofts can cause this....

meaning the sections should be created in the order that they are lofted through?

Hope someone more enlightened can help more.
Steve.
User avatar
Joel_graff
Posts: 1222
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Loft twisting between sections

Postby Joel_graff » Thu Jan 24, 2019 11:32 am

Bance wrote:
Wed Jan 23, 2019 11:37 pm
I don't know if it's pertinent, or even entirely correct, but I seem to remember reading somewhere that the order of creation of lofts can cause this....

meaning the sections should be created in the order that they are lofted through?

Hope someone more enlightened can help more.
I didn't know that, but I assumed it was likely the case. That said, they're generated programmatically, stepping incrementally along the path, so, yes, they're in order. ;)
You can find the FreeCAD Trails workbench for transportation engineering on my github at:
https://www.github.com/joelgraff/freecad.trails
User avatar
microelly2
Posts: 4242
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Loft twisting between sections

Postby microelly2 » Thu Jan 24, 2019 12:08 pm

If the curvature changes into the other direction the binormal vector flips too.
To avoid this these vectors (tangent, normal) must be monitored along the path and when a flip is detected there must be a flag in the calculation which switches back.
This can be done in a extra script. Loft does not handle this.
I have this method soemwhere in my scripts to compute ways on terrains. I must look where it is exactly
this was the use case
https://youtu.be/ZwJ26sdSN_E