さらに良い解決策は、Logistic functionのような機能を使用することです。現在の高度が明示的に精度releatedエラーのすべての種類を導入反復計算に頼る必要はありません計算されているので
Double minAlt = 0.0;
Double maxAlt = 500000.0;
Int32 numberSteps = 1000;
Double boundary = +6.0;
for (Int32 step = 0; step < numberSteps; step++)
{
Double t = -boundary + 2.0 * boundary * step/(numberSteps - 1);
Double correction = 1.0/(1.0 + Math.Exp(Math.Abs(boundary)));
Double value = 1.0/(1.0 + Math.Exp(-t));
Double correctedValue = (value - correction)/(1.0 - 2.0 * correction);
Double curAlt = correctedValue * (maxAlt - minAlt) + minAlt;
}
。
関数の形状を調整する方法のサンプルコードを参照してください。
ここには、この機能を表示するコンソールアプリケーションのサンプルがあります。あなたは、その行動の感情を得るためにパラメータを少し再生することができます。
using System;
namespace LogisticFunction
{
class Program
{
static void Main(string[] args)
{
Double minAlt = 5.0;
Double maxAlt = 95.0;
Int32 numberSteps = 60;
// Keep maxAlt and numberSteps small if you don't want a giant console window.
Console.SetWindowSize((Int32)maxAlt + 12, numberSteps + 1);
// Positive values produce ascending functions.
// Negative values produce descending functions.
// Values with smaller magnitude produce more linear functions.
// Values with larger magnitude produce more step like functions.
// Zero causes an error.
// Try for example +1.0, +6.0, +20.0 and -1.0, -6.0, -20.0
Double boundary = +6.0;
for (Int32 step = 0; step < numberSteps; step++)
{
Double t = -boundary + 2.0 * boundary * step/(numberSteps - 1);
Double correction = 1.0/(1.0 + Math.Exp(Math.Abs(boundary)));
Double value = 1.0/(1.0 + Math.Exp(-t));
Double correctedValue = (value - correction)/(1.0 - 2.0 * correction);
Double curAlt = correctedValue * (maxAlt - minAlt) + minAlt;
Console.WriteLine(String.Format("{0, 10:N4} {1}", curAlt, new String('#', (Int32)Math.Round(curAlt))));
}
Console.ReadLine();
}
}
}
私が探しているかもしれません!私はそれをテストしてみましょう – Malfist
私はそれを間違った方法で実装しているかもしれないと思います。私は最初の反復の巨大なジャンプを取得しますが、それ以降は誰もがそれをすべきです。次のコード行があります。double curAlt = 1 /(1 + Math.Exp(-t))*(properties.endingAltitude) - properties.startingAltitude; – Malfist
また、私はカーブの前半または後半だけを望んでいます、どうすればいいですか? – Malfist