~ubuntu-branches/ubuntu/utopic/vtk6/utopic

« back to all changes in this revision

Viewing changes to ThirdParty/libproj4/vtklibproj4/proj_psi.c

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-01-07 21:26:32 UTC
  • Revision ID: package-import@ubuntu.com-20140107212632-vzwzmu3oyc3obmsg
Tags: upstream-6.0.0
ImportĀ upstreamĀ versionĀ 6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
** libproj -- library of cartographic projections
 
3
**
 
4
** Copyright (c) 2006   Gerald I. Evenden
 
5
*/
 
6
static const char
 
7
LIBPROJ_ID[] = "Id";
 
8
/*
 
9
** Permission is hereby granted, free of charge, to any person obtaining
 
10
** a copy of this software and associated documentation files (the
 
11
** "Software"), to deal in the Software without restriction, including
 
12
** without limitation the rights to use, copy, modify, merge, publish,
 
13
** distribute, sublicense, and/or sell copies of the Software, and to
 
14
** permit persons to whom the Software is furnished to do so, subject to
 
15
** the following conditions:
 
16
**
 
17
** The above copyright notice and this permission notice shall be
 
18
** included in all copies or substantial portions of the Software.
 
19
**
 
20
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
21
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
22
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
23
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 
24
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
25
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
26
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
*/
 
28
#include  <lib_proj.h>
 
29
#define MAX_ITER 11
 
30
#define EPS 1e-14
 
31
 
 
32
  double /* isometric latitude */
 
33
proj_psi(double phi, double sphi, double e) {
 
34
  double esp = e * sphi;
 
35
 
 
36
  return log(tan(FORTPI + 0.5 * phi) * pow((1. - esp)/(1. + esp), 0.5 * e));
 
37
}
 
38
  double /* inverse isometric latitude */
 
39
proj_apsi(double psi, double e) {
 
40
  double esp, phi, phi0, he = e * 0.5, exp_psi = exp(psi);
 
41
  int i = MAX_ITER;
 
42
 
 
43
  phi = 0.;
 
44
  phi0 = 2. * atan(exp_psi) - HALFPI;
 
45
  while (--i) {
 
46
    esp = e * sin(phi0);
 
47
    phi = 2. * atan(pow((1. + esp)/(1. - esp), he) * exp_psi) - HALFPI;
 
48
    phi0 = phi;
 
49
  } while ((fabs(phi0 - phi) > EPS) && --i);
 
50
  // if (!i) runaway
 
51
  return phi;
 
52
}
 
53
/*
 
54
** Log: proj_psi.c
 
55
** Revision 1.2  2008-11-14 16:56:33  jeff
 
56
** COMP: Fixing more libproj warnings.
 
57
**
 
58
** Revision 1.1  2008-11-07 16:41:15  jeff
 
59
** ENH: Adding a 2D geoview. Adding the geographic projection library libproj4
 
60
** to Utilities. Updating the architecture of the geospatial views. All
 
61
** multi-resolution sources are now subclasses of vtkGeoSource. Each source
 
62
** has its own worker thread for fetching refined images or geometry.
 
63
** On the 3D side, vtkGeoGlobeSource is an appropriate source for vtkGeoTerrain,
 
64
** and vtkGeoAlignedImageSource is an appropriate source for
 
65
** vtkGeoAlignedImageRepresentation. On the 2D side, vtkGeoProjectionSource is an
 
66
** appropriate source for vtkGeoTerrain2D, and the image source is the same.
 
67
**
 
68
** Revision 3.1  2006/06/19 01:00:26  gie
 
69
** Initial
 
70
**
 
71
*/