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-2024 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>
25 #include "hkl-binoculars-private.h"
27 mat4s
hkl_binoculars_parameter_transformation_get(const HklParameter
*self
)
29 CGLM_ALIGN_MAT mat4s r
= GLMS_MAT4_IDENTITY_INIT
;
30 HklParameterType type
= hkl_parameter_type_get(self
);
34 of(Rotation
, axis_v
) {
35 CGLM_ALIGN_MAT vec3s axis
= {{axis_v
->data
[0], axis_v
->data
[1], axis_v
->data
[2]}};
37 r
= glms_rotate_make(self
->_value
, axis
);
39 of(RotationWithOrigin
, axis_v
, pivot_v
) {
40 CGLM_ALIGN_MAT vec3s pivot
= {{pivot_v
->data
[0], pivot_v
->data
[1], pivot_v
->data
[2]}};
41 float angle
= self
->_value
;
42 CGLM_ALIGN_MAT vec3s axis
= {{axis_v
->data
[0], axis_v
->data
[1], axis_v
->data
[2]}};
44 #if (CGLM_VERSION_MAJOR <= 0 && CGLM_VERSION_MINOR <= 9 && CGLM_VERSION_PATH < 1)
45 CGLM_ALIGN_MAT mat4s m
= glms_mat4_identity();
46 r
= glms_rotate_atm(m
, pivot
, angle
, axis
);
48 r
= glms_rotate_atm(pivot
, angle
, axis
);
51 of(Translation
, v_v
) {
52 CGLM_ALIGN_MAT vec3s v
= {{v_v
->data
[0], v_v
->data
[1], v_v
->data
[2]}};
53 v
= glms_vec3_scale(v
, self
->_value
);
56 glms_vec3_print(v
, stdout
);
57 hkl_vector_fprintf(stdout
, v_v
);
58 fprintf(stdout
, "\nvalue: %g", self
->_value
);
60 r
= glms_translate_make(v
);
68 mat4s
hkl_binoculars_holder_transformation_get(const HklHolder
*self
)
70 CGLM_ALIGN_MAT mat4s r
= GLMS_MAT4_IDENTITY_INIT
;
73 /* for each axis from the end apply the transformation to the vector */
74 for(i
=0;i
<self
->config
->len
;i
++){
75 HklParameter
*p
= darray_item(self
->geometry
->axes
, self
->config
->idx
[i
]);
77 r
= glms_mat4_mul(r
, hkl_binoculars_parameter_transformation_get(p
));