2 This file is part of Kig, a KDE program for Interactive Geometry...
3 Copyright (C) 2004 Dominique Devriese <devriese@kde.org>
4 Copyright (C) 2004 Pino Toscano <toscano.pino@tiscali.it>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 #include "goniometry.h"
25 #include <qstringlist.h>
32 Goniometry::Goniometry()
38 Goniometry::Goniometry( double value
, Goniometry::System system
)
44 Goniometry::~Goniometry()
48 void Goniometry::setValue( double value
)
53 const double Goniometry::value() const
58 void Goniometry::setSystem( Goniometry::System system
)
63 void Goniometry::convertTo( Goniometry::System system
)
65 mvalue
= convert( mvalue
, msys
, system
);
69 const Goniometry::System
Goniometry::system() const
74 double Goniometry::getValue( Goniometry::System system
)
76 return convert( mvalue
, msys
, system
);
79 Goniometry
& Goniometry::operator=( const Goniometry
& g
)
86 double Goniometry::convert( const double angle
, const Goniometry::System from
, const Goniometry::System to
)
93 return angle
* M_PI
/ 180;
95 return angle
* 10 / 9;
101 return angle
* 180 / M_PI
;
103 return angle
* 200 / M_PI
;
109 return angle
* 9 / 10;
111 return angle
* M_PI
/ 200;
118 QStringList
Goniometry::systemList()
121 sl
<< i18n( "Translators: Degrees", "Deg" );
122 sl
<< i18n( "Translators: Radians", "Rad" );
123 sl
<< i18n( "Translators: Gradians", "Grad" );
127 Goniometry::System
Goniometry::intToSystem( const int index
)
131 else if( index
== 1 )
133 else if( index
== 2 )
135 kdDebug() << "No goniometric system with index " << index
<< endl
;