SFF++ library: reading and writing SFF from C++

◆ offset()

double sff::offset ( const SRCE srce,
const INFO info,
const double &  radius 
)

return offset in meters

Definition at line 45 of file offset.cc.

References sff::SRCE::cs, sff::INFO::cs, CS_cartesian, CS_spherical, sff::SRCE::cx, sff::INFO::cx, sff::SRCE::cy, sff::INFO::cy, SFF_abort, and SFF_assert.

Referenced by offsetdeg().

47  {
48  double retval;
49  SFF_assert((srce.cs == info.cs),
50  "ERROR (offset): inconsistent coordinate systems!");
51  if (srce.cs == CS_spherical)
52  {
53  const double convfac=0.017453293;
54  double rtet=(90.-info.cx)*convfac;
55  double stet=(90.-srce.cx)*convfac;
56  double rphi=info.cy*convfac;
57  double sphi=srce.cy*convfac;
58  double cosepi=cos(stet)*cos(rtet)+sin(stet)*sin(rtet)*cos(sphi-rphi);
59  retval=acos(cosepi)*radius*1.e3;
60  }
61  else if (srce.cs == CS_cartesian)
62  {
63  double dx=srce.cx-info.cx;
64  double dy=srce.cy-info.cy;
65  retval=sqrt(dx*dx+dy*dy);
66  }
67  else
68  {
69  SFF_abort("ERROR (offset): unknown coordinate system!");
70  }
71  return(retval);
72  } // double offset(const SRCE& srce, const INFO& info;
#define SFF_assert(C, M)
check condition
Definition: sffxx.h:82
#define SFF_abort(M)
abort by throwing an exception
Definition: sffxx.h:91
Here is the caller graph for this function: