<p>Based on your linked question, the problem appears to be that you don't get enough samples in highly curved areas of the surface. You could increase the sample density everywhere, but then you oversample the flatter areas and it becomes too slow.</p>

<p>So, you need to increase the sample density locally in areas where it's needed. A conceptually simple algorithm for this is adaptive refinement. You would start out with a uniform sample grid in UV space. Then, detect grid squares in which the curvature is too high for the grid spacing (above some threshold), and subdivide them, adding additional samples in between the existing ones. This process can be repeated recursively on the new, smaller grid squares, subdividing as finely as the surface requires. You can tune the curvature threshold to balance fidelity versus performance.</p>

<p>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.</p>

CC BY-SA 3.0
2016-08-08T04:29:27.650Z
Most software define chord height as a subdivision criteria along with angle error (which is what you describe... ) . Reason being  that usually in engineering solutions the tolerance is usually for deflection from true surface not how well the curvature is preserved. But there is many ways to skim the fish depenzing on what your needs are. Simple UV division can be bad for multipatched /  trimmed surfaces.
joojaa
CC BY-SA 3.0
2016-08-08T00:03:31.260Z
2016-08-08T04:15:03.340Z
2016-08-08T04:15:03.340Z
Nathan Reed
<p>Given that I have implemented a function called <code>calc_bspline_surf()</code> in C, and that function has the following declaration:</p>

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

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

<p>Here is a solution that sampling the 3D points uniformly in two direction</p>

<pre><code>for u = {0, 0.05, ..., 1}
    for v= {0, 0.05, ..., 1}
       calc_bspline_surf(u, v)
</code></pre>

<p><img src="https://i.sstatic.net/6J4Vr.png" alt="enter image description here"></p>

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

CC BY-SA 3.0
2016-08-06T16:13:07.167Z
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?
joojaa
CC BY-SA 3.0
2016-08-07T01:51:08.737Z
@joojaa Sorry for my unclear description. My question originates from this [question](http://mathematica.stackexchange.com/questions/122056/specialized-sampling-techniques-of-built-in-bsplinesurface). For example, in Mathematica, I could use `ParametricPlot3D[f[x, y], {x, 0, 1}, {y, 0, 1}]` to draw a B-spline surface.
xyz
CC BY-SA 3.0
2016-08-07T16:11:39.040Z
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?
trichoplax is on Codidact now
CC BY-SA 3.0
2016-08-08T01:15:01.013Z
@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](https://i.sstatic.net/BmCqn.png)
xyz
<sampling><nurbs>
How to sample 3D points to visualize a B-spline surface?
xyz
# How to sample 3D points to visualize a B-spline surface?

(Asked by: username_0 on 2016-08-06)

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)

```

![enter image description here](https://i.sstatic.net/6J4Vr.png)

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

**Tags:** sampling, nurbs

> **Comments:**
> **username_1**: 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?  
> **username_0**: @username_1 Sorry for my unclear description. My question originates from this [question](http://mathematica.stackexchange.com/questions/122056/specialized-sampling-techniques-of-built-in-bsplinesurface). For example, in Mathematica, I could use `ParametricPlot3D[f[x, y], {x, 0, 1}, {y, 0, 1}]` to draw a B-spline surface.  
> **username_2**: As username_1 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?  
> **username_0**: @username_2 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](https://i.sstatic.net/BmCqn.png)  

---

## 1 answers

### Answer by username_3 on 2016-08-08. Score: 3

Based on your linked question, the problem appears to be that you don't get enough samples in highly curved areas of the surface. You could increase the sample density everywhere, but then you oversample the flatter areas and it becomes too slow.

So, you need to increase the sample density locally in areas where it's needed. A conceptually simple algorithm for this is adaptive refinement. You would start out with a uniform sample grid in UV space. Then, detect grid squares in which the curvature is too high for the grid spacing (above some threshold), and subdivide them, adding additional samples in between the existing ones. This process can be repeated recursively on the new, smaller grid squares, subdividing as finely as the surface requires. You can tune the curvature threshold to balance fidelity versus performance.

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.

> **Comments:**
> **username_1**: Most software define chord height as a subdivision criteria along with angle error (which is what you describe... ) . Reason being  that usually in engineering solutions the tolerance is usually for deflection from true surface not how well the curvature is preserved. But there is many ways to skim the fish depenzing on what your needs are. Simple UV division can be bad for multipatched /  trimmed surfaces.  

---

