ACT-CV - Machine Vision for Cognitive Modeling
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
general
linien
linien.cpp
Go to the documentation of this file.
1
// -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; coding: iso-8859-1; -*-
2
3
/*
4
ACT-CV - Machine Vision for Cognitive Modeling
5
Copyright (c) 2008 Marc Halbruegge
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
28
#include <iostream>
29
using namespace
std;
30
31
#include "
linien.h
"
32
33
#define _USE_MATH_DEFINES
34
#include <cmath>
35
36
#ifndef _PI
37
# ifdef M_PI
38
# define _PI M_PI
39
# else
40
# define _PI 3.1415926536
41
# ifndef M_PI
42
# define M_PI 3.1415926536
43
# endif
44
# endif
45
#endif
46
47
48
ostream&
operator <<
(ostream &out,
const
Linie
&linie) {
49
//noch normieren für die Ausgabe:
50
double
l,r,o,u;
51
52
if
(linie.
GetLinks
()==linie.
GetRechts
()) {
53
l=r=linie.
GetRechts
();
54
if
(linie.
GetOben
() > linie.
GetUnten
()) {
55
o=linie.
GetOben
(); u=linie.
GetUnten
();
56
}
else
{
57
u=linie.
GetOben
(); o=linie.
GetUnten
();
58
}
59
}
else
{
60
if
(linie.
GetRechts
() > linie.
GetLinks
()) {
61
l=linie.
GetLinks
(); o=linie.
GetOben
();
62
r=linie.
GetRechts
(); u=linie.
GetUnten
();
63
}
else
{
64
r=linie.
GetLinks
(); u=linie.
GetOben
();
65
l=linie.
GetRechts
(); o=linie.
GetUnten
();
66
}
67
}
68
69
out << l <<
" "
<< o <<
" "
70
<< r <<
" "
<< u;
71
72
return
out;
73
}
74
75
// difference of two angles in [-pi/2;pi/2]
76
double
GetWinkelDiff
(
double
w1,
double
w2) {
77
double
result=w2-w1;
78
while
(result < -
M_PI
/2) result+=
M_PI
;
79
while
(result >
M_PI
/2) result-=
M_PI
;
80
return
result;
81
}
82
ACT-CV - Machine Vision for Cognitive Modeling
© 2015
Marc Halbruegge
(actcvlibrary@googlemail.com)