def example3(): """ Plot a B-Spline curve using a clamped and not clamped partition. """ V = np.array([[-0.,0.], [-0.,6.], [-1.,5.], [-3.,8.], [-1.,14.],[2.,14.],[4.,8.], [2.,5.], [1.,6.], [1.,0.]]) k = 4 pc = np.array([0., 0., 0., 0., 1./7., 2./7., 3./7., 4./7., 5./7., 6./7., 1., 1., 1., 1.]) pnc = np.array([-3./7., -2./7., -1./7., 0., 1./7., 2./7., 3./7., 4./7., 5./7., 6./7., 1., 8./7., 9./7., 10./7.]) fn.drawVertexes(V) fn.drawVertexes(V,'o') fn.drawVertexes(fn.bSpline(V, k, pc)) fn.drawVertexes(fn.bSpline(V, k, pnc))
def example5(): """ Plot a 3 dimensional B-Spline curve. """ V = np.array([[0.,0.,0.], [0.,6.,1.], [-1.,5.,2.], [-3.,8.,3.], [-1.,14.,4.],[2.,14.,5.],[4.,8.,6.], [2.,5.,7.], [1.,6.,8.], [1.,0.,9.]]) k = 4 p = np.array([0.,0.,0.,0.,1./7.,2./7.,3./7.,4./7.,5./7.,6./7.,1.,1.,1.,1.]) fn.drawVertexes(V, 'o') fn.drawVertexes(V) fn.drawVertexes(fn.bSpline(V, k, p))
def exerB_3(): """ Represent the B-Spline for a given control vertexes set with a multeplicity. """ V = np.array([[0.,2.], [1.,0.], [2.,1.], [2.,1.], [3., 0.], [4., 2.]]) k = 3 p= np.array([0., 0., 0., 1./4., 1./2., 3./4., 1., 1., 1.]) fn.drawVertexes(V, 'o') fn.drawVertexes(V) fn.drawVertexes(fn.bSpline(V, k, p))
def exerB_4(): """ Represent the B-Splines for a given control vertexes set with a multeplicity and different nodal partitions, one with a multeplicity and one without. """ V = np.array([[1.,0.], [0.,1.], [2.,1.5], [2.,1.5], [4., 1.], [3., 0.]]) k = 4 ps = [ np.array([0., 0., 0., 0., 1./4., 3./4., 1., 1., 1., 1.]), np.array([0., 0., 0., 0., 1./2., 1./2., 1., 1., 1., 1.]), ] fn.drawVertexes(V, 'o') fn.drawVertexes(V) for p in ps: fn.drawVertexes(fn.bSpline(V, k, p))
def exerB_1(): """ Given a fixed set of control vertexes, represent the B-Spline curves for different nodal partitions and orders. """ V = np.array([[0.5,0.5], [0.4,1.], [1.,1.2], [0.9,0.], [2., 0.1], [1.5, 0.6]]) ks = [2, 3, 4, 5, 6] ps = [ np.array([0., 0., 1./5., 2./5., 3./5., 4./5., 1., 1.]), np.array([0., 0., 0., 1./4., 1./2., 3./4., 1., 1., 1.]), np.array([0., 0., 0., 0., 1./3., 2./3., 1., 1., 1., 1.]), np.array([0., 0., 0., 0., 0., 1./2., 1., 1., 1., 1., 1.]), np.array([0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1.]), ] for p,k in zip(ps, ks): fn.drawVertexes(fn.bSpline(V, k, p)) fn.drawVertexes(V, 'o')
def exerB_2(): """ Given a fixed set of control vertexes, represent the B-Spline curves for different nodal partitions and orders. """ V = np.array([[0.,0.], [-0.4,-0.1], [-1.,0.2], [-0.1,1.], [1., 1.1], [1.1, 0.6], [1.2, 0.7], [1.3, 1.2], [2., 0.8], [2.5, 0.7]]) ks = [4, 4, 6, 6, 8] ps = [ np.array([0., 0., 0., 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]), np.array([0., 0., 0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 4., 4.]), np.array([0., 0., 0., 0., 0., 0., 1., 2., 3., 4., 5., 5., 5., 5., 5., 5.]), np.array([0., 0., 0., 0., 0., 0., 1., 2., 3., 3., 4., 4., 4., 4., 4., 4.]), np.array([0., 0., 0., 0., 0., 0., 0., 0., 1., 2., 3., 3., 3., 3., 3., 3., 3., 3.]), ] for p,k in zip(ps, ks): fn.drawVertexes(fn.bSpline(V, k, p)) fn.drawVertexes(V, 'o') fn.drawVertexes(V)
def exerB_5(): """ Determine different behavior for B-Splines with same control vertexes but different multeplicity. """ Vs = [ np.array([[0.,1.], [1.,0.], [2.,1.], [3., 0.], [4., 1.]]), np.array([[0.,1.], [1.,0.], [2.,1.], [2.,1.], [3., 0.], [4., 1.]]), np.array([[0.,1.], [1.,0.], [2.,1.], [2.,1.], [2.,1.], [3., 0.], [4., 1.]]) ] ks = [4,4,4] ps = [ np.array([0., 0., 0., 0.,1./2., 1., 1., 1., 1.]), np.array([0., 0., 0., 0., 1./4., 3./4.,1., 1., 1., 1.]), np.array([0., 0., 0., 0., 1./2., 1./2., 1./2.,1., 1., 1., 1.]) ] fn.drawVertexes(Vs[0], 'o') fn.drawVertexes(Vs[0]) for V,k,p in zip(Vs,ks,ps): fn.drawVertexes(fn.bSpline(V, k, p))