prepare a rc1 and add a publish target to publish the documentation.
[hkl.git] / hkl / hkl-detector.c
blob73ec60b21426064856edcc2abfab1402af0fda32
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 <math.h>
23 #include <hkl/hkl-detector.h>
25 HklDetector *hkl_detector_new(void)
27 HklDetector *self = NULL;
29 self = HKL_MALLOC(HklDetector);
31 self->idx = 0;
32 self->holder = NULL;
34 return self;
37 HklDetector *hkl_detector_new_copy(HklDetector const *src)
39 HklDetector *self;
41 self = HKL_MALLOC(HklDetector);
43 self->idx = src->idx;
44 self->holder = src->holder;
46 return self;
49 void hkl_detector_free(HklDetector *self)
51 if(self)
52 free(self);
55 void hkl_detector_attach_to_holder(HklDetector *self, HklHolder const *holder)
57 if(!self || !holder)
58 return;
60 self->holder = holder;
63 int hkl_detector_compute_kf(HklDetector const *self, HklGeometry *g,
64 HklVector *kf)
66 HklHolder *holder;
68 hkl_geometry_update(g);
70 holder = &g->holders[self->idx];
71 if (holder) {
72 hkl_vector_init(kf, HKL_TAU / g->source.wave_length, 0, 0);
73 hkl_vector_rotated_quaternion(kf, &holder->q);
74 return HKL_SUCCESS;
75 } else
76 return HKL_FAIL;