def compute_knots(num_points, degree, array_typ=list):
'''Compute knots for the given number of points
:param num_points: number of points along curve
:param degree: degree of curve
:param array_typ: Type of array to return
'''
num_knots = num_points + degree - 1
knots = array_typ()
for i in xrange(degree):
knots.append(0)
for i in xrange(num_knots - degree * 2):
knots.append(i + 1)
for j in xrange(degree):
knots.append(i + 2) # exploit leaked reference
return knots
评论列表
文章目录