construct_knotvector

compas.geometry.construct_knotvector(degree, pointcount)[source]

Construct a nonperiodic (clamped), uniform knot vector for a curve with given degree and number of control points.

This function will generate a knotvector of the form [0] * (order) + [i / d for i in range(1, d)] + [1] * (order), with order = degree + 1 and d = pointcount - degree. Therefore the length of the knotvector will be pointcount + degree + 1.

For example, if degree is 3 and the number of control points is 7, the knot vector will be [0, 0, 0, 0, 1/4, 2/4, 3/4, 1, 1, 1, 1].

Parameters:
degreeint

Degree of the curve.

pointcountint

The number of control points of the curve.

Returns:
list[float]

Knot vector.

Raises:
ValueError

If the number of control points is less than degree + 1.

References

The NURBS Book. Chapter 2. Page 66.