# How to sample 3D points to visualize a B-spline surface?

Given that I have implemented a function called calc_bspline_surf() in C, and that function has the following declaration:

calc_bspline_surf(ctrlnet, p, q, U, V, u, v)
/*
ctrlnet --> control net of B-spline surface
p, q --> degree of B-spline surface
U, V --> the knots vector in two directions
u, v --> parameter pair
*/


So for a pair of parameters {u, v}, corresponding B-spline surface coordinate could be generated via calling function calc_bspline_surf(u, v).

Here is a solution that sampling the 3D points uniformly in two direction

for u = {0, 0.05, ..., 1}
for v= {0, 0.05, ..., 1}
calc_bspline_surf(u, v)


However, how many 3D-points I need to sample? Is there classical sample strategy?

• Your question header seems to ask a different question than the body of your question. So which is it? How to sample points or how many do you need to sample? Commented Aug 6, 2016 at 16:13
• @joojaa Sorry for my unclear description. My question originates from this question. For example, in Mathematica, I could use ParametricPlot3D[f[x, y], {x, 0, 1}, {y, 0, 1}] to draw a B-spline surface.
– xyz
Commented Aug 7, 2016 at 1:51
• As joojaa points out, the question in your title is different from the rest of your question. Are you looking to only sample uniformly, and adjust only the size of the sample, or are you also interested in sampling in different ways, that may reduce the number of points required? Commented Aug 7, 2016 at 16:11
• @trichoplax Obviously, the uniformly sample is not a good method. My confusion is whether exist a specialized algorithm about sampling 3D-points and visualization for the B-spline surface. Please see this screenshots
– xyz
Commented Aug 8, 2016 at 1:15

Since B-splines (NURBS) are based on rational functions, I would guess that the maximum curvature in a region can be found (or at least bounded) analytically. This would be ideal, if possible, since it would avoid the problem of missing a small high-curvature area if none of the initial grid points happen to land in it. However, in a pinch the curvature can be estimated by looking at the sample points you've evaluated. For instance, if $p_1, p_2, p_3$ are three sample points collinear in UV space, they should be close to collinear as well, if the surface is adequately sampled. So, you could for instance evaluate $$\frac{\|p_2 - p_1\| + \|p_3 - p_2\|}{\|p_3 - p_1\|}$$ where the double bars mean vector length. If this is greater than some threshold value such as 1.1 or 1.5 (note that 1.0 would be perfectly flat), then you would subdivide the area between these points.