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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
MarbleMath.h
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2007 Torsten Rahn <tackat@kde.org>
9 // Copyright 2007 Inge Wallin <ingwa@kde.org>
10 //
11 
12 #ifndef MARBLE_MARBLEMATH_H
13 #define MARBLE_MARBLEMATH_H
14 
15 #include <QtGlobal>
16 
17 #include <GeoDataCoordinates.h>
18 #include <math.h>
19 
20 
21 namespace
22 {
23  const qreal a1 = 1.0/6.0;
24  const qreal a2 = 1.0/24.0;
25  const qreal a3 = 61.0/5040;
26  const qreal a4 = 277.0/72576.0;
27  const qreal a5 = 50521.0/39916800.0;
28  const qreal a6 = 41581.0/95800320.0;
29  const qreal a7 = 199360981.0/1307674368000.0;
30  const qreal a8 = 228135437.0/4184557977600.0;
31  const qreal a9 = 2404879675441.0/121645100408832000.0;
32  const qreal a10 = 14814847529501.0/2043637686868377600.0;
33  const qreal a11 = 69348874393137901.0/25852016738884976640000.0;
34  const qreal a12 = 238685140977801337.0/238634000666630553600000.0;
35  const qreal a13 = 4087072509293123892361.0/10888869450418352160768000000.0;
36  const qreal a14 = 454540704683713199807.0/3209350995912777478963200000.0;
37  const qreal a15 = 441543893249023104553682821.0/8222838654177922817725562880000000.0;
38  const qreal a16 = 2088463430347521052196056349.0/102156677868375135241390522368000000.0;
39 }
40 
41 namespace Marble
42 {
43 
52 inline qreal distanceSphere( qreal lon1, qreal lat1, qreal lon2, qreal lat2 ) {
53 
54  qreal h1 = sin( 0.5 * ( lat2 - lat1 ) );
55  qreal h2 = sin( 0.5 * ( lon2 - lon1 ) );
56  qreal d = h1 * h1 + cos( lat1 ) * cos( lat2 ) * h2 * h2;
57 
58  return 2.0 * atan2( sqrt( d ), sqrt( 1.0 - d ) );
59 }
60 
61 
66 inline qreal distanceSphere( const GeoDataCoordinates& coords1, const GeoDataCoordinates& coords2 ) {
67 
68  qreal lon1, lat1;
69  coords1.geoCoordinates( lon1, lat1 );
70  qreal lon2, lat2;
71  coords2.geoCoordinates( lon2, lat2 );
72 
73  // FIXME: Take the altitude into account!
74 
75  return distanceSphere( lon1, lat1, lon2, lat2 );
76 }
77 
78 
85 inline qreal distanceSphereApprox( qreal lon1, qreal lat1, qreal lon2, qreal lat2 ) {
86  return acos( sin( lat1 ) * sin( lat2 ) + cos( lat1 ) * cos( lat2 ) * cos( lon1 - lon2 ) );
87 }
88 
89 
96 inline qreal gdInv( qreal x ) {
97  const qreal x2 = x * x;
98  return x
99  + x * x2 * ( a1
100  + x2 * ( a2 + x2 * ( a3 + x2 * ( a4 + x2 * ( a5
101  + x2 * ( a6 + x2 * ( a7 + x2 * ( a8 + x2 * ( a9
102  + x2 * ( a10 + x2 * ( a11 + x2 * ( a12 + x2 * ( a13
103  + x2 * ( a14 + x2 * ( a15 + x2 * ( a16 ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) );
104 }
105 
106 }
107 
114 inline qreal gd( qreal x ) {
115 
116  /*
117  const qreal x2 = x * x;
118  return x
119  - x * x2 * ( a1
120  - x2 * ( a2 - x2 * ( a3 - x2 * ( a4 - x2 * ( a5
121  - x2 * ( a6 - x2 * ( a7 - x2 * ( a8 - x2 * ( a9
122  - x2 * ( a10 - x2 * ( a11 - x2 * ( a12 - x2 * ( a13
123  - x2 * ( a14 - x2 * ( a15 - x2 * ( a16 ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) );
124  */
125 
126  return atan ( sinh ( x ) );
127 }
128 
129 #endif
GeoDataCoordinates.h
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
Marble::gdInv
qreal gdInv(qreal x)
This method is a fast Mac Laurin power series approximation of the.
Definition: MarbleMath.h:96
Marble::distanceSphere
qreal distanceSphere(qreal lon1, qreal lat1, qreal lon2, qreal lat2)
This method calculates the shortest distance between two points on a sphere.
Definition: MarbleMath.h:52
Marble::GeoDataCoordinates::geoCoordinates
void geoCoordinates(qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
use this function to get the longitude and latitude with one call - use the unit parameter to switch ...
Definition: GeoDataCoordinates.cpp:715
gd
qreal gd(qreal x)
This method is a fast Mac Laurin power series approximation of the Gudermannian.
Definition: MarbleMath.h:114
Marble::distanceSphereApprox
qreal distanceSphereApprox(qreal lon1, qreal lat1, qreal lon2, qreal lat2)
This method roughly calculates the shortest distance between two points on a sphere.
Definition: MarbleMath.h:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • 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
  • 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