質問

以下は、キュービック補間関数である:

public float Smooth(float start, float end, float amount)
{
    // Clamp to 0-1;
    amount = (amount > 1f) ? 1f : amount;
    amount = (amount < 0f) ? 0f : amount;

    // Cubicly adjust the amount value.
    amount = (amount * amount) * (3f - (2f * amount));

    return (start + ((end - start) * amount));
}
1.0F -

この関数は、立方体は0.0fの量、所与の開始と終了の値の間を補間します。あなたはこの曲線をプロットした場合、あなたはこのようなものに終わるだろう。

  

除去期限切れImageShackの画像

ここでは三次関数は、次のとおりです。

    amount = (amount * amount) * (3f - (2f * amount));

どのように私は内外2本の農産物の接線を生成するために、これを調整するのですか?

このような曲線を生成するために:(リニア立方端に開始)

  

除去期限切れImageShackの画像

一の機能として

別として、このような(線形エンド立方開始)

  

除去期限切れImageShackの画像

誰もが任意のアイデアを得ましたか。事前に感謝します。

役に立ちましたか?

解決

何がしたいことはhref="http://en.wikipedia.org/wiki/Cubic_Hermite_spline" rel="nofollow noreferrer">キュービックエルミートスプラインの

altテキスト

P0は開始点であり、P1はエンドポイントである、M0は、開始接線であり、m1は終了接線である

他のヒント

あなたは、線形補間やキュービック補間を持っており、2つの補間機能の間を補間することができます。

すなわちます。

cubic(t) = cubic interpolation
linear(t) = linear interpolation
cubic_to_linear(t) = linear(t)*t + cubic(t)*(1-t)
linear_to_cubic(t) = cubic(t)*t + linear(t)*(1-t)

tが0から範囲です... 1

まあ、簡単な方法は、このようになります:

-Expand your function by 2 x and y
-Move 1 to the left and 1 down
Example: f(x) = -2x³+3x²
g(x) = 2 * [-2((x-1)/2)³+3((x-1)/2)²] - 1

またはプログラム(立方体調整):

double amountsub1div2 = (amount + 1) / 2;
amount = -4 * amountsub1div2 * amountsub1div2 * amountsub1div2 + 6 * amountsub1div2 * amountsub1div2 - 1;

他の一つは、単に「移動」を除外

g(x) = 2 * [-2(x/2)³+3(x/2)²]

またはプログラム(立方体調整):

double amountdiv2 = amount / 2;
amount = -4 * amountdiv2 * amountdiv2 * amountdiv2 + 6 * amountdiv2 * amountdiv2;
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top