In order to create curve by CVs we need to construct knot vector. It should have numberOfCVs + degree - 1 knot values. This small snippet takes number of CV and degree of the curve, and returns knot vector values as list. Maybe it will be useful for somebody.
def createKnotVectorString(cvNum, degree): """ @param int cvNum: number of CVs in constructing curve. @param int degree: degree of constructing curve. @return list """ if cvNum <= degree: print "warning, number of CVs can't be less than degree + 1" return None tailsSize = degree knotsNum = cvNum + degree - 1 knotsArray = [0]*knotsNum for i in range(0, len(knotsArray)-degree+1): knotsArray[i + degree-1] = i tailValue = knotsArray[-tailsSize-1] + 1 for i in range(1,tailsSize): knotsArray[-i] = tailValue return knotsArray print createKnotVectorString(4, 3)
No comments:
Post a Comment