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 <stdio.h> // for fprintf, NULL, FILE
23 #include <stdlib.h> // for free
24 #include "hkl-detector-private.h" // for _HklDetector
25 #include "hkl-geometry-private.h" // for HklHolder, _HklGeometry, etc
26 #include "hkl-macros-private.h" // for HKL_MALLOC
27 #include "hkl-source-private.h" // for HklSource
28 #include "hkl-vector-private.h" // for hkl_vector_init, etc
29 #include "hkl.h" // for HklDetector, HklGeometry, etc
30 #include "hkl/ccan/darray/darray.h" // for darray_item
33 * hkl_detector_new: (skip)
35 * Create a new default #HklDetector
39 HklDetector
*hkl_detector_new(void)
41 HklDetector
*self
= NULL
;
43 self
= HKL_MALLOC(HklDetector
);
52 * hkl_detector_new_copy: (skip)
53 * @src: the detector to copy
55 * the copy constructor
59 HklDetector
*hkl_detector_new_copy(const HklDetector
*src
)
63 self
= HKL_MALLOC(HklDetector
);
71 * hkl_detector_free: (skip)
76 void hkl_detector_free(HklDetector
*self
)
82 * hkl_detector_attach_to_holder: (skip)
86 * attach the #HklDetector to an #HklHolder
88 void hkl_detector_attach_to_holder(HklDetector
*self
, HklHolder
const *holder
)
90 self
->holder
= holder
;
94 * hkl_detector_compute_kf: (skip)
96 * @g: (in): the diffractometer #HklGeometry use to compute kf.
97 * @kf: (out caller-allocates): the #HklVector fill with the kf coordinates.
99 * Compute the kf vector of the #HklDetector
101 * Returns: HKL_SUCCESS if everythongs goes fine. HKL_FAIL otherwise.
103 int hkl_detector_compute_kf(HklDetector
const *self
, HklGeometry
*g
,
108 hkl_geometry_update(g
);
110 holder
= darray_item(g
->holders
, self
->idx
);
112 hkl_vector_init(kf
, HKL_TAU
/ g
->source
.wave_length
, 0, 0);
113 hkl_vector_rotated_quaternion(kf
, &holder
->q
);
120 * hkl_detector_fprintf: (skip)
124 * print to a FILE the detector members
126 void hkl_detector_fprintf(FILE *f
, const HklDetector
*self
)
128 fprintf(f
, "detector->idx: %d\n", self
->idx
);
129 fprintf(f
, "detector->holder: %p\n", self
->holder
);