toma
01-14-2004, 03:56 AM
Hi,
I'm having a problem with the spline function.
Below is some very simplified code. My problem is that I cannot seem to get the spline to go through the first point (0,0) whatever end derivatives I use (slightly better with 1e30 but still gives 4 instead of 0). Can anyone spot something that I am doing wrong??
Thanks very much for your help
Tom
int main()
{
float x[] = {0, 40, 80,120,140,180};
float y[] = {0, 6 , 8, 8, 7, 6};
float y2[6];
spline(x, y, 6, 0, 0, y2);
float ty;
int tx;
for (tx = 0; tx <= 180; tx += 20)
{
splint(x, y, y2, 6, tx, &ty);
printf("TX %4d: TY %3.2f\n",tx,ty);
}
return 0;
}
Output is:
TX 0: TY 12.12
TX 20: TY 7.27
TX 40: TY 6.00
TX 60: TY 6.76
TX 80: TY 8.00
TX 100: TY 8.46
TX 120: TY 8.00
TX 140: TY 7.00
TX 160: TY 6.47
TX 180: TY 6.00
I'm having a problem with the spline function.
Below is some very simplified code. My problem is that I cannot seem to get the spline to go through the first point (0,0) whatever end derivatives I use (slightly better with 1e30 but still gives 4 instead of 0). Can anyone spot something that I am doing wrong??
Thanks very much for your help
Tom
int main()
{
float x[] = {0, 40, 80,120,140,180};
float y[] = {0, 6 , 8, 8, 7, 6};
float y2[6];
spline(x, y, 6, 0, 0, y2);
float ty;
int tx;
for (tx = 0; tx <= 180; tx += 20)
{
splint(x, y, y2, 6, tx, &ty);
printf("TX %4d: TY %3.2f\n",tx,ty);
}
return 0;
}
Output is:
TX 0: TY 12.12
TX 20: TY 7.27
TX 40: TY 6.00
TX 60: TY 6.76
TX 80: TY 8.00
TX 100: TY 8.46
TX 120: TY 8.00
TX 140: TY 7.00
TX 160: TY 6.47
TX 180: TY 6.00