diff options
Diffstat (limited to 'src/path.c')
-rw-r--r-- | src/path.c | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -39,8 +39,6 @@ path *path_init(double *pos, double *dir, double T0, double range, double theta0 path *p = malloc(sizeof(path)); - p->theta0 = theta0; - p->pos[0] = pos[0]; p->pos[1] = pos[1]; p->pos[2] = pos[2]; @@ -148,6 +146,19 @@ path *path_init(double *pos, double *dir, double T0, double range, double theta0 dz[i] = tmp2[2]; } + /* Calculate the approximate residual scattering RMS. + * + * For a given truncated KL expansion the residual error in the + * approximation is given by: + * + * \sum_{n+1}^\infty sqrt(lambda_k)*sqrt(2/range)*sin(pi*s*(k-0.5)/range) + * + * Since there is no nice closed form solution for this, we estimate it by + * evaluating the result at the middle of the track. */ + p->theta0 = 4*range*pow(theta0,2)*gsl_sf_psi_n(1,p->n-0.5)/pow(M_PI,2); + + p->theta0 = fmax(MIN_THETA0, p->theta0); + p->s = s; p->x = x; p->y = y; @@ -166,8 +177,6 @@ path *path_init(double *pos, double *dir, double T0, double range, double theta0 void path_eval(path *p, double s, double *pos, double *dir, double *T, double *t, double *theta0) { - double range; - pos[0] = interp1d(s,p->s,p->x,N); pos[1] = interp1d(s,p->s,p->y,N); pos[2] = interp1d(s,p->s,p->z,N); @@ -179,20 +188,7 @@ void path_eval(path *p, double s, double *pos, double *dir, double *T, double *t dir[1] = interp1d(s,p->s,p->dy,N); dir[2] = interp1d(s,p->s,p->dz,N); - range = p->s[N-1]; - - /* Calculate the approximate residual scattering RMS. - * - * For a given truncated KL expansion the residual error in the - * approximation is given by: - * - * \sum_{n+1}^\infty sqrt(lambda_k)*sqrt(2/range)*sin(pi*s*(k-0.5)/range) - * - * Since there is no nice closed form solution for this, we estimate it by - * evaluating the result at the middle of the track. */ - *theta0 = 4*range*pow(p->theta0,2)*gsl_sf_psi_n(1,p->n-0.5)/pow(M_PI,2); - - *theta0 = fmax(MIN_THETA0, *theta0); + *theta0 = p->theta0; } void path_free(path *p) |