計算機程式設計/物理/加速物體的位移函式
外觀
加速物體的位移可以用數學函式 描述。可以使用泰勒級數 獲得廣義函式
- ,
其中 是 階導數
- 等等。
此函式的精度取決於所用項數,因為 迅速減小。此外,時間 可以同步,使得 (麥克勞林級數)。
注意,對於恆定加速度,大多數項將變為零,只剩下
或者
C++
[edit | edit source]template<class Vector,class Number>
Vector PositionAcceleratingBody(Vector *s0,Number t,size_t Accuracy)
{
Vector s(0); //set to zero if int, float, etc. or invoke the
// "set to zero" constructor for a class
Number factor(1);//0!==1 and t^0==1
for(size_t n(0);n<Accuracy;n++)
{
if(n)factor*=(t/n);//0!==1 and t^0==1
s+=(factor*s0[n]); //s0 is the array of nth derivatives of s
// at t=t0=0
}
return s;
}
使用泰勒級數的理由
[edit | edit source]泰勒級數可以透過系統地選擇哪些變數是常數,然後將其外推到無限極限來推導。
- 恆定位置
- 或者
- 恆定速度
- 或者
- 恆定加速度
- 或者
- 加速度的變化率恆定
- 或者
- 等等。