-
Notifications
You must be signed in to change notification settings - Fork 158
Control points getters and setters
It might look confusing when you check the control points and weights getters and setters in the NURBS module. Although the documentation and the examples repository have details on how they are used and stored in the classes, I would like to summarize these details on this wiki page.
During the development of NURBS-Python, the main reference book was The NURBS Book by Piegl and Tiller. On the book, B-Spline shapes use control points, referenced as P
and NURBS shapes use weighted control points, referenced as Pw
. NURBS curves uses a 1-dimensional array of Pw
and NURBS surfaces use a 2-dimensional array of Pw
arranged in order Pw[u][v]
where first dimension corresponds to u-direction and second dimension corresponds to v-direction. ctrlpts_size_u
and ctrlpts_size_v
properties control the 2-dimensional array size where they correspond to len(Pw)
and len(Pw[0])
, accordingly.
For instance:
Pw = [[[1, 2, 1], [3, 4, 1], [5, 6, 1], [7, 8, 1]],
[[1, 2, 1], [3, 4, 1], [5, 6, 1], [7, 8, 1]]]
len(Pw) # equal to 2
len(Pw[0]) # equal to 4
In NURBS-Python, all points are a list of floating point numbers. For instance; [1, 2, 0.5]
might have two different meanings depending on where it is used:
- If it is
Pw
, then it represents a 2-dimensional point withP = [2, 4]
andW = [0.5]
- If it is
P
, then it represents a 3-dimensional point withP = [1, 2, 0.5]
In BSPpline.Surface
class, this property sets/gets P
and in NURBS.Surface
class, this property sets/gets Pw
. Both of them are 2-dimensional array of points.
This property sets/gets 1- dimensional array of unweighted control points in all classes. The weights are automatically generated as an array of 1s or updated with the existing ones in NURBS.Curve
and NURBS.Surface
classes.
This property is only available in NURBS
module. As the name implies, it gets/sets the weights vector. You should set the control points (unweighted ones are good too), before setting the weights.
This property is only available in NURBS
module. It gets/sets Pw
but it accepts 1-dimensional array of points.