moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / ksutils.cpp
blobb8db47f6134bfd969802a00ea2455fb6397edc21
1 /***************************************************************************
2 ksutils.cpp - K Desktop Planetarium
3 -------------------
4 begin : Mon Jan 7 10:48:09 EST 2002
5 copyright : (C) 2002 by Mark Hollomon
6 email : mhh@mindspring.com
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include <kstandarddirs.h>
19 #include <qfile.h>
20 #include "ksutils.h"
22 bool KSUtils::openDataFile( QFile &file, const QString &s ) {
23 bool result;
24 QString FileName = locate( "appdata", s );
26 if ( !FileName.isNull() ) {
27 file.setName( FileName );
28 if ( !file.open( IO_ReadOnly ) ) {
29 result = false;
30 } else {
31 result = true;
33 } else {
34 result = false;
37 return result;
40 long double KSUtils::lagrangeInterpolation( const long double x[], const long double v[], int n, long double xval) {
41 long double value = 0;
42 for (int i=1; i<n; ++i) {
43 long double c = 1.0;
44 for (int j = 1; j<n;++j)
45 if (i != j)
46 c *= (xval - x[j]) / (x[i] - x[j]);
47 value += c *v[i];
50 return value;