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

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
dms.h
Go to the documentation of this file.
1 /***************************************************************************
2  dms.h - K Desktop Planetarium
3  -------------------
4  begin : Sun Feb 11 2001
5  copyright : (C) 2001 by Jason Harris
6  email : jharris@30doradus.org
7  ***************************************************************************/
8 
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  ***************************************************************************/
17 
18 #ifndef DMS_H_
19 #define DMS_H_
20 
21 #include <kdebug.h>
22 
23 #include <QString>
24 
25 #include <cmath>
26 #include "nan.h"
27 
42 class dms {
43 public:
45  dms() : D( NaN::d ) {}
46 
53  explicit dms( const int &d, const int &m=0, const int &s=0, const int &ms=0 ) { setD( d, m, s, ms ); }
54 
60  explicit dms( const double &x ) : D(x) {}
61 
75  explicit dms( const QString &s, bool isDeg=true ) { setFromString( s, isDeg ); }
76 
79  inline int degree() const { return int( D ) ; }
80 
84  int arcmin() const;
85 
89  int arcsec() const;
90 
94  int marcsec() const;
95 
98  inline const double& Degrees() const { return D; }
99 
104  inline int hour() const { return int( reduce().Degrees()/15.0 ); }
105 
109  int minute() const;
110 
114  int second() const;
115 
119  int msecond() const;
120 
125  inline double Hours() const { return reduce().Degrees()/15.0; }
126 
130  void setD( const double &x ) { D = x; }
131 
146  void setD( const int &d, const int &m, const int &s, const int &ms=0 );
147 
155  void setH( const double &x );
156 
169  void setH( const int &h, const int &m, const int &s, const int &ms=0 );
170 
179  bool setFromString( const QString &s, bool isDeg=true );
180 
190  inline void SinCos( double &s, double &c ) const;
191 
197  double sin() const { return ::sin(D*DegToRad); }
198 
204  double cos() const { return ::cos(D*DegToRad); }
205 
209  double radians() const { return D*DegToRad; }
210 
217  void setRadians( const double &a );
218 
222  const dms reduce() const;
223 
227  const QString toDMSString(const bool forceSign = false) const;
228 
232  const QString toHMSString() const;
233 
237  static const double PI;
238 
242  static const double DegToRad;
243 
258  static dms fromString(const QString & s, bool deg);
259 
260  dms operator - () { return dms(-D); }
261 private:
262  double D;
263 
264  friend dms operator+(dms, dms);
265  friend dms operator-(dms, dms);
266 };
267 
269 inline dms operator + (dms a, dms b) {
270  return dms( a.D + b.D);
271 }
272 
274 inline dms operator - (dms a, dms b) {
275  return dms( a.D - b.D);
276 }
277 
278 // Inline sincos
279 inline void dms::SinCos(double& s, double& c) const {
280 #ifdef __GLIBC__
281 #if ( __GLIBC__ >= 2 && __GLIBC_MINOR__ >=1 && !defined(__UCLIBC__))
282  //GNU version
283  sincos( radians(), &s, &c );
284 #else
285  //For older GLIBC versions
286  s = ::sin( radians() );
287  c = ::cos( radians() );
288 #endif
289 #else
290  //ANSI-compliant version
291  s = ::sin( radians() );
292  c = ::cos( radians() );
293 #endif
294 }
295 
297 inline bool operator == (const dms& a1, const dms& a2) { return a1.Degrees() == a2.Degrees(); }
298 
299 #endif
dms::hour
int hour() const
Definition: dms.h:104
operator+
Add two angles dms operator+(dms a, dms b)
Definition: dms.h:269
dms::dms
dms(const QString &s, bool isDeg=true)
Construct an angle from a string representation.
Definition: dms.h:75
nan.h
dms::minute
int minute() const
Definition: dms.cpp:174
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
dms::degree
int degree() const
Definition: dms.h:79
dms::dms
dms()
Default constructor.
Definition: dms.h:45
dms::second
int second() const
Definition: dms.cpp:182
dms::dms
dms(const double &x)
Construct an angle from a double value.
Definition: dms.h:60
operator-
Subtract angles dms operator-(dms a, dms b)
Definition: dms.h:274
dms::dms
dms(const int &d, const int &m=0, const int &s=0, const int &ms=0)
Set the floating-point value of the angle according to the four integer arguments.
Definition: dms.h:53
dms
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:42
dms::Hours
double Hours() const
Definition: dms.h:125
dms::marcsec
int marcsec() const
Definition: dms.cpp:165
NaN::d
const double d
Definition: nan.h:35
PI
#define PI
Definition: satellite.cpp:43
dms::msecond
int msecond() const
Definition: dms.cpp:190
dms::arcsec
int arcsec() const
Definition: dms.cpp:156
dms::setD
void setD(const double &x)
Sets floating-point value of angle, in degrees.
Definition: dms.h:130
operator==
bool operator==(const dms &a1, const dms &a2)
Overloaded equality operator.
Definition: dms.h:297
dms::arcmin
int arcmin() const
Definition: dms.cpp:148
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

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