下面是一个关于活塞形线生成的C#程序,我看不大懂,特别是jerk、acc那块那两个公式什么意思不明白,求解释,越详细越好,谢谢。
double[] D_high = {0,6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 53.9};
double[] D_dec_rad = { -0.0053, -0.0012, 0, -0.0002, -0.0016, -0.0054, -0.0129, -0.0252, -0.0435, -0.0691, -0.0986, -0.1250 };
double[] D_dec_rad_v = new double[20];
//double[] p = new double[200];
double[] p2 = new double[2000];
double[] D_high_subdivision = new double[2000];
double[] t = new double[200];
double p0,p1,v0,v1,T,jerk,acc;
int run = 0;
int run_count = 0;
int I_high = D_high.Length;
int I_dec_rad = D_dec_rad.Length;
//string str_rad_dec_data;
for (int i = 0; i <= I_dec_rad-3; i++)//从1开始赋值
{
D_dec_rad_v[i+1] = Math.Tan((Math.Atan2(D_dec_rad[i + 1] - D_dec_rad[i], D_high[i + 1] - D_high[i]) + Math.Atan2(D_dec_rad[i + 2]- D_dec_rad[i + 1], D_high[i + 2] - D_high[i + 1])) / 2);
}
D_dec_rad_v[0]= 2*D_dec_rad_v[1]-D_dec_rad_v[2];
D_dec_rad_v[I_dec_rad-1] = 2*D_dec_rad_v[I_dec_rad-2]-D_dec_rad_v[I_dec_rad-3];
for (int i = 0; i <= I_dec_rad-2; i++)//从1开始赋值
{
p0 = D_dec_rad[i];
p1 = D_dec_rad[i + 1];
v0 = D_dec_rad_v[i];
v1 = D_dec_rad_v[i + 1];
T = D_high[i + 1] - D_high[i];
jerk = (v1 - v0) / (T * T) - 2 * (p1 - p0 - v0 * T) / (T * T * T);
acc = ((v1 - v0) / T - 3 * jerk * T) / 2;
run = Convert.ToInt32(T / 0.1);
for (int j = 0; j < 200; j++)//从0开始赋值
{
t[j] = 0;
//p[j] = 0;
}
for (int j = 0; j < run; j++)//从0开始赋值
{
t[j] = Convert.ToDouble(j) / Convert.ToDouble(run) * T;
p2[run_count] = p0 + v0 * t[j] + acc * t[j] * t[j] + jerk * t[j] * t[j] * t[j];
D_high_subdivision[run_count] = 0.1 * run_count ;
run_count += 1;
}
D_high_subdivision[run_count] = D_high[I_high -1];
p2[run_count] = D_dec_rad[I_dec_rad-1];
}