LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Functions | Variables
lsst::geom Namespace Reference

Namespaces

 _Angle
 
 _coordinates
 
 _SpherePoint
 
 detail
 
 polynomials
 Low-level polynomials (including special polynomials) in C++.
 
 testUtils
 
 version
 

Classes

class  AffineTransform
 An affine coordinate transformation consisting of a linear transformation and an offset. More...
 
class  Angle
 A class representing an angle. More...
 
class  AngleUnit
 A class used to convert scalar POD types such as double to Angle. More...
 
class  Box2D
 A floating-point coordinate rectangle geometry. More...
 
class  Box2I
 An integer coordinate rectangle. More...
 
class  CoordinateBase
 A CRTP base class for coordinate objects. More...
 
class  CoordinateBase< Derived, T, 2 >
 Specialization of CoordinateBase for 2 dimensions. More...
 
class  CoordinateBase< Derived, T, 3 >
 Specialization of CoordinateBase for 3 dimensions. More...
 
class  CoordinateExpr
 A boolean coordinate. More...
 
class  Extent
 A coordinate class intended to represent offsets and dimensions. More...
 
class  Extent< T, 2 >
 A coordinate class intended to represent offsets and dimensions (2-d specialization). More...
 
class  Extent< T, 3 >
 A coordinate class intended to represent offsets and dimensions (3-d specialization). More...
 
class  ExtentBase
 
class  LinearTransform
 A 2D linear coordinate transformation. More...
 
class  Point
 A coordinate class intended to represent absolute positions. More...
 
class  Point< T, 2 >
 A coordinate class intended to represent absolute positions (2-d specialization). More...
 
class  Point< T, 3 >
 A coordinate class intended to represent absolute positions (3-d specialization). More...
 
class  PointBase
 
class  SingularTransformException
 
class  SpherePoint
 Point in an unspecified spherical coordinate system. More...
 

Typedefs

typedef Box2D BoxD
 
typedef Box2I BoxI
 
typedef CoordinateExpr< 2 > CoordinateExpr2
 
typedef CoordinateExpr< 3 > CoordinateExpr3
 
typedef Extent< int, 2 > ExtentI
 
typedef Extent< int, 2 > Extent2I
 
typedef Extent< int, 3 > Extent3I
 
typedef Extent< double, 2 > ExtentD
 
typedef Extent< double, 2 > Extent2D
 
typedef Extent< double, 3 > Extent3D
 
typedef Point< int, 2 > PointI
 
typedef Point< int, 2 > Point2I
 
typedef Point< int, 3 > Point3I
 
typedef Point< double, 2 > PointD
 
typedef Point< double, 2 > Point2D
 
typedef Point< double, 3 > Point3D
 
using PyAngle = py::class_< Angle >
 
using PyAngleUnit = py::class_< AngleUnit >
 
using PySpherePoint = py::class_< SpherePoint, std::shared_ptr< SpherePoint > >
 

Functions

std::ostreamoperator<< (std::ostream &os, lsst::geom::AffineTransform const &transform)
 
AffineTransform makeAffineTransformFromTriple (Point2D const &p1, Point2D const &p2, Point2D const &p3, Point2D const &q1, Point2D const &q2, Point2D const &q3)
 
constexpr double degToRad (double x) noexcept
 
constexpr double radToDeg (double x) noexcept
 
constexpr double radToArcsec (double x) noexcept
 
constexpr double radToMas (double x) noexcept
 
constexpr double arcsecToRad (double x) noexcept
 
constexpr double masToRad (double x) noexcept
 
constexpr Angle operator+ (Angle a, Angle d) noexcept
 Sum of two angles. More...
 
constexpr Angle operator- (Angle a, Angle d) noexcept
 Difference of two angles. More...
 
constexpr Angle operator* (Angle a, Angle d) noexcept
 Product of two angles. More...
 
constexpr Angle operator- (Angle angle)
 An angle in the opposite sense. More...
 
constexpr Angle operator/ (Angle a, int d) noexcept
 Ratio of an angle and a scalar. More...
 
constexpr Angle operator/ (Angle a, double d) noexcept
 Ratio of an angle and a scalar. More...
 
template<typename T >
constexpr double operator/ (T const lhs, Angle rhs) noexcept=delete
 
std::ostreamoperator<< (std::ostream &s, Angle a)
 Print an Angle to a stream. More...
 
template<typename T >
constexpr bool isAngle (T) noexcept
 Allow a user to check if they have an angle. More...
 
template<typename T >
constexpr Angle operator* (T lhs, AngleUnit rhs) noexcept
 Use AngleUnit to convert a POD (e.g. int, double) to an Angle; e.g. 180*degrees. More...
 
std::ostreamoperator<< (std::ostream &os, Box2I const &box)
 
std::ostreamoperator<< (std::ostream &os, Box2D const &box)
 
template<typename Derived , typename T , int N>
bool allclose (CoordinateBase< Derived, T, N > const &a, CoordinateBase< Derived, T, N > const &b, T rtol=static_cast< T >(1E-5), T atol=static_cast< T >(1E-8)) noexcept(std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_assignable< T >::value)
 Floating-point comparison with tolerance. More...
 
template<typename Derived , typename T , int N>
std::ostreamoperator<< (std::ostream &os, CoordinateBase< Derived, T, N > const &coordinate)
 
template<int N>
bool all (CoordinateExpr< N > const &expr) noexcept
 Return true if all elements are true. More...
 
template<int N>
bool any (CoordinateExpr< N > const &expr) noexcept
 Return true if any elements are true. More...
 
template<typename T , int N>
std::size_t hash_value (Extent< T, N > const &extent) noexcept
 
template<int N>
Extent< int, N > truncate (Extent< double, N > const &input) noexcept
 Return the component-wise truncation (round towards zero). More...
 
template<int N>
Extent< int, N > floor (Extent< double, N > const &input) noexcept
 Return the component-wise floor (round towards more negative). More...
 
template<int N>
Extent< int, N > ceil (Extent< double, N > const &input) noexcept
 Return the component-wise ceil (round towards more positive). More...
 
template<typename T , int N>
Extent< T, N > operator* (T scalar, ExtentBase< T, N > const &rhs) noexcept(ExtentBase< T, N >::IS_ELEMENT_NOTHROW_COPYABLE)
 
template<int N>
Extent< double, N > operator* (ExtentBase< int, N > const &lhs, double rhs) noexcept
 
template<int N>
void operator*= (ExtentBase< int, N > &lhs, double rhs) noexcept
 
template<int N>
Extent< double, N > operator/ (ExtentBase< int, N > const &lhs, double rhs) noexcept
 
template<int N>
void operator/= (ExtentBase< int, N > &lhs, double rhs) noexcept
 
template<int N>
Extent< double, N > operator* (double lhs, ExtentBase< int, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > operator+ (Extent< double, N > const &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > & operator+= (Extent< double, N > &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > operator- (Extent< double, N > const &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > & operator-= (Extent< double, N > &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > operator+ (Extent< int, N > const &lhs, Extent< double, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > operator- (Extent< int, N > const &lhs, Extent< double, N > const &rhs) noexcept
 
std::ostreamoperator<< (std::ostream &os, lsst::geom::LinearTransform const &t)
 
template<typename T , int N>
std::size_t hash_value (Point< T, N > const &point) noexcept
 
template<int N>
Point< double, N > operator+ (Point< double, N > const &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Point< double, N > operator+ (Extent< int, N > const &rhs, Point< double, N > const &lhs) noexcept
 
template<int N>
Point< double, N > & operator+= (Point< double, N > &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Point< double, N > operator+ (Point< int, N > const &lhs, Extent< double, N > const &rhs) noexcept
 
template<int N>
Point< double, N > operator- (Point< double, N > const &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Point< double, N > & operator-= (Point< double, N > &lhs, Extent< int, N > const &rhs) noexcept
 
template<int N>
Point< double, N > operator- (Point< int, N > const &lhs, Extent< double, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > operator- (Point< double, N > const &lhs, Point< int, N > const &rhs) noexcept
 
template<int N>
Extent< double, N > operator- (Point< int, N > const &lhs, Point< double, N > const &rhs) noexcept
 
SpherePoint averageSpherePoint (std::vector< SpherePoint > const &coords)
 Return the average of a list of coordinates. More...
 
std::ostreamoperator<< (std::ostream &os, SpherePoint const &point)
 Print the value of a point to a stream. More...
 
Eigen::Vector3d asEigen (sphgeom::Vector3d const &vector) noexcept
 
void wrapAffineTransform (utils::python::WrapperCollection &wrappers)
 
void wrapAngle (utils::python::WrapperCollection &wrappers)
 
void wrapBox (utils::python::WrapperCollection &wrappers)
 
void wrapCoordinates (utils::python::WrapperCollection &wrappers)
 
void wrapSpherePoint (WrapperCollection &wrappers)
 
void wrapLinearTransform (WrapperCollection &wrappers)
 
 PYBIND11_MODULE (_geom, mod)
 
template bool allclose< Point2D, double, 2 > (CoordinateBase< Point2D, double, 2 > const &, CoordinateBase< Point2D, double, 2 > const &, double, double)
 
template bool allclose< Point3D, double, 3 > (CoordinateBase< Point3D, double, 3 > const &, CoordinateBase< Point3D, double, 3 > const &, double, double)
 
template bool allclose< Extent2D, double, 2 > (CoordinateBase< Extent2D, double, 2 > const &, CoordinateBase< Extent2D, double, 2 > const &, double, double)
 
template bool allclose< Extent3D, double, 3 > (CoordinateBase< Extent3D, double, 3 > const &, CoordinateBase< Extent3D, double, 3 > const &, double, double)
 
constexpr Angle operator* (Angle a, double d) noexcept
 Product of an angle and a scalar. More...
 
constexpr Angle operator* (double d, Angle a) noexcept
 Product of an angle and a scalar. More...
 
constexpr Angle operator* (Angle a, int d) noexcept
 Product of an angle and a scalar. More...
 
constexpr Angle operator* (int d, Angle a) noexcept
 Product of an angle and a scalar. More...
 

Variables

double constexpr PI = boost::math::constants::pi<double>()
 The ratio of a circle's circumference to diameter. More...
 
double constexpr TWOPI = boost::math::constants::pi<double>() * 2.0
 
double constexpr HALFPI = boost::math::constants::pi<double>() * 0.5
 
double constexpr ONE_OVER_PI = 1.0 / boost::math::constants::pi<double>()
 
double const SQRTPI = sqrt(boost::math::constants::pi<double>())
 
double const INVSQRTPI = 1.0 / sqrt(boost::math::constants::pi<double>())
 
double constexpr ROOT2 = boost::math::constants::root_two<double>()
 
AngleUnit constexpr radians = AngleUnit(1.0)
 constant with units of radians More...
 
AngleUnit constexpr degrees = AngleUnit(PI / 180.0)
 constant with units of degrees More...
 
AngleUnit constexpr hours = AngleUnit(PI * 15.0 / 180.0)
 constant with units of hours More...
 
AngleUnit constexpr arcminutes = AngleUnit(PI / 60 / 180.0)
 constant with units of arcminutes More...
 
AngleUnit constexpr arcseconds = AngleUnit(PI / 180.0 / 3600.0)
 constant with units of arcseconds More...
 
AngleUnit constexpr milliarcseconds
 constant with units of milliarcseconds More...
 
template<typename T , typename U >
bool constexpr IS_NOTHROW_CONVERTIBLE
 Test that a type is nothrow-copy-convertible from U to T. More...
 

Typedef Documentation

◆ BoxD

Definition at line 538 of file Box.h.

◆ BoxI

Definition at line 539 of file Box.h.

◆ CoordinateExpr2

Definition at line 95 of file CoordinateExpr.h.

◆ CoordinateExpr3

Definition at line 96 of file CoordinateExpr.h.

◆ Extent2D

typedef Extent<double, 2> lsst::geom::Extent2D

Definition at line 400 of file Extent.h.

◆ Extent2I

typedef Extent<int, 2> lsst::geom::Extent2I
Examples:
image2.cc, and maskedImage2.cc.

Definition at line 397 of file Extent.h.

◆ Extent3D

typedef Extent<double, 3> lsst::geom::Extent3D

Definition at line 401 of file Extent.h.

◆ Extent3I

typedef Extent<int, 3> lsst::geom::Extent3I

Definition at line 398 of file Extent.h.

◆ ExtentD

typedef Extent<double, 2> lsst::geom::ExtentD

Definition at line 399 of file Extent.h.

◆ ExtentI

typedef Extent<int, 2> lsst::geom::ExtentI

Definition at line 396 of file Extent.h.

◆ Point2D

typedef Point<double, 2> lsst::geom::Point2D

Definition at line 324 of file Point.h.

◆ Point2I

typedef Point<int, 2> lsst::geom::Point2I

Definition at line 321 of file Point.h.

◆ Point3D

typedef Point<double, 3> lsst::geom::Point3D

Definition at line 325 of file Point.h.

◆ Point3I

typedef Point<int, 3> lsst::geom::Point3I

Definition at line 322 of file Point.h.

◆ PointD

typedef Point<double, 2> lsst::geom::PointD

Definition at line 323 of file Point.h.

◆ PointI

typedef Point<int, 2> lsst::geom::PointI

Definition at line 320 of file Point.h.

◆ PyAngle

using lsst::geom::PyAngle = typedef py::class_<Angle>

Definition at line 33 of file _Angle.cc.

◆ PyAngleUnit

using lsst::geom::PyAngleUnit = typedef py::class_<AngleUnit>

Definition at line 34 of file _Angle.cc.

◆ PySpherePoint

Definition at line 41 of file _SpherePoint.cc.

Function Documentation

◆ all()

template<int N>
bool lsst::geom::all ( CoordinateExpr< N > const &  expr)
inlinenoexcept

Return true if all elements are true.

Definition at line 81 of file CoordinateExpr.h.

81  {
82  for (int n = 0; n < N; ++n)
83  if (!expr[n]) return false;
84  return true;
85 }

◆ allclose()

template<typename Derived , typename T , int N>
bool lsst::geom::allclose ( CoordinateBase< Derived, T, N > const &  a,
CoordinateBase< Derived, T, N > const &  b,
rtol = static_cast<T>(1E-5),
atol = static_cast<T>(1E-8) 
)
noexcept

Floating-point comparison with tolerance.

Interface, naming, and default tolerances matches Numpy.

Definition at line 30 of file CoordinateBase.cc.

32  {
33  Eigen::Array<T, N, 1> diff = (a.asEigen().array() - b.asEigen().array()).abs();
34  Eigen::Array<T, N, 1> rhs = (0.5 * (a.asEigen().array() + b.asEigen().array())).abs();
35  rhs *= rtol;
36  rhs += atol;
37  return (diff <= rhs).all();
38 }
T atol(T... args)
Angle abs(Angle const &a)
Definition: Angle.h:106
table::Key< int > b
table::Key< int > a

◆ allclose< Extent2D, double, 2 >()

template bool lsst::geom::allclose< Extent2D, double, 2 > ( CoordinateBase< Extent2D, double, 2 > const &  ,
CoordinateBase< Extent2D, double, 2 > const &  ,
double  ,
double   
)

◆ allclose< Extent3D, double, 3 >()

template bool lsst::geom::allclose< Extent3D, double, 3 > ( CoordinateBase< Extent3D, double, 3 > const &  ,
CoordinateBase< Extent3D, double, 3 > const &  ,
double  ,
double   
)

◆ allclose< Point2D, double, 2 >()

template bool lsst::geom::allclose< Point2D, double, 2 > ( CoordinateBase< Point2D, double, 2 > const &  ,
CoordinateBase< Point2D, double, 2 > const &  ,
double  ,
double   
)

◆ allclose< Point3D, double, 3 >()

template bool lsst::geom::allclose< Point3D, double, 3 > ( CoordinateBase< Point3D, double, 3 > const &  ,
CoordinateBase< Point3D, double, 3 > const &  ,
double  ,
double   
)

◆ any()

template<int N>
bool lsst::geom::any ( CoordinateExpr< N > const &  expr)
inlinenoexcept

Return true if any elements are true.

Definition at line 89 of file CoordinateExpr.h.

89  {
90  for (int n = 0; n < N; ++n)
91  if (expr[n]) return true;
92  return false;
93 }

◆ arcsecToRad()

constexpr double lsst::geom::arcsecToRad ( double  x)
inlinenoexcept

Definition at line 55 of file Angle.h.

55 { return (x / 3600.) * PI / 180.; }
double x
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ asEigen()

Eigen::Vector3d lsst::geom::asEigen ( sphgeom::Vector3d const &  vector)
noexcept

Definition at line 36 of file sphgeomUtils.h.

36  {
37  return Eigen::Vector3d(vector.x(), vector.y(), vector.z());
38 }

◆ averageSpherePoint()

SpherePoint lsst::geom::averageSpherePoint ( std::vector< SpherePoint > const &  coords)

Return the average of a list of coordinates.

Parameters
[in]coordslist of coords to average
Exceptions
lsst::pex::exceptions::LengthErrorif coords is empty

Definition at line 235 of file SpherePoint.cc.

235  {
236  if (coords.size() == 0) {
237  throw LSST_EXCEPT(pex::exceptions::LengthError, "No coordinates provided to average");
238  }
239  sphgeom::Vector3d sum(0, 0, 0);
240  sphgeom::Vector3d corr(0, 0, 0); // Kahan summation correction
241  for (auto const& sp : coords) {
242  auto const point = sp.getVector();
243  // Kahan summation
244  auto const add = point - corr;
245  auto const temp = sum + add;
246  corr = (temp - sum) - add;
247  sum = temp;
248  }
249  sum /= static_cast<double>(coords.size());
250  return SpherePoint(sum);
251 }
T size(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::geom::SpherePoint SpherePoint
Definition: misc.h:35

◆ ceil()

template<int N>
Extent< int, N > lsst::geom::ceil ( Extent< double, N > const &  input)
noexcept

Return the component-wise ceil (round towards more positive).

In Python, this is available as both a free function and a method on ExtentD.

Definition at line 118 of file Extent.cc.

118  {
119  Extent<int, N> result;
120  for (int i = 0; i < N; ++i) {
121  result[i] = std::ceil(input[i]);
122  }
123  return result;
124 }
T ceil(T... args)
py::object result
Definition: schema.cc:418

◆ degToRad()

constexpr double lsst::geom::degToRad ( double  x)
inlinenoexcept

Definition at line 51 of file Angle.h.

51 { return x * PI / 180.; }
double x
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ floor()

template<int N>
Extent< int, N > lsst::geom::floor ( Extent< double, N > const &  input)
noexcept

Return the component-wise floor (round towards more negative).

In Python, this is available as both a free function and a method on ExtentD.

Definition at line 109 of file Extent.cc.

109  {
110  Extent<int, N> result;
111  for (int i = 0; i < N; ++i) {
112  result[i] = std::floor(input[i]);
113  }
114  return result;
115 }
py::object result
Definition: schema.cc:418
T floor(T... args)

◆ hash_value() [1/2]

template<typename T , int N>
std::size_t lsst::geom::hash_value ( Point< T, N > const &  point)
noexcept

Definition at line 118 of file Point.cc.

118  {
119  std::size_t result = 0; // Completely arbitrary seed
120  for (int n = 0; n < N; ++n) result = utils::hashCombine(result, point[n]);
121  return result;
122 }
py::object result
Definition: schema.cc:418
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35

◆ hash_value() [2/2]

template<typename T , int N>
std::size_t lsst::geom::hash_value ( Extent< T, N > const &  extent)
noexcept

Definition at line 127 of file Extent.cc.

127  {
128  std::size_t result = 0; // Completely arbitrary seed
129  for (int n = 0; n < N; ++n) result = utils::hashCombine(result, extent[n]);
130  return result;
131 }
py::object result
Definition: schema.cc:418
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35

◆ isAngle()

template<typename T >
constexpr bool lsst::geom::isAngle ( )
inlinenoexcept

Allow a user to check if they have an angle.

Definition at line 380 of file Angle.h.

380  {
382 };

◆ makeAffineTransformFromTriple()

AffineTransform lsst::geom::makeAffineTransformFromTriple ( Point2D const &  p1,
Point2D const &  p2,
Point2D const &  p3,
Point2D const &  q1,
Point2D const &  q2,
Point2D const &  q3 
)

Definition at line 88 of file AffineTransform.cc.

89  {
90  Eigen::Matrix3d mp;
91  mp << p1.getX(), p2.getX(), p3.getX(), p1.getY(), p2.getY(), p3.getY(), 1.0, 1.0, 1.0;
92 
93  Eigen::Matrix3d mq;
94  mq << q1.getX(), q2.getX(), q3.getX(), q1.getY(), q2.getY(), q3.getY(), 1.0, 1.0, 1.0;
95 
96  Eigen::Matrix3d m = mq * mp.inverse();
97  return AffineTransform(m);
98 }
int m
Definition: SpanSet.cc:49

◆ masToRad()

constexpr double lsst::geom::masToRad ( double  x)
inlinenoexcept

Definition at line 56 of file Angle.h.

56 { return (x / (1000. * 3600.)) * PI / 180.; }
double x
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ operator*() [1/9]

constexpr Angle operator* ( Angle  a,
Angle  d 
)
inlinenoexcept

Product of two angles.

Warning
The result will be treated like an planar angle, not a solid angle.

Definition at line 322 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator*() [2/9]

constexpr Angle operator* ( Angle  a,
double  d 
)
inlinenoexcept

Product of an angle and a scalar.

Definition at line 329 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator*() [3/9]

constexpr Angle lsst::geom::operator* ( double  d,
Angle  a 
)
inlinenoexcept

Product of an angle and a scalar.

Definition at line 329 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator*() [4/9]

constexpr Angle lsst::geom::operator* ( Angle  a,
int  d 
)
inlinenoexcept

Product of an angle and a scalar.

Definition at line 330 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator*() [5/9]

constexpr Angle lsst::geom::operator* ( int  d,
Angle  a 
)
inlinenoexcept

Product of an angle and a scalar.

Definition at line 330 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator*() [6/9]

template<typename T >
constexpr Angle operator* ( lhs,
AngleUnit  rhs 
)
inlinenoexcept

Use AngleUnit to convert a POD (e.g. int, double) to an Angle; e.g. 180*degrees.

Parameters
lhsthe value to convert
rhsthe conversion coefficient
Exception Safety
Shall not throw exceptions.

Definition at line 395 of file Angle.h.

395  {
396  static_assert(std::is_arithmetic<T>::value,
397  "Only numeric types may be multiplied by an AngleUnit to create an Angle!");
398  return Angle(lhs * rhs._val);
399 }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator*() [7/9]

template<typename T , int N>
Extent<T, N> lsst::geom::operator* ( scalar,
ExtentBase< T, N > const &  rhs 
)
noexcept

Definition at line 432 of file Extent.h.

433  {
434  return rhs * scalar;
435 }

◆ operator*() [8/9]

template<int N>
Extent<double, N> lsst::geom::operator* ( ExtentBase< int, N > const &  lhs,
double  rhs 
)
noexcept

Definition at line 438 of file Extent.h.

438  {
439  return Extent<double, N>(static_cast<Extent<int, N> const &>(lhs)) * rhs;
440 }

◆ operator*() [9/9]

template<int N>
Extent<double, N> lsst::geom::operator* ( double  lhs,
ExtentBase< int, N > const &  rhs 
)
noexcept

Definition at line 460 of file Extent.h.

460  {
461  return lhs * Extent<double, N>(static_cast<Extent<int, N> const &>(rhs));
462 }

◆ operator*=()

template<int N>
void lsst::geom::operator*= ( ExtentBase< int, N > &  lhs,
double  rhs 
)
noexcept

Definition at line 443 of file Extent.h.

443  {
444  // use "N < 0" so assertion is dependent on template instantiation, instead of triggering all the time
445  static_assert(N < 0, "In-place multiplication of Extent<int,N> by double would truncate.");
446 }

◆ operator+() [1/6]

constexpr Angle operator+ ( Angle  a,
Angle  d 
)
inlinenoexcept

Sum of two angles.

Definition at line 308 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator+() [2/6]

template<int N>
Point<double, N> lsst::geom::operator+ ( Point< double, N > const &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 328 of file Point.h.

328  {
329  return lhs + Extent<double, N>(rhs);
330 }

◆ operator+() [3/6]

template<int N>
Point<double, N> lsst::geom::operator+ ( Extent< int, N > const &  rhs,
Point< double, N > const &  lhs 
)
noexcept

Definition at line 333 of file Point.h.

333  {
334  return Point<double, N>(lhs) + rhs;
335 }

◆ operator+() [4/6]

template<int N>
Point<double, N> lsst::geom::operator+ ( Point< int, N > const &  lhs,
Extent< double, N > const &  rhs 
)
noexcept

Definition at line 343 of file Point.h.

343  {
344  return Point<double, N>(lhs) + rhs;
345 }

◆ operator+() [5/6]

template<int N>
Extent<double, N> lsst::geom::operator+ ( Extent< double, N > const &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 465 of file Extent.h.

465  {
466  return lhs + Extent<double, N>(rhs);
467 }

◆ operator+() [6/6]

template<int N>
Extent<double, N> lsst::geom::operator+ ( Extent< int, N > const &  lhs,
Extent< double, N > const &  rhs 
)
noexcept

Definition at line 485 of file Extent.h.

485  {
486  return Extent<double, N>(lhs) + rhs;
487 }

◆ operator+=() [1/2]

template<int N>
Point<double, N>& lsst::geom::operator+= ( Point< double, N > &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 338 of file Point.h.

338  {
339  return lhs += Extent<double, N>(rhs);
340 }

◆ operator+=() [2/2]

template<int N>
Extent<double, N>& lsst::geom::operator+= ( Extent< double, N > &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 470 of file Extent.h.

470  {
471  return lhs += Extent<double, N>(rhs);
472 }

◆ operator-() [1/8]

constexpr Angle operator- ( Angle  a,
Angle  d 
)
inlinenoexcept

Difference of two angles.

Definition at line 314 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator-() [2/8]

constexpr Angle operator- ( Angle  angle)
inline

An angle in the opposite sense.

Definition at line 341 of file Angle.h.

341 { return Angle(-static_cast<double>(angle)); }
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator-() [3/8]

template<int N>
Point<double, N> lsst::geom::operator- ( Point< double, N > const &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 348 of file Point.h.

348  {
349  return lhs - Extent<double, N>(rhs);
350 }

◆ operator-() [4/8]

template<int N>
Point<double, N> lsst::geom::operator- ( Point< int, N > const &  lhs,
Extent< double, N > const &  rhs 
)
noexcept

Definition at line 358 of file Point.h.

358  {
359  return Point<double, N>(lhs) - rhs;
360 }

◆ operator-() [5/8]

template<int N>
Extent<double, N> lsst::geom::operator- ( Point< double, N > const &  lhs,
Point< int, N > const &  rhs 
)
noexcept

Definition at line 363 of file Point.h.

363  {
364  return lhs - Point<double, N>(rhs);
365 }

◆ operator-() [6/8]

template<int N>
Extent<double, N> lsst::geom::operator- ( Point< int, N > const &  lhs,
Point< double, N > const &  rhs 
)
noexcept

Definition at line 368 of file Point.h.

368  {
369  return Point<double, N>(lhs) - rhs;
370 }

◆ operator-() [7/8]

template<int N>
Extent<double, N> lsst::geom::operator- ( Extent< double, N > const &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 475 of file Extent.h.

475  {
476  return lhs - Extent<double, N>(rhs);
477 }

◆ operator-() [8/8]

template<int N>
Extent<double, N> lsst::geom::operator- ( Extent< int, N > const &  lhs,
Extent< double, N > const &  rhs 
)
noexcept

Definition at line 490 of file Extent.h.

490  {
491  return Extent<double, N>(lhs) - rhs;
492 }

◆ operator-=() [1/2]

template<int N>
Point<double, N>& lsst::geom::operator-= ( Point< double, N > &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 353 of file Point.h.

353  {
354  return lhs -= Extent<double, N>(rhs);
355 }

◆ operator-=() [2/2]

template<int N>
Extent<double, N>& lsst::geom::operator-= ( Extent< double, N > &  lhs,
Extent< int, N > const &  rhs 
)
noexcept

Definition at line 480 of file Extent.h.

480  {
481  return lhs -= Extent<double, N>(rhs);
482 }

◆ operator/() [1/4]

constexpr Angle operator/ ( Angle  a,
int  d 
)
inlinenoexcept

Ratio of an angle and a scalar.

Definition at line 349 of file Angle.h.

349 { return Angle(static_cast<double>(a) / d); }
table::Key< int > a
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator/() [2/4]

constexpr Angle operator/ ( Angle  a,
double  d 
)
inlinenoexcept

Ratio of an angle and a scalar.

Definition at line 356 of file Angle.h.

356 { return Angle(static_cast<double>(a) / d); }
table::Key< int > a
lsst::geom::Angle Angle
Definition: misc.h:33

◆ operator/() [3/4]

template<typename T >
constexpr double lsst::geom::operator/ ( T const  lhs,
Angle  rhs 
)
deletenoexcept

◆ operator/() [4/4]

template<int N>
Extent<double, N> lsst::geom::operator/ ( ExtentBase< int, N > const &  lhs,
double  rhs 
)
noexcept

Definition at line 449 of file Extent.h.

449  {
450  return Extent<double, N>(static_cast<Extent<int, N> const &>(lhs)) / rhs;
451 }

◆ operator/=()

template<int N>
void lsst::geom::operator/= ( ExtentBase< int, N > &  lhs,
double  rhs 
)
noexcept

Definition at line 454 of file Extent.h.

454  {
455  // use "N < 0" so assertion is dependent on template instantiation, instead of triggering all the time
456  static_assert(N < 0, "In-place division of Extent<int,N> by double would truncate.");
457 }

◆ operator<<() [1/7]

std::ostream & lsst::geom::operator<< ( std::ostream os,
lsst::geom::LinearTransform const &  t 
)

Definition at line 65 of file LinearTransform.cc.

65  {
66  std::ios::fmtflags flags = os.flags();
67  int prec = os.precision(7);
68  os.setf(std::ios::fixed);
69  os << "LinearTransform([(" << std::setw(10) << t[LinearTransform::XX] << "," << std::setw(10)
70  << t[LinearTransform::XY] << "),\n";
71  os << " (" << std::setw(10) << t[LinearTransform::YX] << "," << std::setw(10)
72  << t[LinearTransform::YY] << ")])";
73  os.precision(prec);
74  os.flags(flags);
75  return os;
76 }
T setf(T... args)
T precision(T... args)
T setw(T... args)
T flags(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [2/7]

template<typename Derived , typename T , int N>
std::ostream& lsst::geom::operator<< ( std::ostream os,
CoordinateBase< Derived, T, N > const &  coordinate 
)

Definition at line 258 of file CoordinateBase.h.

258  {
259  os << "(" << coordinate[0];
260  for (int n = 1; n < N; ++n) os << ", " << coordinate[n];
261  return os << ")";
262 }

◆ operator<<() [3/7]

std::ostream & lsst::geom::operator<< ( std::ostream os,
lsst::geom::AffineTransform const &  transform 
)

Definition at line 72 of file AffineTransform.cc.

72  {
73  std::ios::fmtflags flags = os.flags();
74  AffineTransform::Matrix const &matrix = transform.getMatrix();
75  int prec = os.precision(7);
76  os.setf(std::ios::fixed);
77  os << "AffineTransform([(" << std::setw(10) << matrix(0, 0) << "," << std::setw(10) << matrix(0, 1) << ","
78  << std::setw(10) << matrix(0, 2) << "),\n";
79  os << " (" << std::setw(10) << matrix(1, 0) << "," << std::setw(10) << matrix(1, 1) << ","
80  << std::setw(10) << matrix(1, 2) << "),\n";
81  os << " (" << std::setw(10) << matrix(2, 0) << "," << std::setw(10) << matrix(2, 1) << ","
82  << std::setw(10) << matrix(2, 2) << ")])";
83  os.precision(prec);
84  os.flags(flags);
85  return os;
86 }
T setf(T... args)
T precision(T... args)
T setw(T... args)
T flags(T... args)
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Typedefs to be used for probability and parameter values.
Definition: common.h:45
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [4/7]

std::ostream & lsst::geom::operator<< ( std::ostream s,
Angle  a 
)

Print an Angle to a stream.

The exact details of the string representation are unspecified and subject to change, but the following may be regarded as typical: "0.567 rad".

Parameters
sThe output stream.
aThe angle.
Exception Safety
Provides basic exception guarantee.

Definition at line 29 of file Angle.cc.

29 { return s << static_cast<double>(a) << " rad"; }
table::Key< int > a

◆ operator<<() [5/7]

ostream & lsst::geom::operator<< ( std::ostream os,
SpherePoint const &  point 
)

Print the value of a point to a stream.

The exact details of the string representation are unspecified and subject to change, but the following may be regarded as typical: "(10.543250, +32.830583)".

Parameters
osthe stream to which to print point
pointthe point to print to the stream
Returns
a reference to os
Exceptions
pex::exceptions::std::ostream::failureThrown if an I/O state flag was set that was registered with os.exceptions(). See the documentation of std::ostream for more details.
Exception Safety
Provides basic exception guarantee.

Definition at line 253 of file SpherePoint.cc.

253  {
254  // Can't provide atomic guarantee anyway for I/O, so ok to be sloppy.
255  auto oldFlags = os.setf(ostream::fixed);
256  auto oldPrecision = os.precision(6);
257 
258  os << "(" << point.getLongitude().asDegrees() << ", ";
259  os.setf(ostream::showpos);
260  os << point.getLatitude().asDegrees() << ")";
261 
262  os.flags(oldFlags);
263  os.precision(oldPrecision);
264  return os;
265 }
T setf(T... args)
T precision(T... args)
T flags(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [6/7]

std::ostream & lsst::geom::operator<< ( std::ostream os,
Box2I const &  box 
)

Definition at line 430 of file Box.cc.

430  {
431  if (box.isEmpty()) return os << "Box2I()";
432  return os << "Box2I(Point2I" << box.getMin() << ", Extent2I" << box.getDimensions() << ")";
433 }

◆ operator<<() [7/7]

std::ostream & lsst::geom::operator<< ( std::ostream os,
Box2D const &  box 
)

Definition at line 435 of file Box.cc.

435  {
436  if (box.isEmpty()) return os << "Box2D()";
437  return os << "Box2D(Point2D" << box.getMin() << ", Extent2D" << box.getDimensions() << ")";
438 }

◆ PYBIND11_MODULE()

lsst::geom::PYBIND11_MODULE ( _geom  ,
mod   
)

Definition at line 42 of file _geom.cc.

42  {
43  WrapperCollection w(mod, "lsst.geom");
44  wrapAngle(w);
47  wrapBox(w);
50  w.finish();
51 }
void wrapAngle(utils::python::WrapperCollection &wrappers)
Definition: _Angle.cc:54
void wrapSpherePoint(WrapperCollection &wrappers)
Definition: _SpherePoint.cc:43
void wrapCoordinates(utils::python::WrapperCollection &wrappers)
void wrapBox(utils::python::WrapperCollection &wrappers)
Definition: _Box.cc:34
void wrapLinearTransform(WrapperCollection &wrappers)
double w
Definition: CoaddPsf.cc:69
void wrapAffineTransform(utils::python::WrapperCollection &wrappers)

◆ radToArcsec()

constexpr double lsst::geom::radToArcsec ( double  x)
inlinenoexcept

Definition at line 53 of file Angle.h.

53 { return x * 3600. * 180. / PI; }
double x
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ radToDeg()

constexpr double lsst::geom::radToDeg ( double  x)
inlinenoexcept

Definition at line 52 of file Angle.h.

52 { return x * 180. / PI; }
double x
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ radToMas()

constexpr double lsst::geom::radToMas ( double  x)
inlinenoexcept

Definition at line 54 of file Angle.h.

54 { return x * 1000. * 3600. * 180. / PI; }
double x
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ truncate()

template<int N>
Extent< int, N > lsst::geom::truncate ( Extent< double, N > const &  input)
noexcept

Return the component-wise truncation (round towards zero).

In Python, this is available as both a free function and a method on ExtentD.

Definition at line 100 of file Extent.cc.

100  {
101  Extent<int, N> result;
102  for (int i = 0; i < N; ++i) {
103  result[i] = static_cast<int>(input[i]);
104  }
105  return result;
106 }
py::object result
Definition: schema.cc:418

◆ wrapAffineTransform()

void lsst::geom::wrapAffineTransform ( utils::python::WrapperCollection wrappers)

Definition at line 37 of file _AffineTransform.cc.

37  {
38  wrappers.wrapType(
39  py::class_<AffineTransform, std::shared_ptr<AffineTransform>>(wrappers.module, "AffineTransform"),
40  [](auto & mod, auto & cls) mutable {
41 
42  // Parameters enum is really only used as integer constants.
43  cls.attr("XX") = py::cast(int(AffineTransform::Parameters::XX));
44  cls.attr("YX") = py::cast(int(AffineTransform::Parameters::YX));
45  cls.attr("XY") = py::cast(int(AffineTransform::Parameters::XY));
46  cls.attr("YY") = py::cast(int(AffineTransform::Parameters::YY));
47  cls.attr("X") = py::cast(int(AffineTransform::Parameters::X));
48  cls.attr("Y") = py::cast(int(AffineTransform::Parameters::Y));
49 
50  /* Constructors */
51  cls.def(py::init<>());
52  cls.def(py::init<Eigen::Matrix3d const &>(), "matrix"_a);
53  cls.def(py::init<Eigen::Matrix2d const &>(), "linear"_a);
54  cls.def(py::init<Eigen::Vector2d const &>(), "translation"_a);
55  cls.def(py::init<Eigen::Matrix2d const &, Eigen::Vector2d const &>(),
56  "linear"_a, "translation"_a);
57  cls.def(py::init<LinearTransform const &>(), "linear"_a);
58  cls.def(py::init<Extent2D const &>(), "translation"_a);
59  cls.def(py::init<LinearTransform const &, Extent2D const &>(), "linear"_a, "translation"_a);
60 
61  /* Operators and special methods */
62  cls.def("__mul__", &AffineTransform::operator*, py::is_operator());
63  cls.def("__call__",
64  py::overload_cast<Point2D const &>(&AffineTransform::operator(), py::const_));
65  cls.def("__call__",
66  py::overload_cast<Extent2D const &>(&AffineTransform::operator(), py::const_));
67  cls.def("__setitem__", [](AffineTransform &self, int i, double value) {
68  if (i < 0 || i > 5) {
69  PyErr_Format(PyExc_IndexError, "Invalid index for AffineTransform: %d", i);
70  throw py::error_already_set();
71  }
72  self[i] = value;
73  });
74  cls.def("__getitem__", [](AffineTransform const &self, int row, int col) {
75  if (row < 0 || row > 2 || col < 0 || col > 2) {
76  PyErr_Format(PyExc_IndexError, "Invalid index for AffineTransform: %d, %d", row, col);
77  throw py::error_already_set();
78  }
79  return (self.getMatrix())(row, col);
80  });
81  cls.def("__getitem__", [](AffineTransform const &self, int i) {
82  if (i < 0 || i > 5) {
83  PyErr_Format(PyExc_IndexError, "Invalid index for AffineTransform: %d", i);
84  throw py::error_already_set();
85  }
86  return self[i];
87  });
88  cls.def("__str__", [](AffineTransform const &self) {
89  return py::str(py::cast(self.getMatrix())); }
90  );
91  cls.def("__repr__", [](AffineTransform const &self) {
92  return py::str("AffineTransform(\n{}\n)").format(py::cast(self.getMatrix()));
93  });
94  cls.def("__reduce__", [cls](AffineTransform const &self) {
95  return py::make_tuple(cls, py::make_tuple(py::cast(self.getMatrix())));
96  });
97 
98  /* Members */
99  cls.def("inverted", &AffineTransform::inverted);
100  cls.def("isIdentity", &AffineTransform::isIdentity);
101  cls.def("getTranslation", (Extent2D & (AffineTransform::*)()) & AffineTransform::getTranslation);
102  cls.def("getLinear", (LinearTransform & (AffineTransform::*)()) & AffineTransform::getLinear);
103  cls.def("getMatrix", &AffineTransform::getMatrix);
104  cls.def("getParameterVector", &AffineTransform::getParameterVector);
105  cls.def("setParameterVector", &AffineTransform::setParameterVector);
106  cls.def_static("makeScaling", py::overload_cast<double>(&AffineTransform::makeScaling));
107  cls.def_static("makeScaling", py::overload_cast<double, double>(&AffineTransform::makeScaling));
108  cls.def_static("makeRotation", &AffineTransform::makeRotation, "angle"_a);
109  cls.def_static("makeTranslation", &AffineTransform::makeTranslation, "translation"_a);
110 
111  /* Non-members */
112  mod.def("makeAffineTransformFromTriple", makeAffineTransformFromTriple);
113  }
114  );
115 }
int col
Definition: CR.cc:144
Extent< double, 2 > Extent2D
Definition: Extent.h:400
AffineTransform makeAffineTransformFromTriple(Point2D const &p1, Point2D const &p2, Point2D const &p3, Point2D const &q1, Point2D const &q2, Point2D const &q3)
int row
Definition: CR.cc:145

◆ wrapAngle()

void lsst::geom::wrapAngle ( utils::python::WrapperCollection wrappers)

Definition at line 54 of file _Angle.cc.

54  {
55  wrappers.wrapType(
56  PyAngleUnit(wrappers.module, "AngleUnit"),
57  [](auto & mod, auto & cls) mutable {
58  cls.def("__eq__", [](AngleUnit const& self, AngleUnit const& other) { return self == other; },
59  py::is_operator());
60  cls.def("__ne__", [](AngleUnit const& self, AngleUnit const& other) { return !(self == other); },
61  py::is_operator());
62  cls.def("_mul", [](AngleUnit const& self, double other) { return other * self; },
63  py::is_operator());
64  cls.def("_rmul", [](AngleUnit const& self, double other) { return other * self; },
65  py::is_operator());
66  mod.attr("radians") = py::cast(radians);
67  mod.attr("degrees") = py::cast(degrees);
68  mod.attr("hours") = py::cast(hours);
69  mod.attr("arcminutes") = py::cast(arcminutes);
70  mod.attr("arcseconds") = py::cast(arcseconds);
71  mod.attr("milliarcseconds") = py::cast(milliarcseconds);
72  }
73  );
74 
75  wrappers.wrapType(
76  PyAngle(wrappers.module, "Angle"),
77  [](auto & mod, auto & cls) mutable {
78  cls.def(py::init<double, AngleUnit>(), py::arg("val"), py::arg("units") = radians);
79  cls.def(py::init<>());
80  declareAngleComparisonOperators<Angle>(cls);
81  declareAngleComparisonOperators<double>(cls);
82  declareAngleComparisonOperators<int>(cls);
83  cls.def("__mul__", [](Angle const& self, double other) { return self * other; },
84  py::is_operator());
85  cls.def("__mul__", [](Angle const& self, int other) { return self * other; },
86  py::is_operator());
87  cls.def("__rmul__", [](Angle const& self, double other) { return self * other; },
88  py::is_operator());
89  cls.def("__rmul__", [](Angle const& self, int other) { return self * other; },
90  py::is_operator());
91  cls.def("__imul__", [](Angle& self, double other) { return self *= other; });
92  cls.def("__imul__", [](Angle& self, int other) { return self *= other; });
93  cls.def("__add__", [](Angle const& self, Angle const& other) { return self + other; },
94  py::is_operator());
95  cls.def("__sub__", [](Angle const& self, Angle const& other) { return self - other; },
96  py::is_operator());
97  cls.def("__neg__", [](Angle const& self) { return -self; }, py::is_operator());
98  cls.def("__iadd__", [](Angle& self, Angle const& other) { return self += other; });
99  cls.def("__isub__", [](Angle& self, Angle const& other) { return self -= other; });
100  cls.def("__truediv__", [](Angle const& self, double other) { return self / other; },
101  py::is_operator());
102  // Without an explicit wrapper, Python lets Angle / Angle -> Angle
103  cls.def("__truediv__", [](Angle const& self, Angle const& other) {
104  throw py::type_error("unsupported operand type(s) for /: 'Angle' and 'Angle'");
105  });
106  cls.def("__float__", &Angle::operator double);
107  cls.def("__abs__", [](Angle const& self) { return std::abs(self.asRadians()) * radians; });
108 
109  cls.def("__reduce__", [cls](Angle const& self) {
110  return py::make_tuple(cls, py::make_tuple(py::cast(self.asRadians())));
111  });
112  utils::python::addOutputOp(cls, "__str__");
113  utils::python::addOutputOp(cls, "__repr__");
114  cls.def("asAngularUnits", &Angle::asAngularUnits);
115  cls.def("asRadians", &Angle::asRadians);
116  cls.def("asDegrees", &Angle::asDegrees);
117  cls.def("asHours", &Angle::asHours);
118  cls.def("asArcminutes", &Angle::asArcminutes);
119  cls.def("asArcseconds", &Angle::asArcseconds);
120  cls.def("asMilliarcseconds", &Angle::asMilliarcseconds);
121  cls.def("wrap", &Angle::wrap);
122  cls.def("wrapCtr", &Angle::wrapCtr);
123  cls.def("wrapNear", &Angle::wrapNear);
124  cls.def("separation", &Angle::separation);
125  mod.def("isAngle", isAngle<Angle>);
126  mod.def("isAngle", isAngle<double>);
127  }
128  );
129 
130  wrappers.wrap(
131  [](auto & mod) mutable {
132  mod.attr("PI") = py::float_(PI);
133  mod.attr("TWOPI") = py::float_(TWOPI);
134  mod.attr("HALFPI") = py::float_(HALFPI);
135  mod.attr("ONE_OVER_PI") = py::float_(ONE_OVER_PI);
136  mod.attr("SQRTPI") = py::float_(SQRTPI);
137  mod.attr("INVSQRTPI") = py::float_(INVSQRTPI);
138  mod.attr("ROOT2") = py::float_(ROOT2);
139  mod.def("degToRad", degToRad);
140  mod.def("radToDeg", radToDeg);
141  mod.def("radToArcsec", radToArcsec);
142  mod.def("radToMas", radToMas);
143  mod.def("arcsecToRad", arcsecToRad);
144  mod.def("masToRad", masToRad);
145  }
146  );
147 }
AngleUnit constexpr arcminutes
constant with units of arcminutes
Definition: Angle.h:111
Angle abs(Angle const &a)
Definition: Angle.h:106
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
double constexpr TWOPI
Definition: Angle.h:40
AngleUnit constexpr hours
constant with units of hours
Definition: Angle.h:110
constexpr double radToDeg(double x) noexcept
Definition: Angle.h:52
def wrap(ctrl)
Definition: wrap.py:291
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:108
constexpr double radToArcsec(double x) noexcept
Definition: Angle.h:53
double constexpr ONE_OVER_PI
Definition: Angle.h:42
py::class_< Angle > PyAngle
Definition: _Angle.cc:33
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:109
AngleUnit constexpr arcseconds
constant with units of arcseconds
Definition: Angle.h:112
constexpr double degToRad(double x) noexcept
Definition: Angle.h:51
double const INVSQRTPI
Definition: Angle.h:45
double constexpr HALFPI
Definition: Angle.h:41
constexpr double radToMas(double x) noexcept
Definition: Angle.h:54
double const SQRTPI
Definition: Angle.h:44
ItemVariant const * other
Definition: Schema.cc:56
py::class_< AngleUnit > PyAngleUnit
Definition: _Angle.cc:34
lsst::geom::Angle Angle
Definition: misc.h:33
AngleUnit constexpr milliarcseconds
constant with units of milliarcseconds
Definition: Angle.h:115
constexpr double masToRad(double x) noexcept
Definition: Angle.h:56
constexpr double arcsecToRad(double x) noexcept
Definition: Angle.h:55
double constexpr ROOT2
Definition: Angle.h:46
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

◆ wrapBox()

void lsst::geom::wrapBox ( utils::python::WrapperCollection wrappers)

Definition at line 34 of file _Box.cc.

34  {
35  wrappers.wrapType(
36  py::class_<Box2I, std::shared_ptr<Box2I>>(wrappers.module, "Box2I"),
37  [](auto & mod, auto & cls) mutable {
38 
39  cls.attr("Point") = mod.attr("Point2I");
40  cls.attr("Extent") = mod.attr("Extent2I");
41 
42  py::enum_<Box2I::EdgeHandlingEnum>(cls, "EdgeHandlingEnum")
43  .value("EXPAND", Box2I::EdgeHandlingEnum::EXPAND)
44  .value("SHRINK", Box2I::EdgeHandlingEnum::SHRINK)
45  .export_values();
46 
47  cls.def(py::init<>());
48  cls.def(py::init<Point2I const &, Point2I const &, bool>(), "minimum"_a, "maximum"_a,
49  "invert"_a = true);
50  cls.def(py::init<Point2I const &, Extent2I const &, bool>(), "corner"_a, "dimensions"_a,
51  "invert"_a = true);
52  cls.def(py::init<Box2D const &, Box2I::EdgeHandlingEnum>(), "other"_a,
53  "edgeHandling"_a = Box2I::EXPAND);
54  cls.def(py::init<Box2I const &>(), "other"_a);
55 
56  cls.def("__eq__", [](Box2I const &self, Box2I const &other) { return self == other; },
57  py::is_operator());
58  cls.def("__ne__", [](Box2I const &self, Box2I const &other) { return self != other; },
59  py::is_operator());
60 
61  cls.def_static("makeCenteredBox", &Box2I::makeCenteredBox, "center"_a, "size"_a);
62  cls.def("swap", &Box2I::swap);
63  cls.def("getMin", &Box2I::getMin);
64  cls.def("getMinX", &Box2I::getMinX);
65  cls.def("getMinY", &Box2I::getMinY);
66  cls.def("getMax", &Box2I::getMax);
67  cls.def("getMaxX", &Box2I::getMaxX);
68  cls.def("getMaxY", &Box2I::getMaxY);
69  cls.def("getBegin", &Box2I::getBegin);
70  cls.def("getBeginX", &Box2I::getBeginX);
71  cls.def("getBeginY", &Box2I::getBeginY);
72  cls.def("getEnd", &Box2I::getEnd);
73  cls.def("getEndX", &Box2I::getEndX);
74  cls.def("getEndY", &Box2I::getEndY);
75  cls.def("getDimensions", &Box2I::getDimensions);
76  cls.def("getWidth", &Box2I::getWidth);
77  cls.def("getHeight", &Box2I::getHeight);
78  cls.def("getArea", &Box2I::getArea);
79  cls.def("getCenter", &Box2I::getCenter);
80  cls.def("getCenterX", &Box2I::getCenterX);
81  cls.def("getCenterY", &Box2I::getCenterY);
82  cls.def("isEmpty", &Box2I::isEmpty);
83  cls.def("contains", (bool (Box2I::*)(Point2I const &) const) & Box2I::contains);
84  cls.def("contains", (bool (Box2I::*)(Box2I const &) const) & Box2I::contains);
85  cls.def("__contains__", (bool (Box2I::*)(Point2I const &) const) & Box2I::contains);
86  cls.def("__contains__", (bool (Box2I::*)(Box2I const &) const) & Box2I::contains);
87  cls.def("overlaps", &Box2I::overlaps);
88  cls.def("grow", (void (Box2I::*)(int)) & Box2I::grow);
89  cls.def("grow", (void (Box2I::*)(Extent2I const &)) & Box2I::grow);
90  cls.def("shift", &Box2I::shift);
91  cls.def("flipLR", &Box2I::flipLR);
92  cls.def("flipTB", &Box2I::flipTB);
93  cls.def("include", (void (Box2I::*)(Point2I const &)) & Box2I::include);
94  cls.def("include", (void (Box2I::*)(Box2I const &)) & Box2I::include);
95  cls.def("clip", &Box2I::clip);
96  cls.def("getCorners", &Box2I::getCorners);
97  cls.def("toString", &Box2I::toString);
98  cls.def("__repr__", [](Box2I const &self) {
99  return py::str("Box2I(minimum={}, dimensions={})")
100  .format(py::repr(py::cast(self.getMin())), py::repr(py::cast(self.getDimensions())));
101  });
102  cls.def("__str__", [](Box2I const &self) {
103  return py::str("(minimum={}, maximum={})")
104  .format(py::str(py::cast(self.getMin())), py::str(py::cast(self.getMax())));
105  });
106  cls.def("__reduce__", [cls](Box2I const &self) {
107  return py::make_tuple(cls, make_tuple(py::cast(self.getMin()), py::cast(self.getMax())));
108  });
109  cls.def("getSlices", [](Box2I const &self) {
110  return py::make_tuple(py::slice(self.getBeginY(), self.getEndY(), 1),
111  py::slice(self.getBeginX(), self.getEndX(), 1));
112  });
113 
114  mod.attr("BoxI") = cls;
115  }
116  );
117 
118  wrappers.wrapType(
119  py::class_<Box2D, std::shared_ptr<Box2D>>(wrappers.module, "Box2D"),
120  [](auto & mod, auto & cls) mutable {
121 
122  cls.attr("Point") = mod.attr("Point2D");
123  cls.attr("Extent") = mod.attr("Extent2D");
124 
125  cls.attr("EPSILON") = py::float_(Box2D::EPSILON);
126  cls.attr("INVALID") = py::float_(Box2D::INVALID);
127 
128  cls.def(py::init<>());
129  cls.def(py::init<Point2D const &, Point2D const &, bool>(), "minimum"_a, "maximum"_a,
130  "invert"_a = true);
131  cls.def(py::init<Point2D const &, Extent2D const &, bool>(), "corner"_a, "dimensions"_a,
132  "invert"_a = true);
133  cls.def(py::init<Box2I const &>());
134  cls.def(py::init<Box2D const &>());
135 
136  cls.def("__eq__", [](Box2D const &self, Box2D const &other) { return self == other; },
137  py::is_operator());
138  cls.def("__ne__", [](Box2D const &self, Box2D const &other) { return self != other; },
139  py::is_operator());
140 
141  cls.def_static("makeCenteredBox", &Box2D::makeCenteredBox, "center"_a, "size"_a);
142  cls.def("swap", &Box2D::swap);
143  cls.def("getMin", &Box2D::getMin);
144  cls.def("getMinX", &Box2D::getMinX);
145  cls.def("getMinY", &Box2D::getMinY);
146  cls.def("getMax", &Box2D::getMax);
147  cls.def("getMaxX", &Box2D::getMaxX);
148  cls.def("getMaxY", &Box2D::getMaxY);
149  cls.def("getDimensions", &Box2D::getDimensions);
150  cls.def("getWidth", &Box2D::getWidth);
151  cls.def("getHeight", &Box2D::getHeight);
152  cls.def("getArea", &Box2D::getArea);
153  cls.def("getCenter", &Box2D::getCenter);
154  cls.def("getCenterX", &Box2D::getCenterX);
155  cls.def("getCenterY", &Box2D::getCenterY);
156  cls.def("isEmpty", &Box2D::isEmpty);
157  cls.def("contains", (bool (Box2D::*)(Point2D const &) const) & Box2D::contains);
158  cls.def("contains", (bool (Box2D::*)(Box2D const &) const) & Box2D::contains);
159  cls.def("__contains__", (bool (Box2D::*)(Point2D const &) const) & Box2D::contains);
160  cls.def("__contains__", (bool (Box2D::*)(Box2D const &) const) & Box2D::contains);
161  cls.def("overlaps", &Box2D::overlaps);
162  cls.def("grow", (void (Box2D::*)(double)) & Box2D::grow);
163  cls.def("grow", (void (Box2D::*)(Extent2D const &)) & Box2D::grow);
164  cls.def("overlaps", (void (Box2D::*)(Extent2D const &)) & Box2D::overlaps);
165  cls.def("shift", &Box2D::shift);
166  cls.def("flipLR", &Box2D::flipLR);
167  cls.def("flipTB", &Box2D::flipTB);
168  cls.def("include", (void (Box2D::*)(Point2D const &)) & Box2D::include);
169  cls.def("include", (void (Box2D::*)(Box2D const &)) & Box2D::include);
170  cls.def("clip", &Box2D::clip);
171  cls.def("getCorners", &Box2D::getCorners);
172  cls.def("toString", &Box2D::toString);
173  cls.def("__repr__", [](Box2D const &self) {
174  return py::str("Box2D(minimum={}, dimensions={})")
175  .format(py::repr(py::cast(self.getMin())), py::repr(py::cast(self.getDimensions())));
176  });
177  cls.def("__str__", [](Box2D const &self) {
178  return py::str("(minimum={}, maximum={})")
179  .format(py::str(py::cast(self.getMin())), py::str(py::cast(self.getMax())));
180  });
181  cls.def("__reduce__", [cls](Box2D const &self) {
182  return py::make_tuple(cls, make_tuple(py::cast(self.getMin()), py::cast(self.getMax())));
183  });
184 
185  mod.attr("BoxD") = cls;
186  }
187  );
188 }
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
T make_tuple(T... args)
Point< double, 2 > Point2D
Definition: Point.h:324
Point< int, 2 > Point2I
Definition: Point.h:321
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition: Image.cc:471
Extent< int, 2 > Extent2I
Definition: Extent.h:397
ItemVariant const * other
Definition: Schema.cc:56
Extent< double, 2 > Extent2D
Definition: Extent.h:400

◆ wrapCoordinates()

void lsst::geom::wrapCoordinates ( utils::python::WrapperCollection wrappers)

Definition at line 471 of file _coordinates.cc.

471  {
472  // Only the interface-level classes are defined here, and these functions
473  // call others to define their base classes, since those are never shared.
474 
475  declareCoordinateExpr<2>(wrappers, "2");
476  declareCoordinateExpr<3>(wrappers, "3");
477 
478  auto clsExtent2I = declareExtent2<int>(wrappers, "I");
479  auto clsExtent2D = declareExtent2<double>(wrappers, "D");
480 
481  auto clsExtent3I = declareExtent3<int>(wrappers, "I");
482  auto clsExtent3D = declareExtent3<double>(wrappers, "D");
483 
484  auto clsPoint2I = declarePoint2<int>(wrappers, "I");
485  auto clsPoint2D = declarePoint2<double>(wrappers, "D");
486 
487  auto clsPoint3I = declarePoint3<int>(wrappers, "I");
488  auto clsPoint3D = declarePoint3<double>(wrappers, "D");
489 
490  declareExtentOperators(wrappers, clsExtent2I, clsExtent2D);
491  declareExtentOperators(wrappers, clsExtent3I, clsExtent3D);
492  declarePointOperators(wrappers, clsPoint2I, clsPoint2D);
493  declarePointOperators(wrappers, clsPoint3I, clsPoint3D);
494 
495 }

◆ wrapLinearTransform()

void lsst::geom::wrapLinearTransform ( WrapperCollection wrappers)

Definition at line 40 of file _LinearTransform.cc.

40  {
41  wrappers.wrapType(
42  py::class_<LinearTransform, std::shared_ptr<LinearTransform>>(wrappers.module, "LinearTransform"),
43  [](auto & mod, auto & cls) {
44 
45  // Parameters enum is really only used as integer constants.
46  cls.attr("XX") = py::cast(int(LinearTransform::Parameters::XX));
47  cls.attr("YX") = py::cast(int(LinearTransform::Parameters::YX));
48  cls.attr("XY") = py::cast(int(LinearTransform::Parameters::XY));
49  cls.attr("YY") = py::cast(int(LinearTransform::Parameters::YY));
50 
51  /* Constructors */
52  cls.def(py::init<>());
53  cls.def(py::init<LinearTransform::Matrix const &>(), "matrix"_a);
54 
55  /* Operators */
56  cls.def("__call__",
57  py::overload_cast<Point2D const &>(&LinearTransform::operator(), py::const_));
58  cls.def("__call__",
59  py::overload_cast<Extent2D const &>(&LinearTransform::operator(), py::const_));
60  cls.def("__getitem__",
61  [](LinearTransform const &self, int i) { return self[utils::python::cppIndex(4, i)]; });
62  cls.def("__getitem__", [](LinearTransform const &self, std::pair<int, int> i) {
63  auto row = utils::python::cppIndex(2, i.first);
64  auto col = utils::python::cppIndex(2, i.second);
65  return self.getMatrix()(row, col);
66  });
67  cls.def("__mul__", &LinearTransform::operator*, py::is_operator());
68  cls.def("__add__", &LinearTransform::operator+, py::is_operator());
69  cls.def("__sub__", &LinearTransform::operator-, py::is_operator());
70  cls.def("__iadd__", &LinearTransform::operator+=);
71  cls.def("__isub__", &LinearTransform::operator-=);
72 
73  /* Members */
74  cls.def_static("makeScaling",
75  py::overload_cast<double>(&LinearTransform::makeScaling),
76  "scale"_a);
77  cls.def_static("makeScaling",
78  py::overload_cast<double, double>(&LinearTransform::makeScaling));
79  cls.def_static("makeRotation",
80  py::overload_cast<Angle>(LinearTransform::makeRotation),
81  "angle"_a);
82  cls.def("getParameterVector", &LinearTransform::getParameterVector);
83  cls.def("getMatrix",
84  py::overload_cast<>(& LinearTransform::getMatrix, py::const_));
85  cls.def("inverted", &LinearTransform::inverted);
86  cls.def("computeDeterminant", &LinearTransform::computeDeterminant);
87  cls.def("isIdentity", &LinearTransform::isIdentity);
88 
89  cls.def("set",
90  [](LinearTransform &self, double xx, double yx, double xy, double yy) {
91  self[LinearTransform::XX] = xx;
92  self[LinearTransform::XY] = xy;
93  self[LinearTransform::YX] = yx;
94  self[LinearTransform::YY] = yy;
95  },
96  "xx"_a, "yx"_a, "xy"_a, "yy"_a);
97 
98  cls.def("__str__", [](LinearTransform const &self) {
99  return py::str(py::cast(self.getMatrix()));
100  });
101  cls.def("__repr__", [](LinearTransform const &self) {
102  return py::str("LinearTransform(\n{}\n)").format(py::cast(self.getMatrix()));
103  });
104  cls.def("__reduce__", [cls](LinearTransform const &self) {
105  return py::make_tuple(cls, py::make_tuple(py::cast(self.getMatrix())));
106  });
107  }
108  );
109 }
int col
Definition: CR.cc:144
std::size_t cppIndex(std::ptrdiff_t size, std::ptrdiff_t i)
Compute a C++ index from a Python index (negative values count from the end) and range-check.
Definition: python.h:124
int row
Definition: CR.cc:145

◆ wrapSpherePoint()

void lsst::geom::wrapSpherePoint ( WrapperCollection wrappers)

Definition at line 43 of file _SpherePoint.cc.

43  {
44  wrappers.addSignatureDependency("lsst.sphgeom");
45  wrappers.wrapType(
46  PySpherePoint(wrappers.module, "SpherePoint"),
47  [](auto & mod, auto & cls) mutable {
48  /* Constructors */
49  cls.def(py::init<>());
50  cls.def(py::init<Angle const &, Angle const &>(), "longitude"_a, "latitude"_a);
51  cls.def(py::init<double, double, AngleUnit>(), "longitude"_a, "latitude"_a, "units"_a);
52  cls.def(py::init<sphgeom::Vector3d const &>(), "vector"_a);
53  cls.def(py::init<sphgeom::UnitVector3d const &>(), "unitVector"_a);
54  cls.def(py::init<sphgeom::LonLat const &>(), "lonLat"_a);
55  cls.def(py::init<SpherePoint const &>(), "other"_a);
56  py::implicitly_convertible<SpherePoint, sphgeom::LonLat>();
57  py::implicitly_convertible<sphgeom::LonLat, SpherePoint>();
58 
59  /* Operators */
60  cls.def("__getitem__",
61  [](SpherePoint const &self, std::ptrdiff_t i) {
62  return self[utils::python::cppIndex(2, i)];
63  });
64  cls.def("__eq__", &SpherePoint::operator==, py::is_operator());
65  cls.def("__ne__", &SpherePoint::operator!=, py::is_operator());
66 
67  /* Members */
68  cls.def("getLongitude", &SpherePoint::getLongitude);
69  cls.def("getLatitude", &SpherePoint::getLatitude);
70  cls.def("getRa", &SpherePoint::getRa);
71  cls.def("getDec", &SpherePoint::getDec);
72  cls.def("getVector", &SpherePoint::getVector);
73  cls.def("getPosition", &SpherePoint::getPosition, "units"_a);
74  cls.def("atPole", &SpherePoint::atPole);
75  cls.def("isFinite", &SpherePoint::isFinite);
76  cls.def("bearingTo", &SpherePoint::bearingTo, "other"_a);
77  cls.def("separation", &SpherePoint::separation, "other"_a);
78  cls.def("rotated", &SpherePoint::rotated, "axis"_a, "amount"_a);
79  cls.def("offset", &SpherePoint::offset, "bearing"_a, "amount"_a);
80  cls.def("getTangentPlaneOffset", &SpherePoint::getTangentPlaneOffset, "other"_a);
81  utils::python::addOutputOp(cls, "__str__");
82  cls.def("__len__", [](SpherePoint const &) { return 2; });
83  cls.def("__reduce__", [cls](SpherePoint const &self) {
84  return py::make_tuple(cls, py::make_tuple(py::cast(self.getLongitude()),
85  py::cast(self.getLatitude())));
86  });
87 
88  /* Module level */
89  mod.def("averageSpherePoint", averageSpherePoint);
90  }
91  );
92 }
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
py::class_< SpherePoint, std::shared_ptr< SpherePoint > > PySpherePoint
Definition: _SpherePoint.cc:41
lsst::geom::SpherePoint SpherePoint
Definition: misc.h:35
SpherePoint averageSpherePoint(std::vector< SpherePoint > const &coords)
Return the average of a list of coordinates.
Definition: SpherePoint.cc:235

Variable Documentation

◆ arcminutes

AngleUnit constexpr lsst::geom::arcminutes = AngleUnit(PI / 60 / 180.0)

constant with units of arcminutes

Definition at line 111 of file Angle.h.

◆ arcseconds

AngleUnit constexpr lsst::geom::arcseconds = AngleUnit(PI / 180.0 / 3600.0)

constant with units of arcseconds

Definition at line 112 of file Angle.h.

◆ degrees

AngleUnit constexpr lsst::geom::degrees = AngleUnit(PI / 180.0)

constant with units of degrees

Definition at line 109 of file Angle.h.

◆ HALFPI

double constexpr lsst::geom::HALFPI = boost::math::constants::pi<double>() * 0.5

Definition at line 41 of file Angle.h.

◆ hours

AngleUnit constexpr lsst::geom::hours = AngleUnit(PI * 15.0 / 180.0)

constant with units of hours

Definition at line 110 of file Angle.h.

◆ INVSQRTPI

double const lsst::geom::INVSQRTPI = 1.0 / sqrt(boost::math::constants::pi<double>())

Definition at line 45 of file Angle.h.

◆ IS_NOTHROW_CONVERTIBLE

template<typename T , typename U >
bool constexpr lsst::geom::IS_NOTHROW_CONVERTIBLE
Initial value:

Test that a type is nothrow-copy-convertible from U to T.

Definition at line 45 of file CoordinateBase.h.

◆ milliarcseconds

AngleUnit constexpr lsst::geom::milliarcseconds
Initial value:
=
AngleUnit(PI / (180.0 * 3.6e6))
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:39

constant with units of milliarcseconds

Definition at line 115 of file Angle.h.

◆ ONE_OVER_PI

double constexpr lsst::geom::ONE_OVER_PI = 1.0 / boost::math::constants::pi<double>()

Definition at line 42 of file Angle.h.

◆ PI

double constexpr lsst::geom::PI = boost::math::constants::pi<double>()

The ratio of a circle's circumference to diameter.

Definition at line 39 of file Angle.h.

◆ radians

AngleUnit constexpr lsst::geom::radians = AngleUnit(1.0)

constant with units of radians

Definition at line 108 of file Angle.h.

◆ ROOT2

double constexpr lsst::geom::ROOT2 = boost::math::constants::root_two<double>()

Definition at line 46 of file Angle.h.

◆ SQRTPI

double const lsst::geom::SQRTPI = sqrt(boost::math::constants::pi<double>())

Definition at line 44 of file Angle.h.

◆ TWOPI

double constexpr lsst::geom::TWOPI = boost::math::constants::pi<double>() * 2.0

Definition at line 40 of file Angle.h.