2 #include <gsl/gsl_sf_trig.h>
3 #include <hkl/hkl-pseudoaxis.h>
5 /********************************/
6 /* common methode use by getter */
7 /********************************/
9 int RUBh_minus_Q(double const x
[], void *params
, double f
[])
13 HklPseudoAxisEngine
*engine
;
14 HklPseudoAxis
*H
, *K
, *L
;
19 H
= &engine
->pseudoAxes
[0];
20 K
= &engine
->pseudoAxes
[1];
21 L
= &engine
->pseudoAxes
[2];
23 // update the workspace from x;
24 for(i
=0; i
<engine
->axes_len
; ++i
) {
25 HklAxis
*axis
= engine
->axes
[i
];
26 axis
->config
.value
= x
[i
];
27 axis
->config
.dirty
= 1;
29 hkl_geometry_update(engine
->geometry
);
31 hkl_vector_init(&Hkl
, H
->config
.value
, K
->config
.value
,
35 // for now the 0 holder is the sample holder.
36 holder
= &engine
->geometry
->holders
[0];
37 hkl_matrix_times_vector(&engine
->sample
->UB
, &Hkl
);
38 hkl_vector_rotated_quaternion(&Hkl
, &holder
->q
);
41 hkl_source_compute_ki(&engine
->geometry
->source
, &ki
);
42 hkl_detector_compute_kf(engine
->detector
, engine
->geometry
, &dQ
);
43 hkl_vector_minus_vector(&dQ
, &ki
);
45 hkl_vector_minus_vector(&dQ
, &Hkl
);
54 int hkl_pseudo_axis_engine_getter_func_hkl(HklPseudoAxisEngine
*self
,
55 HklGeometry
*geometry
, HklDetector
const *detector
,
56 HklSample
const *sample
)
62 // update the geometry internals
63 hkl_geometry_update(geometry
);
66 // for now the 0 holder is the sample holder.
67 holder
= &geometry
->holders
[0];
68 hkl_quaternion_to_smatrix(&holder
->q
, &RUB
);
69 hkl_matrix_times_smatrix(&RUB
, &sample
->UB
);
72 hkl_source_compute_ki(&geometry
->source
, &ki
);
73 hkl_detector_compute_kf(detector
, geometry
, &Q
);
74 hkl_vector_minus_vector(&Q
, &ki
);
76 hkl_matrix_solve(&RUB
, &hkl
, &Q
);
78 // update the pseudoAxes current and consign parts
79 self
->pseudoAxes
[0].config
.value
= hkl
.data
[0];
80 self
->pseudoAxes
[1].config
.value
= hkl
.data
[1];
81 self
->pseudoAxes
[2].config
.value
= hkl
.data
[2];