FORS Pipeline Reference Manual  4.12.5
fors_pattern-test.c
1 /* $Id: fors_pattern-test.c,v 1.2 2007-09-07 11:29:49 jmlarsen Exp $
2  *
3  * This file is part of the FORS Library
4  * Copyright (C) 2002-2006 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: jmlarsen $
23  * $Date: 2007-09-07 11:29:49 $
24  * $Revision: 1.2 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <fors_pattern.h>
33 #include <fors_point.h>
34 #include <test.h>
35 
45 static void
47 {
48  fors_point *p1 = fors_point_new(1, 2);
49  fors_point *p2 = fors_point_new(2, 2);
50  fors_point *p3 = fors_point_new(3, 4);
51  fors_point *p4 = fors_point_new(0.1, 0.2);
52  fors_point *p5 = fors_point_new(0.2, 0.2);
53  fors_point *p6 = fors_point_new(0.3, 0.4);
54  double sigma = 0.001;
55 
56  fors_pattern *pat1 = fors_pattern_new(p1, p2, p3, sigma);
57  fors_pattern *pat2 = fors_pattern_new(p4, p5, p6, sigma);
58 
59  test_abs( fors_pattern_get_scale(pat1, pat2), 10, 0.01 );
60  test_abs( fors_pattern_get_scale(pat2, pat1), 1.0/10, 0.01 );
61  test_abs( fors_pattern_get_angle(pat1, pat2), 0, 0.01 );
62  test_abs( fors_pattern_get_angle(pat2, pat1), 0, 0.01 );
63 
64  test_abs( fors_pattern_distsq(pat1, pat2), 0, 0.001 );
65  test_abs( fors_pattern_distsq(pat2, pat1), 0, 0.001 );
66 
67  fors_point_delete(&p1);
68  fors_point_delete(&p2);
69  fors_point_delete(&p3);
70  fors_point_delete(&p4);
71  fors_point_delete(&p5);
72  fors_point_delete(&p6);
73  fors_pattern_delete(&pat1);
74  fors_pattern_delete(&pat2);
75 
76  return;
77 }
78 
79 
83 int main(void)
84 {
85  TEST_INIT;
86 
87  test_pattern();
88 
89  TEST_END;
90 }
91 
static void test_pattern(void)
test
fors_point * fors_point_new(double x, double y)
Constructor.
Definition: fors_point.c:53
void fors_point_delete(fors_point **p)
Destructor.
Definition: fors_point.c:87
int main(void)
Test of QC module.