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-2023 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 mat4s m
= glms_mat4_identity();
41 CGLM_ALIGN_MAT vec3s pivot
= {{pivot_v
->data
[0], pivot_v
->data
[1], pivot_v
->data
[2]}};
42 float angle
= self
->_value
;
43 CGLM_ALIGN_MAT vec3s axis
= {{axis_v
->data
[0], axis_v
->data
[1], axis_v
->data
[2]}};
45 r
= glms_rotate_atm(m
, pivot
, angle
, axis
);
47 of(Translation
, v_v
) {
48 CGLM_ALIGN_MAT vec3s v
= {{v_v
->data
[0], v_v
->data
[1], v_v
->data
[2]}};
49 v
= glms_vec3_scale(v
, self
->_value
);
52 glms_vec3_print(v
, stdout
);
53 hkl_vector_fprintf(stdout
, v_v
);
54 fprintf(stdout
, "\nvalue: %g", self
->_value
);
56 r
= glms_translate_make(v
);
64 mat4s
hkl_binoculars_holder_transformation_get(const HklHolder
*self
)
66 CGLM_ALIGN_MAT mat4s r
= GLMS_MAT4_IDENTITY_INIT
;
69 /* for each axis from the end apply the transformation to the vector */
70 for(i
=0;i
<self
->config
->len
;i
++){
71 HklParameter
*p
= darray_item(self
->geometry
->axes
, self
->config
->idx
[i
]);
73 r
= glms_mat4_mul(r
, hkl_binoculars_parameter_transformation_get(p
));