SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
100 stars 18 forks source link

Binormals are hard (sweep operations) #68

Open VikingScientist opened 6 years ago

VikingScientist commented 6 years ago
from splipy import *                                                           
from splipy.io import *                                                        
import splipy.curve_factory as cf                                              
import splipy.surface_factory as sf                                            
import splipy.volume_factory as vf                                             
from math import pi                                                            

c1 = cf.line([1,0,0], [5-2.3, 0, 0])                                           
c2 = cf.circle_segment(pi/2, 1.3, center=(5-2.3, 0, 1.3), normal=(0,-1,0))        
c3 = cf.line([5-1, 0, 1.3], [5-1, 0, 10])                                     
c1.append(c2).append(c3)                                                       

vol = vf.sweep(c1, sf.disc(1, type='square'))                                  
vol.refine(2) # just for better plotting resolution                                                                  

with G2("out.g2") as f:                                                        
    f.write(vol)                                                               

The setup is to create a curve piece of a two linear pieces connected by a 90 degree circle segment. Along this curve piece we drag a flat surface disc to sweep out a tube-like volumetric geometry.

binormals

The reason for the bug is that the binormals require acceleration terms to compute, but for linear curve pieces these are [0,0,0]. I tried to create some form of heuristic where it's defined to be along the x/y/z-axis and in addition not parallel to the velocity vector. However it now seems like this heuristic fails at the transition between linear curve pieces and circular curve pieces.

VikingScientist commented 6 years ago

It's hard to define this as a bug since the binormal is mathematically ill-defined along straight lines. However, the reasonable choice given that we can choose any binormal we want (except parallel to the velocity), would be to choose the one which is at the end of the circular piece. From an implementation point of view, this means we have to search along the curve piece for the nearest well-defined binormal which in this case is in the center of the curve. What happens if you have a well-defined binormal both before and after the linear piece; i.e. a U-form of shape with linear-curved-linear-curved-linear structure? Do we do some sort of interpolation between the two nearest binormals?

Tagging this as enhancement since the current implementation isn't exactly wrong, its just impractical.