How to calculate the normal of points on a three-dimensional cubic Bezier curve, given the normal to its start and end points?

I am trying to make a “three-dimensional tape” using one three-dimensional cubic Bezier curve to describe it (the width of the tape is constant). The first and last control points have a normal vector associated with them (which are always perpendicular to the tangents at these points and describe the normal surface of the tape at these points), and I'm trying to smoothly interpolate the normal vector over the course of the curve.

For example, taking into account the curve that forms the letter "C", with the first and last control points having surface normals pointing up, the tape should begin smoothly, parallel to the ground, slowly rotate, and then end again, turning in the same way as the first control point. To do this “smoothly,” he would have to look outward halfway through the curve. At the moment (for this case) I was able to get all the surfaces up (and not out in the middle), which creates an ugly transition in the middle.

It's hard to explain, I attached a few images below this example to how it looks now (all surfaces are facing up, a sharp click in the middle) and how it should look (smooth transition, surfaces slowly rotate round). Silver faces represent the front, black faces the back.

It’s not what he looks like now:

The correct tape is http://img211.imageshack.us/img211/4659/ribbonincorrect.th.png

Correct how it should look:

Wrong tape http://img515.imageshack.us/img515/2673/ribboncorrect.th.png

All I really need is to compute this “hybrid normal vector” for any point on the 3D cubic bezier curve, and I can create polygons without problems, but I cannot figure out how to get them to smoothly rotate the round ones as shown. Totally stuck on how to act!

+4
source share
1 answer

You can use the algorithm described in the first part of this answer , evaluating the normals at t = 0 (or fixed t, depending on what you choose) will give you a smooth transition.

Like this:

alt text

(Imagine your sidewalk along the blue-red border)

Edit

Ok, this is what I got differently:

alt text

The procedure is simple:

Have your parameterized function:

f[t] := { x[t], y[t], z[t] } 

Calculate the tangent vector by taking the derivatives:

 f'[t] := { x'[t], y'[t], z'[t] } 

Select your starting (and ending normal vector), for example:

 n[0] = {0, 0, 1}; 

Now we define another function as the vector product of the derivative and your normal:

 cp[t_] := CrossProduct[f'[t], n[0]]; 

What is it.

The points of my quadrangles lie in:

  {f[t] - cp[t]/3, f[t] + cp[t]/3, f[t + dt] + cp[t + dt]/3, f[t + dt] - cp[t + dt]/3} 

where dt is the increment you like.

A more sophisticated approach may take into account the path length of the curve, but I assume this is the second iteration of the algorithm.

NTN!

+2
source

Source: https://habr.com/ru/post/1333425/


All Articles