* add the liststore to contain all the diffractometers
[hkl.git] / hkl / hkl-pseudoaxis-zaxis-hkl.c
blob1423d80b1e94e4b4bf0039c4035ce8519cfe92b0
1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2010 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
22 #include <gsl/gsl_math.h>
23 #include <gsl/gsl_vector.h>
25 #include <hkl/hkl-pseudoaxis-zaxis.h>
26 #include <hkl/hkl-pseudoaxis-common-hkl.h>
28 static int reflectivity(const gsl_vector *x, void *params, gsl_vector *f)
30 double mu, gamma;
31 double const *x_data = gsl_vector_const_ptr(x, 0);
32 double *f_data = gsl_vector_ptr(f, 0);
34 RUBh_minus_Q(x_data, params, f_data);
36 mu = x_data[0];
37 gamma = x_data[3];
39 f_data[3] = mu - gamma;
41 return GSL_SUCCESS;
44 /*************************/
45 /* ZAXIS PseudoAxeEngine */
46 /*************************/
48 HklPseudoAxisEngine *hkl_pseudo_axis_engine_zaxis_hkl_new(void)
50 HklPseudoAxisEngine *self;
51 HklPseudoAxisEngineMode *mode;
53 self = hkl_pseudo_axis_engine_hkl_new();
55 /* zaxis */
56 mode = hkl_pseudo_axis_engine_mode_new(
57 "zaxis",
58 NULL,
59 hkl_pseudo_axis_engine_mode_get_hkl_real,
60 hkl_pseudo_axis_engine_mode_set_real,
61 1, RUBh_minus_Q_func,
62 (size_t)0,
63 (size_t)3, "omega", "delta", "gamma");
64 hkl_pseudo_axis_engine_add_mode(self, mode);
66 /* reflectivity */
67 mode = hkl_pseudo_axis_engine_mode_new(
68 "reflectivity",
69 NULL,
70 hkl_pseudo_axis_engine_mode_get_hkl_real,
71 hkl_pseudo_axis_engine_mode_set_real,
72 1, reflectivity,
73 (size_t)0,
74 (size_t)4, "mu", "omega", "delta", "gamma");
75 hkl_pseudo_axis_engine_add_mode(self, mode);
77 hkl_pseudo_axis_engine_select_mode(self, 0);
79 return self;