SINTEF / Splipy

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

Fixes #141: volume.edge_surfaces on 6 edge input #143

Closed VikingScientist closed 3 years ago

VikingScientist commented 3 years ago

Solution provided by github user UnaiSan

VikingScientist commented 3 years ago

I was looking around for a better indexing solution to extract unconnected submatrices. Matlab allows this syntax

controlpoints([1,end], [1,end], :)

instead of

 controlpoints[0, 0, :] = vol1.controlpoints[0, 0]
 controlpoints[0, 1, :] = vol1.controlpoints[0, -1]
 controlpoints[1, 0, :] = vol1.controlpoints[-1, 0]
 controlpoints[1, 1, :] = vol1.controlpoints[-1, -1]

but the closest I came was numpy.id, but I couldn't make that one pretty. It is especially annoying that it does not support the :-operator on the last axis and you have to do something like

controlpoints(np.ix([0,-1], [0,-1], np.arange(controlpoints.shape[2]))

which I honestly don't feel contribute to the readability.