[hkl] add hkl_geometry_[sample/detector]_rotation_get
[hkl.git] / tests / hkl-pseudoaxis-zaxis-t.c
blob2ab75401d288c6c1cd04d40562fa21af1f1ac1ee
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-2016 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 "hkl.h"
23 #include <tap/basic.h>
24 #include <tap/hkl-tap.h>
26 static void solution(void)
28 int res = TRUE;
29 HklEngineList *engines;
30 HklEngine *engine;
31 const HklFactory *factory;
32 HklGeometry *geometry;
33 HklGeometryList *geometries;
34 HklDetector *detector;
35 HklSample *sample;
36 HklLattice *lattice;
37 static double hkl[] = {1, 1, 0};
38 HklMatrix *U;
40 /* get the geometry and set the source */
41 factory = hkl_factory_get_by_name("ZAXIS", NULL);
42 geometry = hkl_factory_create_new_geometry(factory);
43 res &= DIAG(hkl_geometry_wavelength_set(geometry, 0.842, HKL_UNIT_DEFAULT, NULL));
45 /* set up the sample */
46 sample = hkl_sample_new("test");
47 lattice = hkl_lattice_new(5.432, 5.432, 5.432,
48 90 * HKL_DEGTORAD,
49 90 * HKL_DEGTORAD,
50 90 * HKL_DEGTORAD,
51 NULL);
52 hkl_sample_lattice_set(sample, lattice);
53 U = hkl_matrix_new_euler(-90*HKL_DEGTORAD, 0, 0);
54 hkl_sample_U_set(sample, U, NULL);
55 hkl_lattice_free(lattice);
56 hkl_matrix_free(U);
58 /* use a 0D detector */
59 detector = hkl_detector_factory_new(HKL_DETECTOR_TYPE_0D);
61 /* select the hkl pseudo axis */
62 engines = hkl_factory_create_new_engine_list(factory);
63 hkl_engine_list_init(engines, geometry, detector, sample);
64 engine = hkl_engine_list_engine_get_by_name(engines, "hkl", NULL);
66 /* the init part must succed */
67 res &= DIAG(hkl_geometry_set_values_v(geometry, HKL_UNIT_USER, NULL, 1., 0., 0., 0.));
69 /* compute the 1 1 0 */
70 geometries = hkl_engine_pseudo_axis_values_set(engine, hkl, ARRAY_SIZE(hkl),
71 HKL_UNIT_DEFAULT, NULL);
72 if (geometries){
73 const HklGeometryListItem *item;
75 HKL_GEOMETRY_LIST_FOREACH(item, geometries){
76 hkl_geometry_set(geometry,
77 hkl_geometry_list_item_geometry_get(item));
78 res &= DIAG(check_pseudoaxes(engine, hkl, 3));
80 hkl_geometry_list_free(geometries);
81 }else
82 res = FALSE;
83 if(!res)
84 hkl_engine_fprintf(stdout, engine);
86 hkl_engine_list_free(engines);
87 hkl_detector_free(detector);
88 hkl_sample_free(sample);
89 hkl_geometry_free(geometry);
91 ok(res == TRUE, "solution");
94 int main(void)
96 plan(1);
98 solution();
100 return 0;