Download AmberTools Users` Manual
Transcript
11 NAB: Sample programs
30
}
31
32
33
34
spline( a, x, npts, 1e30, 1e30, x2, tmp );
spline( a, y, npts, 1e30, 1e30, y2, tmp );
spline( a, z, npts, 1e30, 1e30, z2, tmp );
35
36
37
li = 1; la = 1.0; lx = x[1]; ly = y[1]; lz = z[1];
printf( "%8.3f %8.3f %8.3f\\n", lx, ly, lz );
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
while( li < npts ){
ni = li + 1;
na = a[ ni ];
nx = x[ ni ]; ny = y[ ni ]; nz = z[ ni ];
dx = nx - lx; dy = ny - ly; dz = nz - lz;
d = sqrt( dx*dx + dy*dy + dz*dz );
if( d > RISE ){
tfrac = frac = .5;
for( i = 1; i <= MAXI; i = i + 1 ){
na = la + tfrac * ( a[ni] - la );
splint( a, x, x2, npts, na, nx );
splint( a, y, y2, npts, na, ny );
splint( a, z, z2, npts, na, nz );
dx = nx - lx; dy = ny - ly; dz = nz - lz;
d = sqrt( dx*dx + dy*dy + dz*dz );
frac = 0.5 * frac;
if( APPROX( d, RISE ) )
break;
else if( d > RISE )
tfrac = tfrac - frac;
else if( d < RISE )
tfrac = tfrac + frac;
}
printf( "%8.3f %8.3f %8.3f\\n", nx, ny, nz );
}else if( d < RISE ){
li = ni;
continue;
}else if( d == RISE ){
printf( "%8.3f %8.3f %8.3f\\n", nx, ny, nz );
li = ni;
}
la = na;
lx = nx; ly = ny; lz = nz;
}
Execution begins in line 25 where the points are read from stdin one point or three numbers/line and stored in the three arrays x, y and z. The independent variable for each spline, stored
in the array a is created at this time holding the numbers 1 to npts. The second derivatives for
the three splines, one each for interpolation along the X, Y and Z directions are computed in
lines 32-34. Each call to spline() has two arguments set to 1e30 which indicates that the sec-
242