• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
goniometry.cc
Go to the documentation of this file.
1 
22 #include "goniometry.h"
23 
24 #include <math.h>
25 
26 #include <qstringlist.h>
27 
28 #include <kdebug.h>
29 #include <klocale.h>
30 
31 #include <cmath>
32 
33 Goniometry::Goniometry()
34 {
35  mvalue = 0.0;
36  msys = Rad;
37 }
38 
39 Goniometry::Goniometry( double value, Goniometry::System system )
40 {
41  mvalue = value;
42  msys = system;
43 }
44 
45 Goniometry::~Goniometry()
46 {
47 }
48 
49 void Goniometry::setValue( double value )
50 {
51  mvalue = value;
52 }
53 
54 double Goniometry::value() const
55 {
56  return mvalue;
57 }
58 
59 void Goniometry::setSystem( Goniometry::System system )
60 {
61  msys = system;
62 }
63 
64 void Goniometry::convertTo( Goniometry::System system )
65 {
66  mvalue = convert( mvalue, msys, system );
67  msys = system;
68 }
69 
70 Goniometry::System Goniometry::system() const
71 {
72  return msys;
73 }
74 
75 double Goniometry::getValue( Goniometry::System system )
76 {
77  return convert( mvalue, msys, system );
78 }
79 
80 Goniometry& Goniometry::operator=( const Goniometry& g )
81 {
82  mvalue = g.value();
83  msys = g.system();
84  return *this;
85 }
86 
87 double Goniometry::convert( const double angle, const Goniometry::System from, const Goniometry::System to )
88 {
89  switch( from )
90  {
91  case Deg:
92  {
93  if ( to == Rad )
94  return angle * M_PI / 180;
95  if ( to == Grad )
96  return angle * 10 / 9;
97  break;
98  }
99  case Rad:
100  {
101  if ( to == Deg )
102  return angle * 180 / M_PI;
103  if ( to == Grad )
104  return angle * 200 / M_PI;
105  break;
106  }
107  case Grad:
108  {
109  if ( to == Deg )
110  return angle * 9 / 10;
111  if ( to == Rad )
112  return angle * M_PI / 200;
113  break;
114  }
115  }
116  return angle;
117 }
118 
119 QStringList Goniometry::systemList()
120 {
121  QStringList sl;
122  sl << i18nc( "Translators: Degrees", "Deg" );
123  sl << i18nc( "Translators: Radians", "Rad" );
124  sl << i18nc( "Translators: Gradians", "Grad" );
125  return sl;
126 }
127 
128 Goniometry::System Goniometry::intToSystem( const int index )
129 {
130  if( index == 0 )
131  return Deg;
132  else if( index == 1 )
133  return Rad;
134  else if( index == 2 )
135  return Grad;
136  kDebug() << "No goniometric system with index " << index;
137  return Rad;
138 }
Goniometry
Manage an angle and convert it from/to other goniometric systems.
Definition: goniometry.h:28
Goniometry::getValue
double getValue(Goniometry::System system)
Definition: goniometry.cc:75
Goniometry::Deg
Definition: goniometry.h:31
Goniometry::System
System
Definition: goniometry.h:31
Goniometry::setSystem
void setSystem(Goniometry::System system)
Set the system of the current angle to system, but it doesn't convert the value to the new system...
Definition: goniometry.cc:59
Goniometry::intToSystem
static Goniometry::System intToSystem(const int index)
Definition: goniometry.cc:128
Goniometry::Goniometry
Goniometry()
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: goniometry.cc:33
Goniometry::systemList
static QStringList systemList()
Get a list of the supported goniometric systems.
Definition: goniometry.cc:119
goniometry.h
Goniometry::Grad
Definition: goniometry.h:31
Goniometry::system
Goniometry::System system() const
Definition: goniometry.cc:70
Goniometry::operator=
Goniometry & operator=(const Goniometry &g)
Definition: goniometry.cc:80
Goniometry::convert
static double convert(const double angle, const Goniometry::System from, const Goniometry::System to)
The most useful method of this class: convert the specified angle from the system from to the system ...
Definition: goniometry.cc:87
Goniometry::~Goniometry
~Goniometry()
Definition: goniometry.cc:45
Goniometry::setValue
void setValue(double value)
Definition: goniometry.cc:49
Goniometry::Rad
Definition: goniometry.h:31
Goniometry::convertTo
void convertTo(Goniometry::System system)
Set the system of the current angle to system and convert the value to the new system using convert()...
Definition: goniometry.cc:64
Goniometry::value
double value() const
Definition: goniometry.cc:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal