1 // This file is part of Kig, a KDE program for Interactive Geometry...
2 // SPDX-FileCopyrightText: 2004 Dominique Devriese <devriese@kde.org>
3 // SPDX-FileCopyrightText: 2004 Pino Toscano <toscano.pino@tiscali.it>
4 
5 // SPDX-License-Identifier: GPL-2.0-or-later
6 
7 #ifndef KIG_MISC_GONIOMETRY_H
8 #define KIG_MISC_GONIOMETRY_H
9 
10 #include <QStringList>
11 
12 /**
13  * Manage an angle and convert it from/to other goniometric systems.
14  */
15 class Goniometry
16 {
17 public:
18   enum System { Deg, Rad, Grad };
19   Goniometry();
20   Goniometry( double value, Goniometry::System system );
21   ~Goniometry();
22   void setValue( double value );
23   double value() const;
24   /**
25    * Set the system of the current angle to \p system, but it doesn't
26    * convert the value to the new system.
27    *
28    * \see convertTo()
29    */
30   void setSystem( Goniometry::System system );
31   /**
32    * Set the system of the current angle to \p system and convert the
33    * value to the new system using \ref convert().
34    *
35    * \see setSystem()
36    */
37   void convertTo( Goniometry::System system );
38   Goniometry::System system() const;
39   double getValue( Goniometry::System system );
40   /**
41    * The most useful method of this class: convert the specified
42    * \p angle from the system \p from to the system \p to.
43    */
44   static double convert( const double angle, const Goniometry::System from, const Goniometry::System to );
45   /**
46    * Get a list of the supported goniometric systems.
47    */
48   static QStringList systemList();
49   static Goniometry::System intToSystem( const int index );
50 
51   Goniometry( const Goniometry &g ) = default;
52   Goniometry& operator= ( const Goniometry& g ) = default;
53 
54 private:
55   double mvalue;
56   typedef Goniometry::System goniosys;
57   goniosys msys;
58 };
59 
60 #endif
61