1 #ifndef __HKL_PSEUDOAXIS_K4CV_H__
2 #define __HKL_PSEUDOAXIS_K4CV_H__
4 #include <gsl/gsl_math.h>
5 #include <gsl/gsl_vector.h>
6 #include <gsl/gsl_sf_trig.h>
8 #include <hkl/hkl-pseudoaxis.h>
9 #include <hkl/hkl-pseudoaxis-common.h>
13 static int K4CV_bissector_f1(const gsl_vector
*x
, void *params
, gsl_vector
*f
)
15 double komega
, tth
, kappa
, omega
;
17 HklPseudoAxisEngine
*engine
;
18 double const *x_data
= gsl_vector_const_ptr(x
, 0);
19 double *f_data
= gsl_vector_ptr(f
, 0);
23 for(i
=0; i
<x
->size
;++i
)
24 if (gsl_isnan(x_data
[i
]))
27 RUBh_minus_Q(x_data
, params
, f_data
);
31 tth
= gsl_sf_angle_restrict_symm(x_data
[3]);
33 omega
= komega
+ atan(tan(kappa
/2.)*cos(50 * HKL_DEGTORAD
)) + M_PI_2
;
34 omega
= gsl_sf_angle_restrict_symm(omega
);
35 //f_data[3] = tth - 2 * fmod(omega,M_PI);
36 f_data
[3] = tth
- 2*omega
;
41 static int K4CV_bissector_f2(const gsl_vector
*x
, void *params
, gsl_vector
*f
)
43 double komega
, tth
, kappa
, omega
;
45 HklPseudoAxisEngine
*engine
;
46 double const *x_data
= gsl_vector_const_ptr(x
, 0);
47 double *f_data
= gsl_vector_ptr(f
, 0);
51 for(i
=0; i
<x
->size
;++i
)
52 if (gsl_isnan(x_data
[i
]))
55 RUBh_minus_Q(x_data
, params
, f_data
);
59 tth
= gsl_sf_angle_restrict_symm(x_data
[3]);
61 omega
= komega
+ atan(tan(kappa
/2.)*cos(50 * HKL_DEGTORAD
)) - M_PI_2
;
62 omega
= gsl_sf_angle_restrict_symm(omega
);
63 //f_data[3] = tth - 2 * fmod(omega,M_PI);
64 f_data
[3] = tth
- 2*omega
;
69 HklPseudoAxisEngine
*hkl_pseudoAxisEngine_new_K4CV_HKL(void)
71 HklPseudoAxisEngine
*self
;
72 HklPseudoAxisEngineFunc
*function
;
73 HklPseudoAxisEngineGetSet
*getset
;
75 self
= hkl_pseudoAxisEngine_new("hkl", 3, "h", "k", "l");
77 /* hkl get/set bissector */
78 getset
= hkl_pseudo_axis_engine_get_set_new(
80 hkl_pseudo_axis_engine_getter_func_hkl
,
83 4, "komega", "kappa", "kphi", "tth");
84 hkl_pseudoAxisEngine_add_get_set(self
, getset
);
87 function
= hkl_pseudo_axis_engine_func_new(
89 2, K4CV_bissector_f1
, K4CV_bissector_f2
,
91 4, "komega", "kappa", "kphi", "tth");
92 hkl_pseudoAxisEngine_add_function(self
, function
);
99 #endif /* __HKL_PSEUDOAXIS_E4CV_H__ */