9

OpenGL を使用して Hermite 曲線を描画するにはどうすればよいですか? 組み込み関数はありますか? エバリュエーターを使用してベジエ曲線を描画する方法を示すオンラインの例を見ましたが、エルミート曲線に関する情報は見つかりませんでした。

4

3 に答える 3

11

Let the vector of control points for your Bezier be [b0 b1 b2 b3] and those for your Hermite be [h0 h1 v0 v1] (v0 and v1 being the derivative / tangent at points h0 and h1). Then we can use a matrix form to show the conversions:

Hermite to Bezier

[b0] = 1 [ 3  0  0  0] [h0]
[b1]   - [ 3  0  1  0] [h1]
[b2]   3 [ 0  3  0 -1] [v0]
[b3]     [ 0  3  0  0] [v1]

(this is exactly as in Naaff's response, above).

Bezier to Hermite

[h0] = [ 1  0  0  0] [b0]
[h1]   [ 0  0  0  1] [b1]
[v0]   [-3  3  0  0] [b2]
[v1]   [ 0  0 -3  3] [b3]

So in matrix form these are perhaps slightly more complex than needed (after all Naaff's code was short and to the point). It is useful, because we can go beyond Hermites very easily now.

In particular we can bring in the other classic cardinal cubic parametric curve: the Catmull-Rom curve. It has control points [c_1 c0 c1 c2] (unlike Bezier curves, the curve runs from the second to the third control point, hence the customary numbering from -1). The conversions to Bezier are then:

Catmull-Rom to Bezier

[b0] = 1 [ 0  6  0  0] [c_1]
[b1]   - [-1  6  1  0] [c0]
[b2]   6 [ 0  1  6 -1] [c1]
[b3]     [ 0  0  6  0] [c2]

Bezier to Catmull-Rom

[c_1] = [ 6 -6  0  1] [b0]
[c0]    [ 1  0  0  0] [b1]
[c1]    [ 0  0  0  1] [b2]
[c2]    [ 1  0 -6  6] [b3]

I can do the Hermite to Catmull-Rom pair too, but they're rarely used, since Bezier is normally the primary representation.

于 2009-10-22T02:57:37.793 に答える
6

スティーブンが述べたように、3次エルミート曲線を3次ベジェ曲線に変換できます。実はとても簡単です。

典型的な3次エルミート曲線は、2つの点と2つのベクトルで定義されます。

  • P0- 始点
  • V0--デリバティブP0
  • P1- 終点
  • V1--デリバティブP1

キュービックベジェへの変換は単純です。

B0 = P0
B1 = P0 + V0/3
B2 = P1 - V1/3
B3 = P1

次に、エバリュエーターまたはその他の任意の方法を使用してベジェ曲線を描くことができます。

于 2009-07-08T17:07:10.540 に答える
1

任意のエルミート カーブをベジエ カーブに変換して描画できます。これらは、C3 の 2 つの異なるベースを使用して簡単に定義されます。Google はあまり役に立ちませんでした。これはよくある質問のようです。そのため、おそらくサンプル コードを使用して、StackOverflow の回答を決定的なものにするように努める必要があります。明日また来ます。

于 2009-06-23T04:41:48.253 に答える