Initial Commit
[HECS.git] / Misc.cpp
blob162dc557f351cfe2211c6c8958d37383b9f06b8d
1 /***************************************************************************
2 * *
3 * Gains.cpp Copyright (C) 2008 by Jon Rumble *
4 * j.w.rumble@reading.ac.uk *
5 * *
6 * This file is part of HECS, *
7 * *
8 * HECS is free software: you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation, either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * HECS is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
21 ***************************************************************************/
23 #include "Misc.h"
25 double kWHtoGigaJoules(double val_in)
27 double val_out = 0.00;
29 return val_out = (val_in * 3600000) / 1000000000;
34 double lerp(const double& x1,
35 double& x2,
36 double& x3,
37 double& y1,
38 double& y3)
40 double y2 = 0.00;
42 y2= y1 + (x2 - x1) *(y3 - y1)/(x3 - x1);
43 return y2;
46 double calcWk(double area, double uValue)
48 double wK = 0.00;
49 return wK = area * uValue;
52 double sqFeettoSquareMetres(double sqFeetIn)
54 return sqFeetIn / 10.7639104;
57 /*QString sedbukGrade(int sedbukVal)
59 QString rating;
61 if (sedbuk >= 90)
62 return rating = "A";
64 if (sedbuk >= 86 && < 90 )
65 return rating = "A";
67 if (sedbuk >= 90)
68 return rating = "A";
70 if (sedbuk >= 90)
71 return rating = "A";
73 if (sedbuk >= 90)
74 return rating = "A";
76 }*/
78 //NB QStringList must be sorted or it won't work !!!
79 QStringList pruneDuplicates(QStringList strListIn)
82 QStringList prunedList;
83 QString curEntry,lastEntry = "";
84 for (int i = 0; i < strListIn.size(); ++i)
86 curEntry = strListIn.at(i);
88 if (curEntry == lastEntry)
89 continue;
90 else
91 prunedList << curEntry;
93 lastEntry = curEntry;
96 return prunedList;