fors_pattern-test.c

00001 /* $Id: fors_pattern-test.c,v 1.2 2007/09/07 11:29:49 jmlarsen Exp $
00002  *
00003  * This file is part of the FORS Library
00004  * Copyright (C) 2002-2006 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 /*
00022  * $Author: jmlarsen $
00023  * $Date: 2007/09/07 11:29:49 $
00024  * $Revision: 1.2 $
00025  * $Name: fors-4_8_6 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 #include <fors_pattern.h>
00033 #include <fors_point.h>
00034 #include <test.h>
00035 
00045 static void
00046 test_pattern(void)
00047 {
00048     fors_point *p1 = fors_point_new(1, 2);
00049     fors_point *p2 = fors_point_new(2, 2);
00050     fors_point *p3 = fors_point_new(3, 4);
00051     fors_point *p4 = fors_point_new(0.1, 0.2);
00052     fors_point *p5 = fors_point_new(0.2, 0.2);
00053     fors_point *p6 = fors_point_new(0.3, 0.4);
00054     double sigma = 0.001;
00055 
00056     fors_pattern *pat1 = fors_pattern_new(p1, p2, p3, sigma);
00057     fors_pattern *pat2 = fors_pattern_new(p4, p5, p6, sigma);
00058 
00059     test_abs( fors_pattern_get_scale(pat1, pat2),     10, 0.01 );
00060     test_abs( fors_pattern_get_scale(pat2, pat1), 1.0/10, 0.01 );
00061     test_abs( fors_pattern_get_angle(pat1, pat2), 0, 0.01 );
00062     test_abs( fors_pattern_get_angle(pat2, pat1), 0, 0.01 );
00063     
00064     test_abs( fors_pattern_distsq(pat1, pat2), 0, 0.001 );
00065     test_abs( fors_pattern_distsq(pat2, pat1), 0, 0.001 );
00066 
00067     fors_point_delete(&p1);
00068     fors_point_delete(&p2);
00069     fors_point_delete(&p3);
00070     fors_point_delete(&p4);
00071     fors_point_delete(&p5);
00072     fors_point_delete(&p6);
00073     fors_pattern_delete(&pat1);
00074     fors_pattern_delete(&pat2);
00075 
00076     return;
00077 }
00078 
00079 
00083 int main(void)
00084 {
00085     TEST_INIT;
00086 
00087     test_pattern();
00088 
00089     TEST_END;
00090 }
00091 

Generated on Fri Mar 4 09:46:00 2011 for FORS Pipeline Reference Manual by  doxygen 1.4.7