LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
lsst::ap::Point Struct Reference

A point on the unit sphere (sky), specified in spherical polar coordinates. More...

#include <Point.h>

Public Member Functions

 Point ()
 
 Point (double const ra, double const dec)
 
Pointperturb (lsst::afw::math::Random &rng, double const sigma)
 
Pointperturb (lsst::afw::math::Random &rng, double const sigma, double pa)
 
double distance (Point const &p) const
 

Static Public Member Functions

static Point const random (lsst::afw::math::Random &rng)
 
static Point const random (lsst::afw::math::Random &rng, double const decMin, double const decMax)
 
static Point const random (lsst::afw::math::Random &rng, double const raMin, double const raMax, double const decMin, double const decMax)
 

Public Attributes

double _ra
 
double _dec
 

Detailed Description

A point on the unit sphere (sky), specified in spherical polar coordinates.

The units of all angles (stored or passed to member functions) are degrees.

Definition at line 46 of file Point.h.

Constructor & Destructor Documentation

lsst::ap::Point::Point ( )
inline

Definition at line 51 of file Point.h.

51 : _ra(0.0), _dec(0.0) {}
double _dec
Definition: Point.h:49
double _ra
Definition: Point.h:48
lsst::ap::Point::Point ( double const  ra,
double const  dec 
)
inline

Definition at line 52 of file Point.h.

52 : _ra(ra), _dec(dec) {}
double _dec
Definition: Point.h:49
double _ra
Definition: Point.h:48

Member Function Documentation

double lsst::ap::Point::distance ( Point const &  p) const

Returns the angular distance to the given point (in degrees).

Definition at line 138 of file Point.cc.

138  {
139 
140  double sra = std::sin(afwGeom::degToRad(_ra));
141  double cra = std::cos(afwGeom::degToRad(_ra));
142  double sdec = std::sin(afwGeom::degToRad(_dec));
143  double cdec = std::cos(afwGeom::degToRad(_dec));
144 
145  double x = cra*cdec;
146  double y = sra*cdec;
147  double z = sdec;
148 
149  sra = std::sin(afwGeom::degToRad(p._ra));
150  cra = std::cos(afwGeom::degToRad(p._ra));
151  sdec = std::sin(afwGeom::degToRad(p._dec));
152  cdec = std::cos(afwGeom::degToRad(p._dec));
153 
154  x *= cra*cdec;
155  y *= sra*cdec;
156  z *= sdec;
157 
158  return afwGeom::radToDeg(std::acos(x + y + z));
159 }
int y
double radToDeg(long double angleInRadians)
Definition: RaDecStr.cc:61
int x
double _dec
Definition: Point.h:49
double degToRad(long double angleInDegrees)
Definition: RaDecStr.cc:67
double _ra
Definition: Point.h:48
lsst::ap::Point & lsst::ap::Point::perturb ( lsst::afw::math::Random rng,
double const  sigma 
)

Randomly perturbs the point such that the results are distributed according to a normal distribution centered on the original point and having a standard deviation of sigma degrees.

Definition at line 73 of file Point.cc.

73  {
74  return perturb(rng, sigma, rng.uniform()*360.0);
75 }
Point & perturb(lsst::afw::math::Random &rng, double const sigma)
Definition: Point.cc:73
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:42
lsst::ap::Point & lsst::ap::Point::perturb ( lsst::afw::math::Random rng,
double const  sigma,
double  pa 
)

Randomly perturbs the point in the direction given by the specified position angle so that the distance to the original point is normally distributed with a standard deviation of sigma degrees.

Definition at line 82 of file Point.cc.

82  {
83 
84  double sra = std::sin(afwGeom::degToRad(_ra));
85  double cra = std::cos(afwGeom::degToRad(_ra));
86  double sdec = std::sin(afwGeom::degToRad(_dec));
87  double cdec = std::cos(afwGeom::degToRad(_dec));
88 
89  // original position p
90  double x = cra*cdec;
91  double y = sra*cdec;
92  double z = sdec;
93 
94  double spa = std::sin(afwGeom::degToRad(pa));
95  double cpa = std::cos(afwGeom::degToRad(pa));
96 
97  // north vector tangential to p
98  double nx = - cra*sdec;
99  double ny = - sra*sdec;
100  double nz = cdec;
101 
102  // east vector tangential to p
103  double ex = - sra;
104  double ey = cra;
105  double ez = 0.0;
106 
107  // rotate north vector at V by minus position angle
108  double tx = spa*ex + cpa*nx;
109  double ty = spa*ey + cpa*ny;
110  double tz = spa*ez + cpa*nz;
111 
112  // perturb in this direction by a random angle that is normally
113  // distributed with a standard deviation of sigma degrees
114  double mag = afwGeom::degToRad(rng.gaussian()*sigma);
115  double smag = std::sin(mag);
116  double cmag = std::cos(mag);
117 
118  // obtain the perturbed position
119  x = x*cmag + tx*smag;
120  y = y*cmag + ty*smag;
121  z = z*cmag + tz*smag;
122  // finally, convert back to spherical coordinates (in degrees)
123  _ra = afwGeom::radToDeg(std::atan2(y, x));
124  if (_ra < 0.0) {
125  _ra += 360.0;
126  }
127  _dec = afwGeom::radToDeg(std::asin(z));
128  if (_dec <= -90.0) {
129  _dec = -90.0;
130  } else if (_dec >= 90.0) {
131  _dec = 90.0;
132  }
133  return *this;
134 }
int y
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:42
double radToDeg(long double angleInRadians)
Definition: RaDecStr.cc:61
int x
double _dec
Definition: Point.h:49
double degToRad(long double angleInDegrees)
Definition: RaDecStr.cc:67
double _ra
Definition: Point.h:48
lsst::ap::Point const lsst::ap::Point::random ( lsst::afw::math::Random rng)
static

Picks a point uniformly at random on the unit sphere.

Definition at line 163 of file Point.cc.

163  {
164  double z = rng.flat(-1.0, 1.0);
165  return Point(rng.flat(0.0, 360.0), afwGeom::radToDeg(std::asin(z)));
166 }
double flat(double const a, double const b)
Definition: Random.cc:358
double radToDeg(long double angleInRadians)
Definition: RaDecStr.cc:61
lsst::ap::Point const lsst::ap::Point::random ( lsst::afw::math::Random rng,
double const  decMin,
double const  decMax 
)
static

Picks a point uniformly at random in the specified dec band.

Definition at line 170 of file Point.cc.

174  {
175  return Point(rng.flat(0.0, 360.0), randomDec(rng, decMin, decMax));
176 }
double flat(double const a, double const b)
Definition: Random.cc:358
lsst::ap::Point const lsst::ap::Point::random ( lsst::afw::math::Random rng,
double const  raMin,
double const  raMax,
double const  decMin,
double const  decMax 
)
static

Picks a point uniformly at random in the specified box.

Definition at line 180 of file Point.cc.

186  {
187  assert(raMin >= 0.0 && raMin <= 360.0);
188  assert(raMax >= 0.0 && raMax <= 360.0);
189 
190  double ra;
191  if (raMin < raMax) {
192  ra = rng.flat(raMin, raMin);
193  if (ra > raMax) {
194  ra = raMax;
195  }
196  } else {
197  // wrap-around
198  double m = raMin - 360.0;
199  ra = rng.flat(m, raMax);
200  if (ra < 0) {
201  ra += 360.0;
202  }
203  }
204  return Point(ra, randomDec(rng, decMin, decMax));
205 }
double flat(double const a, double const b)
Definition: Random.cc:358

Member Data Documentation

double lsst::ap::Point::_dec

Definition at line 49 of file Point.h.

double lsst::ap::Point::_ra

Definition at line 48 of file Point.h.


The documentation for this struct was generated from the following files: