12 double vkvang_(
double *crs,
double *centr,
const double *r__,
const double *
xd,
14 double ret_val, cosf, sinf, cosp, sinp;
21 sinf = (crs[1] - centr[1]) / *r__;
22 cosf = -(crs[2] - centr[2]) / *r__;
23 sinp = *
xd * sinf - *yd * cosf;
25 cosp = *
xd * cosf + *yd * sinf;
27 ret_val = atan2(sinp, cosp);
42 double vkvFastV(
double *
p1,
double *
p2,
const double* vRef,
double dbmag,
double *
out)
46 double r1, r2, z1, z2, a01[3], a02[3], dc, an[2];
47 double ar1, ar2, xd1, xd2, yd1, yd2, dz1, dz2, pt1, pt2, pz1, pz2,
det;
51 #define cross_ref(a_1,a_2) cross[(a_2)*3 + (a_1) - 4]
61 if (dbmag <= .1) {loc_bmag = 0.1;}
63 double psum[3]={0.,0.,0.};
double ptmp[3]={0.,0.,0.};
64 vkPerigeeToP(&
p1[3],ptmp,loc_bmag); psum[0]+=ptmp[0];psum[1]+=ptmp[1];psum[2]+=ptmp[2];
65 vkPerigeeToP(&
p2[3],ptmp,loc_bmag); psum[0]+=ptmp[0];psum[1]+=ptmp[1];psum[2]+=ptmp[2];
77 pz1 = pt1 /
tan(
p1[3]);
78 pz2 = pt2 /
tan(
p2[3]);
87 a01[1] = -
p1[1] * xd1;
90 a02[1] = -
p2[1] * xd2;
93 cent1[0] = a01[0] - r1 * yd1;
94 cent1[1] = a01[1] + r1 * xd1;
95 cent2[0] = a02[0] - r2 * yd2;
96 cent2[1] = a02[1] + r2 * xd2;
98 an[0] = cent2[0] - cent1[0];
99 an[1] = cent2[1] - cent1[1];
100 dc = sqrt(an[0]*an[0] + an[1]*an[1]);
104 if (dc <= std::abs(ar1 - ar2)) {
106 cross_ref(1, 1) = ar1 / dc * (cent1[0] - cent2[0]) + cent1[0];
107 cross_ref(1, 2) = ar2 / dc * (cent1[0] - cent2[0]) + cent2[0];
108 cross_ref(2, 1) = ar1 / dc * (cent1[1] - cent2[1]) + cent1[1];
109 cross_ref(2, 2) = ar2 / dc * (cent1[1] - cent2[1]) + cent2[1];
111 cross_ref(1, 1) = ar1 / dc * (cent2[0] - cent1[0]) + cent1[0];
112 cross_ref(1, 2) = ar2 / dc * (cent2[0] - cent1[0]) + cent2[0];
113 cross_ref(2, 1) = ar1 / dc * (cent2[1] - cent1[1]) + cent1[1];
114 cross_ref(2, 2) = ar2 / dc * (cent2[1] - cent1[1]) + cent2[1];
117 z1 = pz1 * r1 *
angle / pt1 + a01[2];
119 z2 = pz2 * r2 *
angle / pt2 + a02[2];
123 out[3] = (z1 + z2) / 2.;
124 return std::abs(z1 - z2);
128 diff = dc - (ar1 + ar2);
131 coef = (r1*r1 + dc*dc - r2*r2) / (dc * 2);
145 z1 = pz1 * r1 *
angle / pt1 + a01[2];
147 z2 = pz2 * r2 *
angle / pt2 + a02[2];
148 dz1 = std::abs(z2 - z1);
152 z1 = pz1 * r1 *
angle / pt1 + a01[2];
154 z2 = pz2 * r2 *
angle / pt2 + a02[2];
155 dz2 = std::abs(z2 - z1);
158 if(vRef && std::abs(dz1-dz2)<5.){
162 if(dir1<0) dz1+=1000.;
163 if(dir2<0) dz2+=1000.;
180 cross_ref(1, 1) = (ar1 * cent2[0] + ar2 * cent1[0]) / (ar1 + ar2);
181 cross_ref(2, 1) = (ar1 * cent2[1] + ar2 * cent1[1]) / (ar1 + ar2);
185 d__1 = r1 * dc / (ar1 + ar2);
186 angle = vkvang_(cross, cent1, &d__1, &xd1, &yd1);
187 z1 = pz1 * r1 *
angle / pt1 + a01[2];
188 d__1 = r2 * dc / (ar1 + ar2);
189 angle = vkvang_(cross, cent2, &d__1, &xd2, &yd2);
190 z2 = pz2 * r2 *
angle / pt2 + a02[2];
191 out[3] = (z1 + z2) / 2.;
192 bestZdiff = std::abs(z1 - z2);