Goose Management Model ODdox  1.02
misc.cpp
Go to the documentation of this file.
1 //
2 // misc.cpp
3 //
4 /*
5 *******************************************************************************************************
6 Copyright (c) 2011, Christopher John Topping, University of Aarhus
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without modification, are permitted provided
10 that the following conditions are met:
11 
12 Redistributions of source code must retain the above copyright notice, this list of conditions and the
13 following disclaimer.
14 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
15 the following disclaimer in the documentation and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
20 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 ********************************************************************************************************
26 */
27 
28 #define _CRT_SECURE_NO_DEPRECATE
29 
30 #include "string.h"
31 #include "ls.h"
32 #include "tole_declaration.h"
33 #include "map_cfg.h"
34 
35 extern CfgBool cfg_dumpvegjan;
39 
40 //------------------------------------------------------------------------------
42 int ALMaSS_MathFuncs::CalcDistPythagoras( int a_x, int a_y, int a_x1, int a_y1 ) {
43  int dx = a_x - a_x1;
44  int dy = a_y - a_y1;
45  int dist = (int)sqrt( (double)(dx*dx + dy*dy) );
46  return dist;
47 }
49 int ALMaSS_MathFuncs::CalcDistPythagorasApprox( int a_x, int a_y, int a_x1, int a_y1 ) {
53  int dx = abs( a_x - a_x1 );
54  int dy = abs( a_y - a_y1 );
55  dx++; //To avoid division by zero
56  dy++;
57  int dist;
58  if (dx>dy) {
59  dist = dx + (dy * dy) / (2 * dx);
60  }
61  else dist = dy + (dx * dx) / (2 * dy);
62  return dist;
63 }
64 
65 
CfgStr
String configurator entry class.
Definition: configurator.h:144
ls.h
cfg_dumpvegjunefile
CfgStr cfg_dumpvegjunefile
map_cfg.h
cfg_dumpvegjanfile
CfgStr cfg_dumpvegjanfile
CfgBool
Bool configurator entry class.
Definition: configurator.h:127
cfg_dumpvegjune
CfgBool cfg_dumpvegjune
cfg_dumpvegjan
CfgBool cfg_dumpvegjan
ALMaSS_MathFuncs::CalcDistPythagorasApprox
int CalcDistPythagorasApprox(int a_x, int a_y, int a_x1, int a_y1)
Calculate distance using the Pythagoras approximation.
Definition: misc.cpp:49
ALMaSS_MathFuncs::CalcDistPythagoras
int CalcDistPythagoras(int a_x, int a_y, int a_x1, int a_y1)
Calculate distance using Pythagoras.
Definition: misc.cpp:42
tole_declaration.h