Gnomonic.java
Go to the documentation of this file.
1 
8 package net.sf.geographiclib;
9 
133 public class Gnomonic {
134  private static final double eps_ = 0.01 * Math.sqrt(GeoMath.epsilon);
135  private static final int numit_ = 10;
136  private Geodesic _earth;
137  private double _a, _f;
138 
145  public Gnomonic(Geodesic earth) {
146  _earth = earth;
147  _a = _earth.MajorRadius();
148  _f = _earth.Flattening();
149  }
150 
173  public GnomonicData Forward(double lat0, double lon0, double lat, double lon)
174  {
175  GeodesicData inv =
179  GnomonicData fwd =
180  new GnomonicData(lat0, lon0, lat, lon, Double.NaN, Double.NaN,
181  inv.azi2, inv.M12);
182 
183  if (inv.M12 > 0) {
184  double rho = inv.m12 / inv.M12;
185  Pair p = GeoMath.sincosd(inv.azi1);
186  fwd.x = rho * p.first;
187  fwd.y = rho * p.second;
188  }
189 
190  return fwd;
191  }
192 
217  public GnomonicData Reverse(double lat0, double lon0, double x, double y) {
218  GnomonicData rev =
219  new GnomonicData(lat0, lon0, Double.NaN, Double.NaN, x, y, Double.NaN,
220  Double.NaN);
221 
222  double azi0 = GeoMath.atan2d(x, y);
223  double rho = Math.hypot(x, y);
224  double s = _a * Math.atan(rho / _a);
225  boolean little = rho <= _a;
226 
227  if (!little)
228  rho = 1 / rho;
229 
230  GeodesicLine line =
235 
236  int count = numit_, trip = 0;
237  GeodesicData pos = null;
238 
239  while (count-- > 0) {
240  pos =
245 
246  if (trip > 0)
247  break;
248 
249  double ds =
250  little ? ((pos.m12 / pos.M12) - rho) * pos.M12 * pos.M12
251  : (rho - (pos.M12 / pos.m12)) * pos.m12 * pos.m12;
252  s -= ds;
253 
254  if (Math.abs(ds) <= eps_ * _a)
255  trip++;
256  }
257 
258  if (trip == 0)
259  return rev;
260 
261  rev.lat = pos.lat2;
262  rev.lon = pos.lon2;
263  rev.azi = pos.azi2;
264  rev.rk = pos.M12;
265 
266  return rev;
267  }
268 
273  public double MajorRadius() { return _a; }
274 
279  public double Flattening() { return _f; }
280 }
net.sf.geographiclib.GeodesicData.M12
double M12
Definition: GeodesicData.java:62
net.sf.geographiclib.GeodesicMask.GEODESICSCALE
static final int GEODESICSCALE
Definition: GeodesicMask.java:75
net.sf.geographiclib.Gnomonic._earth
Geodesic _earth
Definition: Gnomonic.java:136
net.sf.geographiclib.Geodesic.Line
GeodesicLine Line(double lat1, double lon1, double azi1)
Definition: Geodesic.java:1130
net.sf.geographiclib.Gnomonic.eps_
static final double eps_
Definition: Gnomonic.java:134
net.sf.geographiclib.GeodesicMask.DISTANCE_IN
static final int DISTANCE_IN
Definition: GeodesicMask.java:67
net.sf.geographiclib.GeodesicLine
Definition: GeodesicLine.java:93
net.sf.geographiclib.Gnomonic.MajorRadius
double MajorRadius()
Definition: Gnomonic.java:273
s
RealScalar s
Definition: level1_cplx_impl.h:126
net.sf.geographiclib.GeodesicData.azi1
double azi1
Definition: GeodesicData.java:33
net.sf.geographiclib.Geodesic
Definition: Geodesic.java:202
net.sf.geographiclib.Geodesic.Inverse
GeodesicData Inverse(double lat1, double lon1, double lat2, double lon2)
Definition: Geodesic.java:615
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
net.sf.geographiclib.Gnomonic._a
double _a
Definition: Gnomonic.java:137
net.sf.geographiclib.GnomonicData.azi
double azi
Definition: GnomonicData.java:52
net.sf.geographiclib.GeodesicMask.LONGITUDE
static final int LONGITUDE
Definition: GeodesicMask.java:47
net.sf.geographiclib.GnomonicData.lon
double lon
Definition: GnomonicData.java:40
net.sf.geographiclib.GeoMath.sincosd
static Pair sincosd(double x)
Definition: GeoMath.java:240
net.sf.geographiclib.Gnomonic.Reverse
GnomonicData Reverse(double lat0, double lon0, double x, double y)
Definition: Gnomonic.java:217
net.sf.geographiclib.Geodesic.Flattening
double Flattening()
Definition: Geodesic.java:1194
net.sf.geographiclib.Gnomonic.Forward
GnomonicData Forward(double lat0, double lon0, double lat, double lon)
Definition: Gnomonic.java:173
example::lat0
const double lat0
Definition: testGPSFactor.cpp:41
net.sf.geographiclib.GeoMath.atan2d
static double atan2d(double y, double x)
Definition: GeoMath.java:274
example::lon0
const double lon0
Definition: testGPSFactor.cpp:41
net.sf.geographiclib.GnomonicData.y
double y
Definition: GnomonicData.java:48
net.sf.geographiclib.Gnomonic.numit_
static final int numit_
Definition: Gnomonic.java:135
net.sf.geographiclib.GeodesicMask.LATITUDE
static final int LATITUDE
Definition: GeodesicMask.java:43
net.sf.geographiclib.GeoMath.epsilon
static final double epsilon
Definition: GeoMath.java:26
net.sf.geographiclib.GeodesicMask
Definition: GeodesicMask.java:23
net.sf.geographiclib.Pair
Definition: Pair.java:15
net.sf.geographiclib.GeodesicData
Definition: GeodesicData.java:21
net.sf.geographiclib.GeodesicLine.Position
GeodesicData Position(double s12)
Definition: GeodesicLine.java:311
y
Scalar * y
Definition: level1_cplx_impl.h:124
net.sf.geographiclib.Gnomonic
Definition: Gnomonic.java:133
net.sf.geographiclib.GeodesicMask.AZIMUTH
static final int AZIMUTH
Definition: GeodesicMask.java:53
net.sf.geographiclib.GeoMath
Definition: GeoMath.java:16
net.sf.geographiclib.Gnomonic.Gnomonic
Gnomonic(Geodesic earth)
Definition: Gnomonic.java:145
net.sf.geographiclib.GeodesicData.azi2
double azi2
Definition: GeodesicData.java:45
net.sf.geographiclib.Geodesic.MajorRadius
double MajorRadius()
Definition: Geodesic.java:1188
net.sf.geographiclib.GeodesicMask.REDUCEDLENGTH
static final int REDUCEDLENGTH
Definition: GeodesicMask.java:71
p
float * p
Definition: Tutorial_Map_using.cpp:9
net.sf.geographiclib.GnomonicData.x
double x
Definition: GnomonicData.java:44
net.sf.geographiclib.GnomonicData
Definition: GnomonicData.java:24
lon
static const double lon
Definition: testGeographicLib.cpp:34
net.sf.geographiclib.GnomonicData.lat
double lat
Definition: GnomonicData.java:36
pos
Definition: example-NearestNeighbor.cpp:32
net.sf.geographiclib.GeodesicData.m12
double m12
Definition: GeodesicData.java:58
net.sf.geographiclib.GnomonicData.rk
double rk
Definition: GnomonicData.java:56
net.sf.geographiclib.Gnomonic.Flattening
double Flattening()
Definition: Gnomonic.java:279
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:40