#include
#include
using namespace std;
const int m = 16;
double dknowx[m] =
;double dknowy[m] =
;double dknowdy[m];
double dknowddy[m];
const int n = 15;
double dinsertx[n] =
;double dinserty[n];
double dinsertdy[n];
double dinsertddy[n];
/*out_dy 所求函式值
out_ddy 所求插值點的一階導數
out_dddy 所求插值點的二階導數
in_dx 所求插值點的插值點的x軸座標(公升序排列)
in_dknowx,in_dknowy 已知點的節點座標(公升序排列)
in_dknowdy, in_dknowddy 已知點的節點的一階導和二階導(公升序排列)
in_in 已知節點個數
*/void cubicspline(double out_dy, double out_ddy, double out_dddy,
double in_dx, int in_im,
double in_dknowx, double in_dknowy,
double in_dknowdy, double in_dknowddy,
int in_in)
in_dknowdy[in_in-1]=(3.0*(in_dknowy[in_in-1]-in_dknowy[in_in-2])/h1+in_dknowddy[in_in-1]*h1/2.0-s[in_in-2])/(2.0+in_dknowdy[in_in-2]);
for(j=in_in-2;j>=0;j--)
in_dknowdy[j]=in_dknowdy[j]*in_dknowdy[j+1]+s[j];
for(j=0;j<=in_in-2;j++)
s[j]=in_dknowx[j+1]-in_dknowx[j];
for(j=0;j<=in_in-2;j++)
h1=s[in_in-2]*s[in_in-2];
in_dknowddy[in_in-1]=6.*(in_dknowy[in_in-2]-in_dknowy[in_in-1])/h1+2.*(2.*in_dknowdy[in_in-1]+in_dknowdy[in_in-2])/s[in_in-2];
g=0.0;
for(i=0;i<=in_in-2;i++)
for(j=0;j<=in_im-1;j++)
h1=(in_dknowx[i+1]-in_dx[j])/s[i];
h0=h1*h1;
out_dy[j]=(3.0*h0-2.0*h0*h1)*in_dknowy[i];
out_dy[j]=out_dy[j]+s[i]*(h0-h0*h1)*in_dknowdy[i];
out_ddy[j]=6.0*(h0-h1)*in_dknowy[i]/s[i];
out_ddy[j]=out_ddy[j]+(3.0*h0-2.0*h1)*in_dknowdy[i];
out_dddy[j]=(6.0-12.0*h1)*in_dknowy[i]/(s[i]*s[i]);
out_dddy[j]=out_dddy[j]+(2.0-6.0*h1)*in_dknowdy[i]/s[i];
h1=(in_dx[j]-in_dknowx[i])/s[i];
h0=h1*h1;
out_dy[j]=out_dy[j]+(3.0*h0-2.0*h0*h1)*in_dknowy[i+1];
out_dy[j]=out_dy[j]-s[i]*(h0-h0*h1)*in_dknowdy[i+1];
out_ddy[j]=out_ddy[j]-6.0*(h0-h1)*in_dknowy[i+1]/s[i];
out_ddy[j]=out_ddy[j]+(3.0*h0-2.0*h1)*in_dknowdy[i+1];
out_dddy[j]=out_dddy[j]+(6.0-12.0*h1)*in_dknowy[i+1]/(s[i]*s[i]);
out_dddy[j]=out_dddy[j]-(2.0-6.0*h1)*in_dknowdy[i+1]/s[i];
}
} void calculatedyddy(double out_ddy, double out_dddy,
double in_dpx, double in_dpy, int in_in,
double in_dbdy = 0, double in_dedy = 0,
double in_dbddy = 0, double in_deddy = 0)
system("pause");
}
b樣條和三次樣條 樣條曲線
最近在學習軌跡規劃中的軌跡生成,涉及到樣條曲線方面的知識,總結一下。曲線的平滑性和相應的平滑性的評判準則相關,在 1 中,作者採用曲率的平方和曲率導數的平方作為評判準則 其中 是路徑點的方向角。最小化這兩個準則的軌跡分別是圓弧和三階螺旋線,並對在對稱和不對稱情況下如何生成路徑進行了分析,事實表明三階...
三次B樣條曲線插值c
b樣條擬合通常把離散點集作為控制點來求擬合曲線,原理和過程可參看 如果想要求得過離散點的插值曲線,需要先用離散點反求控制點,然後用求得的控制點擬合曲線。原理在這篇文章中介紹較詳細 通過離散點集反求控制點 vector bsplineinterpolate vector discretepoints ...
b樣條和三次樣條 B樣條 貝塞爾曲線和b樣條曲線
在數學的子學科數值分析裡,b 樣條是樣條曲線一種特殊的表示形式。它是b 樣條基曲線的線性組合。b 樣條是貝茲曲線的一種一般化,可以進一步推廣為非均勻有理b樣.b樣條就相當於乙個函式,這個函式在係數不同時就可以變化成各種曲線形狀.在實際生產中,我們測量得到的是乙個個離散的點,那麼我們要知道相鄰兩個點之...