LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Namespaces | Classes | Typedefs | Functions | Variables
lsst::geom Namespace Reference

Namespaces

namespace  _Angle
 
namespace  _Box
 
namespace  _coordinates
 
namespace  _Interval
 
namespace  _SpherePoint
 
namespace  detail
 
namespace  polynomials
 Low-level polynomials (including special polynomials) in C++.
 
namespace  testUtils
 
namespace  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  IntervalD
 A floating-point coordinate rectangle geometry. More...
 
class  IntervalI
 A 1-d integer coordinate range. More...
 
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 a, double d) noexcept
 Product of an angle and a scalar. More...
 
constexpr Angle operator* (double d, Angle a) noexcept
 
constexpr Angle operator* (Angle a, int d) noexcept
 
constexpr Angle operator* (int d, Angle a) noexcept
 
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, IntervalI const &interval)
 
std::ostreamoperator<< (std::ostream &os, IntervalD const &interval)
 
void swap (IntervalI &a, IntervalI &b) noexcept
 
void swap (IntervalD &a, IntervalD &b) 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 wrapAngle (WrapperCollection &wrappers)
 
void wrapCoordinates (WrapperCollection &wrappers)
 
void wrapSpherePoint (WrapperCollection &wrappers)
 
void wrapInterval (WrapperCollection &wrappers)
 
void wrapBox (WrapperCollection &wrappers)
 
void wrapLinearTransform (WrapperCollection &wrappers)
 
void wrapAffineTransform (WrapperCollection &wrappers)
 
 PYBIND11_MODULE (_geom, mod)
 
void wrapInterval (utils::python::WrapperCollection &wrappers)
 
void wrapLinearTransform (utils::python::WrapperCollection &wrappers)
 
void wrapSpherePoint (utils::python::WrapperCollection &wrappers)
 
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)
 

Variables

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

Typedef Documentation

◆ BoxD

Definition at line 779 of file Box.h.

◆ BoxI

Definition at line 780 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

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 60 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}
table::Key< int > b
table::Key< int > a
Angle abs(Angle const &a)
Definition: Angle.h:106

◆ 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)
inlineconstexprnoexcept

Definition at line 56 of file Angle.h.

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

◆ 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}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
Vector3d is a vector in ℝ³ with components stored in double precision.
Definition: Vector3d.h:44
lsst::geom::SpherePoint SpherePoint
Definition: misc.h:34
T size(T... args)

◆ 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 {
120 for (int i = 0; i < N; ++i) {
121 result[i] = std::ceil(input[i]);
122 }
123 return result;
124}
py::object result
Definition: _schema.cc:429
T ceil(T... args)
A coordinate class intended to represent offsets and dimensions.
Definition: Extent.h:210

◆ degToRad()

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

Definition at line 52 of file Angle.h.

52{ return x * PI / 180.; }

◆ 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 {
111 for (int i = 0; i < N; ++i) {
112 result[i] = std::floor(input[i]);
113 }
114 return result;
115}
T floor(T... args)

◆ hash_value() [1/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}
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 ( 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}

◆ isAngle()

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

Allow a user to check if they have an angle.

Definition at line 387 of file Angle.h.

◆ 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:48
An affine coordinate transformation consisting of a linear transformation and an offset.

◆ masToRad()

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

Definition at line 57 of file Angle.h.

57{ return (x / (1000. * 3600.)) * PI / 180.; }

◆ operator*() [1/9]

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

Product of two angles.

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

Definition at line 329 of file Angle.h.

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

◆ operator*() [2/9]

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

Product of an angle and a scalar.

Definition at line 336 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator*() [3/9]

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

Definition at line 337 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator*() [4/9]

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

Definition at line 336 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator*() [5/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*() [6/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*() [7/9]

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

Definition at line 337 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator*() [8/9]

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

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 402 of file Angle.h.

402 {
403 static_assert(std::is_arithmetic<T>::value,
404 "Only numeric types may be multiplied by an AngleUnit to create an Angle!");
405 return Angle(lhs * rhs._val);
406}

◆ operator*() [9/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*=()

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 
)
inlineconstexprnoexcept

Sum of two angles.

Definition at line 315 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator+() [2/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+() [3/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+() [4/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}
A coordinate class intended to represent absolute positions.
Definition: Point.h:169

◆ operator+() [5/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+() [6/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+=() [1/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+=() [2/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-() [1/8]

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

Difference of two angles.

Definition at line 321 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator-() [2/8]

constexpr Angle operator- ( Angle  angle)
inlineconstexpr

An angle in the opposite sense.

Definition at line 348 of file Angle.h.

348{ return Angle(-static_cast<double>(angle)); }

◆ operator-() [3/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-() [4/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-() [5/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-() [6/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-() [7/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-() [8/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-=() [1/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-=() [2/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/() [1/4]

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

Ratio of an angle and a scalar.

Definition at line 363 of file Angle.h.

363{ return Angle(static_cast<double>(a) / d); }

◆ operator/() [2/4]

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

Ratio of an angle and a scalar.

Definition at line 356 of file Angle.h.

356{ return Angle(static_cast<double>(a) / d); }

◆ operator/() [3/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/() [4/4]

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

◆ 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/9]

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

Definition at line 510 of file Box.cc.

510 {
511 if (box.isEmpty()) return os << "Box2D()";
512 return os << "Box2D(Point2D" << box.getMin() << ", Extent2D" << box.getDimensions() << ")";
513}
std::ostream * os
Definition: Schema.cc:557

◆ operator<<() [2/9]

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

Definition at line 505 of file Box.cc.

505 {
506 if (box.isEmpty()) return os << "Box2I()";
507 return os << "Box2I(Point2I" << box.getMin() << ", Extent2I" << box.getDimensions() << ")";
508}

◆ operator<<() [3/9]

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<<() [4/9]

std::ostream & lsst::geom::operator<< ( std::ostream os,
IntervalD const &  interval 
)

Definition at line 375 of file Interval.cc.

375 {
376 if (interval.isEmpty()) return os << "IntervalD()";
377 return os << "IntervalD" << interval.toString();
378}

◆ operator<<() [5/9]

std::ostream & lsst::geom::operator<< ( std::ostream os,
IntervalI const &  interval 
)

Definition at line 370 of file Interval.cc.

370 {
371 if (interval.isEmpty()) return os << "IntervalI()";
372 return os << "IntervalI" << interval.toString();
373}

◆ operator<<() [6/9]

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}
table::Key< int > transform
T flags(T... args)
T precision(T... args)
T setf(T... args)
T setw(T... args)

◆ operator<<() [7/9]

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}

◆ operator<<() [8/9]

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 set ostream states here.
255 auto oldFlags = os.setf(ostream::fixed);
256 // 10 digits of precision for a value in degrees is about 1 milliarcsecond
257 auto oldPrecision = os.precision(10);
258
259 os << "(" << point.getLongitude().asDegrees() << ", ";
260 os.setf(ostream::showpos);
261 os << point.getLatitude().asDegrees() << ")";
262
263 os.flags(oldFlags);
264 os.precision(oldPrecision);
265 return os;
266}

◆ operator<<() [9/9]

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"; }

◆ PYBIND11_MODULE()

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

Definition at line 43 of file _geom.cc.

43 {
44 WrapperCollection w(mod, "lsst.geom");
45 wrapAngle(w);
49 wrapBox(w);
52 w.finish();
53}
void wrapCoordinates(WrapperCollection &wrappers)
void wrapAffineTransform(WrapperCollection &wrappers)
void wrapInterval(WrapperCollection &wrappers)
void wrapBox(WrapperCollection &wrappers)
void wrapSpherePoint(WrapperCollection &wrappers)
void wrapAngle(WrapperCollection &wrappers)
void wrapLinearTransform(WrapperCollection &wrappers)
double w
Definition: CoaddPsf.cc:69

◆ radToArcsec()

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

Definition at line 54 of file Angle.h.

54{ return x * 3600. * 180. / PI; }

◆ radToDeg()

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

Definition at line 53 of file Angle.h.

53{ return x * 180. / PI; }

◆ radToMas()

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

Definition at line 55 of file Angle.h.

55{ return x * 1000. * 3600. * 180. / PI; }

◆ swap() [1/2]

void lsst::geom::swap ( IntervalD a,
IntervalD b 
)
inlinenoexcept

Definition at line 736 of file Interval.h.

736{ a.swap(b); }

◆ swap() [2/2]

void lsst::geom::swap ( IntervalI a,
IntervalI b 
)
inlinenoexcept

Definition at line 734 of file Interval.h.

734{ a.swap(b); }

◆ 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 {
102 for (int i = 0; i < N; ++i) {
103 result[i] = static_cast<int>(input[i]);
104 }
105 return result;
106}

◆ wrapAffineTransform() [1/2]

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("__call__",
68 // We use pybind11's wrappers for the Python C API to
69 // delegate to other wrapped methods because:
70 // - defining this in pure Python is tricky because it's
71 // an overload, not a standalone method;
72 // - we'd rather not add a new pure-Python file just for
73 // this;
74 // - using py::vectorize internal to the method would
75 // involve defining a new internal callable every time
76 // this method is called.
77 // The other viable alternative would be to define
78 // applyX and applyY as Python callables with py::vectorize
79 // outside the lambda as C++ local variables, and then
80 // capture them by value in the lambda. This just seems
81 // slightly cleaner, as it's closer to how one would
82 // implement this in pure Python, if it wasn't an overload.
83 [](py::object self, py::object x, py::object y) {
84 return py::make_tuple(self.attr("applyX")(x, y),
85 self.attr("applyY")(x, y));
86 },
87 "x"_a, "y"_a);
88 cls.def("__setitem__", [](AffineTransform &self, int i, double value) {
89 if (i < 0 || i > 5) {
90 PyErr_Format(PyExc_IndexError, "Invalid index for AffineTransform: %d", i);
91 throw py::error_already_set();
92 }
93 self[i] = value;
94 });
95 cls.def("__getitem__", [](AffineTransform const &self, int row, int col) {
96 if (row < 0 || row > 2 || col < 0 || col > 2) {
97 PyErr_Format(PyExc_IndexError, "Invalid index for AffineTransform: %d, %d", row, col);
98 throw py::error_already_set();
99 }
100 return (self.getMatrix())(row, col);
101 });
102 cls.def("__getitem__", [](AffineTransform const &self, int i) {
103 if (i < 0 || i > 5) {
104 PyErr_Format(PyExc_IndexError, "Invalid index for AffineTransform: %d", i);
105 throw py::error_already_set();
106 }
107 return self[i];
108 });
109 cls.def("__str__", [](AffineTransform const &self) {
110 return py::str(py::cast(self.getMatrix())); }
111 );
112 cls.def("__repr__", [](AffineTransform const &self) {
113 return py::str("AffineTransform(\n{}\n)").format(py::cast(self.getMatrix()));
114 });
115 cls.def("__reduce__", [cls](AffineTransform const &self) {
116 return py::make_tuple(cls, py::make_tuple(py::cast(self.getMatrix())));
117 });
118
119 /* Members */
120 cls.def("inverted", &AffineTransform::inverted);
121 cls.def("isIdentity", &AffineTransform::isIdentity);
122 cls.def("getTranslation", (Extent2D & (AffineTransform::*)()) & AffineTransform::getTranslation);
123 cls.def("getLinear", (LinearTransform & (AffineTransform::*)()) & AffineTransform::getLinear);
124 cls.def("getMatrix", &AffineTransform::getMatrix);
125 cls.def("getParameterVector", &AffineTransform::getParameterVector);
126 cls.def("setParameterVector", &AffineTransform::setParameterVector);
127 cls.def("applyX", py::vectorize(&AffineTransform::applyX), "x"_a, "y"_a);
128 cls.def("applyY", py::vectorize(&AffineTransform::applyY), "x"_a, "y"_a);
129 cls.def_static("makeScaling", py::overload_cast<double>(&AffineTransform::makeScaling));
130 cls.def_static("makeScaling", py::overload_cast<double, double>(&AffineTransform::makeScaling));
131 cls.def_static("makeRotation", &AffineTransform::makeRotation, "angle"_a);
132 cls.def_static("makeTranslation", &AffineTransform::makeTranslation, "translation"_a);
133
134 /* Non-members */
135 mod.def("makeAffineTransformFromTriple", makeAffineTransformFromTriple);
136 }
137 );
138}
AffineTransform makeAffineTransformFromTriple(Point2D const &p1, Point2D const &p2, Point2D const &p3, Point2D const &q1, Point2D const &q2, Point2D const &q3)
Extent< double, 2 > Extent2D
Definition: Extent.h:400
int row
Definition: CR.cc:145
int col
Definition: CR.cc:144

◆ wrapAffineTransform() [2/2]

void lsst::geom::wrapAffineTransform ( WrapperCollection &  wrappers)

◆ wrapAngle() [1/2]

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 cls.def("__repr__", [](Angle const & self) {
114 if (std::isfinite(self.asDegrees())) {
115 return py::str("Angle({:0.17g}, degrees)").format(self.asDegrees());
116 } else {
117 return py::str("Angle(float('{}'), degrees)").format(self.asDegrees());
118 }
119 });
120 cls.def("asAngularUnits", &Angle::asAngularUnits);
121 cls.def("asRadians", &Angle::asRadians);
122 cls.def("asDegrees", &Angle::asDegrees);
123 cls.def("asHours", &Angle::asHours);
124 cls.def("asArcminutes", &Angle::asArcminutes);
125 cls.def("asArcseconds", &Angle::asArcseconds);
126 cls.def("asMilliarcseconds", &Angle::asMilliarcseconds);
127 cls.def("wrap", &Angle::wrap);
128 cls.def("wrapCtr", &Angle::wrapCtr);
129 cls.def("wrapNear", &Angle::wrapNear);
130 cls.def("separation", &Angle::separation);
131 mod.def("isAngle", isAngle<Angle>);
132 mod.def("isAngle", isAngle<double>);
133 py::implicitly_convertible<Angle, sphgeom::Angle>();
134 py::implicitly_convertible<sphgeom::Angle, Angle>();
135 }
136 );
137
138 wrappers.wrap(
139 [](auto & mod) mutable {
140 mod.attr("PI") = py::float_(PI);
141 mod.attr("TWOPI") = py::float_(TWOPI);
142 mod.attr("HALFPI") = py::float_(HALFPI);
143 mod.attr("ONE_OVER_PI") = py::float_(ONE_OVER_PI);
144 mod.attr("SQRTPI") = py::float_(SQRTPI);
145 mod.attr("INVSQRTPI") = py::float_(INVSQRTPI);
146 mod.attr("ROOT2") = py::float_(ROOT2);
147 mod.def("degToRad", degToRad);
148 mod.def("radToDeg", radToDeg);
149 mod.def("radToArcsec", radToArcsec);
150 mod.def("radToMas", radToMas);
151 mod.def("arcsecToRad", arcsecToRad);
152 mod.def("masToRad", masToRad);
153 }
154 );
155}
A class used to convert scalar POD types such as double to Angle.
Definition: Angle.h:71
T isfinite(T... args)
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:87
double const SQRTPI
Definition: Angle.h:45
constexpr double arcsecToRad(double x) noexcept
Definition: Angle.h:56
double const INVSQRTPI
Definition: Angle.h:46
constexpr double radToMas(double x) noexcept
Definition: Angle.h:55
constexpr AngleUnit arcseconds
constant with units of arcseconds
Definition: Angle.h:113
constexpr double HALFPI
Definition: Angle.h:42
constexpr AngleUnit degrees
constant with units of degrees
Definition: Angle.h:110
constexpr double radToDeg(double x) noexcept
Definition: Angle.h:53
constexpr double masToRad(double x) noexcept
Definition: Angle.h:57
constexpr double radToArcsec(double x) noexcept
Definition: Angle.h:54
constexpr double TWOPI
Definition: Angle.h:41
constexpr AngleUnit hours
constant with units of hours
Definition: Angle.h:111
constexpr AngleUnit milliarcseconds
constant with units of milliarcseconds
Definition: Angle.h:116
py::class_< Angle > PyAngle
Definition: _Angle.cc:33
constexpr double degToRad(double x) noexcept
Definition: Angle.h:52
constexpr double ONE_OVER_PI
Definition: Angle.h:43
constexpr double ROOT2
Definition: Angle.h:47
constexpr AngleUnit radians
constant with units of radians
Definition: Angle.h:109
py::class_< AngleUnit > PyAngleUnit
Definition: _Angle.cc:34
constexpr AngleUnit arcminutes
constant with units of arcminutes
Definition: Angle.h:112
def wrap(ctrl)
Definition: wrap.py:305

◆ wrapAngle() [2/2]

void lsst::geom::wrapAngle ( WrapperCollection &  wrappers)

◆ wrapBox() [1/2]

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

Definition at line 35 of file _Box.cc.

35 {
36 wrappers.wrapType(
37 py::class_<Box2I, std::shared_ptr<Box2I>>(wrappers.module, "Box2I"),
38 [](auto & mod, auto & cls) mutable {
39
40 cls.attr("Point") = mod.attr("Point2I");
41 cls.attr("Extent") = mod.attr("Extent2I");
42
43 py::enum_<Box2I::EdgeHandlingEnum>(cls, "EdgeHandlingEnum")
44 .value("EXPAND", Box2I::EdgeHandlingEnum::EXPAND)
45 .value("SHRINK", Box2I::EdgeHandlingEnum::SHRINK)
46 .export_values();
47
48 cls.def(py::init<>());
49 cls.def(py::init<Point2I const &, Point2I const &, bool>(), "minimum"_a, "maximum"_a,
50 "invert"_a = true);
51 cls.def(py::init<Point2I const &, Extent2I const &, bool>(), "corner"_a, "dimensions"_a,
52 "invert"_a = true);
53 cls.def(py::init<IntervalI const &, IntervalI const &>(), "x"_a, "y"_a);
54 cls.def(py::init<Box2D const &, Box2I::EdgeHandlingEnum>(), "other"_a,
55 "edgeHandling"_a = Box2I::EXPAND);
56 cls.def(py::init<Box2I const &>(), "other"_a);
57
58 cls.def("__eq__", [](Box2I const &self, Box2I const &other) { return self == other; },
59 py::is_operator());
60 cls.def("__ne__", [](Box2I const &self, Box2I const &other) { return self != other; },
61 py::is_operator());
62
63 cls.def_static("makeCenteredBox", &Box2I::makeCenteredBox, "center"_a, "size"_a);
64 cls.def("swap", &Box2I::swap);
65 cls.def("getMin", &Box2I::getMin);
66 cls.def("getMinX", &Box2I::getMinX);
67 cls.def("getMinY", &Box2I::getMinY);
68 cls.def("getMax", &Box2I::getMax);
69 cls.def("getMaxX", &Box2I::getMaxX);
70 cls.def("getMaxY", &Box2I::getMaxY);
71 cls.def_property_readonly("minX", &Box2I::getMinX);
72 cls.def_property_readonly("minY", &Box2I::getMinY);
73 cls.def_property_readonly("maxX", &Box2I::getMaxX);
74 cls.def_property_readonly("maxY", &Box2I::getMaxY);
75 cls.def("getBegin", &Box2I::getBegin);
76 cls.def("getBeginX", &Box2I::getBeginX);
77 cls.def("getBeginY", &Box2I::getBeginY);
78 cls.def("getEnd", &Box2I::getEnd);
79 cls.def("getEndX", &Box2I::getEndX);
80 cls.def("getEndY", &Box2I::getEndY);
81 cls.def_property_readonly("beginX", &Box2I::getBeginX);
82 cls.def_property_readonly("beginY", &Box2I::getBeginY);
83 cls.def_property_readonly("endX", &Box2I::getEndX);
84 cls.def_property_readonly("endY", &Box2I::getEndY);
85 cls.def("getDimensions", &Box2I::getDimensions);
86 cls.def("getWidth", &Box2I::getWidth);
87 cls.def("getHeight", &Box2I::getHeight);
88 cls.def("getArea", &Box2I::getArea);
89 cls.def_property_readonly("width", &Box2I::getWidth);
90 cls.def_property_readonly("height", &Box2I::getHeight);
91 cls.def_property_readonly("area", &Box2I::getArea);
92 cls.def("getCenter", &Box2I::getCenter);
93 cls.def("getCenterX", &Box2I::getCenterX);
94 cls.def("getCenterY", &Box2I::getCenterY);
95 cls.def_property_readonly("centerX", &Box2I::getCenterX);
96 cls.def_property_readonly("centerY", &Box2I::getCenterY);
97 cls.def("getX", &Box2I::getX);
98 cls.def("getY", &Box2I::getY);
99 cls.def_property_readonly("x", &Box2I::getX);
100 cls.def_property_readonly("y", &Box2I::getY);
101 cls.def("isEmpty", &Box2I::isEmpty);
102 cls.def("contains", py::overload_cast<Point2I const &>(&Box2I::contains, py::const_));
103 cls.def("contains", py::overload_cast<Box2I const &>(&Box2I::contains, py::const_));
104 cls.def("contains",
105 py::vectorize(static_cast<bool (Box2I::*)(int x, int y) const>(&Box2I::contains)),
106 "x"_a, "y"_a);
107 cls.def("__contains__", py::overload_cast<Point2I const &>(&Box2I::contains, py::const_));
108 cls.def("__contains__", py::overload_cast<Box2I const &>(&Box2I::contains, py::const_));
109 cls.def("overlaps", &Box2I::overlaps);
110 cls.def("intersects", &Box2I::intersects);
111 cls.def("isDisjointFrom", &Box2I::isDisjointFrom);
112 cls.def("grow", py::overload_cast<int>(&Box2I::grow));
113 cls.def("grow", py::overload_cast<Extent2I const &>(&Box2I::grow));
114 cls.def("shift", &Box2I::shift);
115 cls.def("flipLR", &Box2I::flipLR);
116 cls.def("flipTB", &Box2I::flipTB);
117 cls.def("include", py::overload_cast<Point2I const &>(&Box2I::include));
118 cls.def("include", py::overload_cast<Box2I const &>(&Box2I::include));
119 cls.def("clip", &Box2I::clip);
120 cls.def("dilatedBy", py::overload_cast<int>(&Box2I::dilatedBy, py::const_));
121 cls.def("dilatedBy", py::overload_cast<Extent2I const &>(&Box2I::dilatedBy, py::const_));
122 cls.def("erodedBy", py::overload_cast<int>(&Box2I::erodedBy, py::const_));
123 cls.def("erodedBy", py::overload_cast<Extent2I const &>(&Box2I::erodedBy, py::const_));
124 cls.def("shiftedBy", &Box2I::shiftedBy);
125 cls.def("reflectedAboutX", &Box2I::reflectedAboutX);
126 cls.def("reflectedAboutY", &Box2I::reflectedAboutY);
127 cls.def("expandedTo", py::overload_cast<Point2I const &>(&Box2I::expandedTo, py::const_));
128 cls.def("expandedTo", py::overload_cast<Box2I const &>(&Box2I::expandedTo, py::const_));
129 cls.def("clippedTo", &Box2I::clippedTo);
130 cls.def("getCorners", &Box2I::getCorners);
131 cls.def("toString", &Box2I::toString);
132 cls.def("__repr__", [](Box2I const &self) {
133 return py::str("Box2I(corner={}, dimensions={})")
134 .format(py::repr(py::cast(self.getMin())), py::repr(py::cast(self.getDimensions())));
135 });
136 cls.def("__str__", [](Box2I const &self) {
137 return py::str("(minimum={}, maximum={})")
138 .format(py::str(py::cast(self.getMin())), py::str(py::cast(self.getMax())));
139 });
140 cls.def("__reduce__", [cls](Box2I const &self) {
141 return py::make_tuple(cls, make_tuple(py::cast(self.getMin()), py::cast(self.getMax())));
142 });
143 auto getSlices = [](Box2I const &self) {
144 return py::make_tuple(py::slice(self.getBeginY(), self.getEndY(), 1),
145 py::slice(self.getBeginX(), self.getEndX(), 1));
146 };
147 cls.def("getSlices", getSlices);
148 cls.def_property_readonly("slices", getSlices);
149
150 mod.attr("BoxI") = cls;
151 }
152 );
153
154 wrappers.wrapType(
155 py::class_<Box2D, std::shared_ptr<Box2D>>(wrappers.module, "Box2D"),
156 [](auto & mod, auto & cls) mutable {
157
158 cls.attr("Point") = mod.attr("Point2D");
159 cls.attr("Extent") = mod.attr("Extent2D");
160
161 cls.attr("EPSILON") = py::float_(Box2D::EPSILON);
162 cls.attr("INVALID") = py::float_(Box2D::INVALID);
163
164 cls.def(py::init<>());
165 cls.def(py::init<Point2D const &, Point2D const &, bool>(), "minimum"_a, "maximum"_a,
166 "invert"_a = true);
167 cls.def(py::init<Point2D const &, Extent2D const &, bool>(), "corner"_a, "dimensions"_a,
168 "invert"_a = true);
169 cls.def(py::init<IntervalD const &, IntervalD const &>(), "x"_a, "y"_a);
170 cls.def(py::init<Box2I const &>());
171 cls.def(py::init<Box2D const &>());
172
173 cls.def("__eq__", [](Box2D const &self, Box2D const &other) { return self == other; },
174 py::is_operator());
175 cls.def("__ne__", [](Box2D const &self, Box2D const &other) { return self != other; },
176 py::is_operator());
177
178 cls.def_static("makeCenteredBox", &Box2D::makeCenteredBox, "center"_a, "size"_a);
179 cls.def("swap", &Box2D::swap);
180 cls.def("getMin", &Box2D::getMin);
181 cls.def("getMinX", &Box2D::getMinX);
182 cls.def("getMinY", &Box2D::getMinY);
183 cls.def("getMax", &Box2D::getMax);
184 cls.def("getMaxX", &Box2D::getMaxX);
185 cls.def("getMaxY", &Box2D::getMaxY);
186 cls.def_property_readonly("minX", &Box2D::getMinX);
187 cls.def_property_readonly("minY", &Box2D::getMinY);
188 cls.def_property_readonly("maxX", &Box2D::getMaxX);
189 cls.def_property_readonly("maxY", &Box2D::getMaxY);
190 cls.def("getDimensions", &Box2D::getDimensions);
191 cls.def("getWidth", &Box2D::getWidth);
192 cls.def("getHeight", &Box2D::getHeight);
193 cls.def("getArea", &Box2D::getArea);
194 cls.def_property_readonly("width", &Box2D::getWidth);
195 cls.def_property_readonly("height", &Box2D::getHeight);
196 cls.def_property_readonly("area", &Box2D::getArea);
197 cls.def("getX", &Box2D::getX);
198 cls.def("getY", &Box2D::getY);
199 cls.def_property_readonly("x", &Box2D::getX);
200 cls.def_property_readonly("y", &Box2D::getY);
201 cls.def("getCenter", &Box2D::getCenter);
202 cls.def("getCenterX", &Box2D::getCenterX);
203 cls.def("getCenterY", &Box2D::getCenterY);
204 cls.def_property_readonly("centerX", &Box2D::getCenterX);
205 cls.def_property_readonly("centerY", &Box2D::getCenterY);
206 cls.def("isEmpty", &Box2D::isEmpty);
207 cls.def("contains", py::overload_cast<Point2D const &>(&Box2D::contains, py::const_));
208 cls.def("contains", py::overload_cast<Box2D const &>(&Box2D::contains, py::const_));
209 cls.def("contains",
210 py::vectorize(static_cast<bool (Box2D::*)(double x, double y) const>(&Box2D::contains)),
211 "x"_a, "y"_a);
212 cls.def("__contains__", py::overload_cast<Point2D const &>(&Box2D::contains, py::const_));
213 cls.def("__contains__", py::overload_cast<Box2D const &>(&Box2D::contains, py::const_));
214 cls.def("intersects", &Box2D::intersects);
215 cls.def("isDisjointFrom", &Box2D::isDisjointFrom);
216 cls.def("overlaps", &Box2D::overlaps);
217 cls.def("grow", py::overload_cast<double>(&Box2D::grow));
218 cls.def("grow", py::overload_cast<Extent2D const &>(&Box2D::grow));
219 cls.def("shift", &Box2D::shift);
220 cls.def("flipLR", &Box2D::flipLR);
221 cls.def("flipTB", &Box2D::flipTB);
222 cls.def("include", py::overload_cast<Point2D const &>(&Box2D::include));
223 cls.def("include", py::overload_cast<Box2D const &>(&Box2D::include));
224 cls.def("clip", &Box2D::clip);
225 cls.def("dilatedBy", py::overload_cast<double>(&Box2D::dilatedBy, py::const_));
226 cls.def("dilatedBy", py::overload_cast<Extent2D const &>(&Box2D::dilatedBy, py::const_));
227 cls.def("erodedBy", py::overload_cast<double>(&Box2D::erodedBy, py::const_));
228 cls.def("erodedBy", py::overload_cast<Extent2D const &>(&Box2D::erodedBy, py::const_));
229 cls.def("shiftedBy", &Box2D::shiftedBy);
230 cls.def("reflectedAboutX", &Box2D::reflectedAboutX);
231 cls.def("reflectedAboutY", &Box2D::reflectedAboutY);
232 cls.def("expandedTo", py::overload_cast<Point2D const &>(&Box2D::expandedTo, py::const_));
233 cls.def("expandedTo", py::overload_cast<Box2D const &>(&Box2D::expandedTo, py::const_));
234 cls.def("clippedTo", &Box2D::clippedTo);
235 cls.def("getCorners", &Box2D::getCorners);
236 cls.def("toString", &Box2D::toString);
237 cls.def("__repr__", [](Box2D const &self) {
238 return py::str("Box2D(corner={}, dimensions={})")
239 .format(py::repr(py::cast(self.getMin())), py::repr(py::cast(self.getDimensions())));
240 });
241 cls.def("__str__", [](Box2D const &self) {
242 return py::str("(minimum={}, maximum={})")
243 .format(py::str(py::cast(self.getMin())), py::str(py::cast(self.getMax())));
244 });
245 cls.def("__reduce__", [cls](Box2D const &self) {
246 return py::make_tuple(cls, make_tuple(py::cast(self.getMin()), py::cast(self.getMax())));
247 });
248
249 mod.attr("BoxD") = cls;
250 }
251 );
252}
int y
Definition: SpanSet.cc:48
An integer coordinate rectangle.
Definition: Box.h:55
T make_tuple(T... args)
void swap(CameraSys &a, CameraSys &b)
Definition: CameraSys.h:157
constexpr double EPSILON
Definition: constants.h:54

◆ wrapBox() [2/2]

void lsst::geom::wrapBox ( WrapperCollection &  wrappers)

◆ wrapCoordinates() [1/2]

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

Definition at line 491 of file _coordinates.cc.

491 {
492 // Only the interface-level classes are defined here, and these functions
493 // call others to define their base classes, since those are never shared.
494
495 declareCoordinateExpr<2>(wrappers, "2");
496 declareCoordinateExpr<3>(wrappers, "3");
497
498 auto clsExtent2I = declareExtent2<int>(wrappers, "I");
499 auto clsExtent2D = declareExtent2<double>(wrappers, "D");
500
501 auto clsExtent3I = declareExtent3<int>(wrappers, "I");
502 auto clsExtent3D = declareExtent3<double>(wrappers, "D");
503
504 auto clsPoint2I = declarePoint2<int>(wrappers, "I");
505 auto clsPoint2D = declarePoint2<double>(wrappers, "D");
506
507 auto clsPoint3I = declarePoint3<int>(wrappers, "I");
508 auto clsPoint3D = declarePoint3<double>(wrappers, "D");
509
510 declareExtentOperators(wrappers, clsExtent2I, clsExtent2D);
511 declareExtentOperators(wrappers, clsExtent3I, clsExtent3D);
512 declarePointOperators(wrappers, clsPoint2I, clsPoint2D);
513 declarePointOperators(wrappers, clsPoint3I, clsPoint3D);
514
515}

◆ wrapCoordinates() [2/2]

void lsst::geom::wrapCoordinates ( WrapperCollection &  wrappers)

◆ wrapInterval() [1/2]

void lsst::geom::wrapInterval ( utils::python::WrapperCollection &  wrappers)

Definition at line 105 of file _Interval.cc.

105 {
106 wrappers.wrapType(py::class_<IntervalI, std::shared_ptr<IntervalI>>(wrappers.module, "IntervalI"),
107 [](auto &mod, auto &cls) {
108 py::enum_<IntervalI::EdgeHandlingEnum>(cls, "EdgeHandlingEnum")
109 .value("EXPAND", IntervalI::EdgeHandlingEnum::EXPAND)
110 .value("SHRINK", IntervalI::EdgeHandlingEnum::SHRINK);
111 cls.def(py::init<IntervalD const &, IntervalI::EdgeHandlingEnum>(), "other"_a,
112 "edgeHandling"_a = IntervalI::EdgeHandlingEnum::EXPAND);
113 cls.def("getBegin", &IntervalI::getBegin);
114 cls.def_property_readonly("begin", &IntervalI::getBegin);
115 cls.def("getEnd", &IntervalI::getEnd);
116 cls.def_property_readonly("end", &IntervalI::getEnd);
117 declareCommonIntervalInterface(cls);
118 });
119
120 wrappers.wrapType(py::class_<IntervalD, std::shared_ptr<IntervalD>>(wrappers.module, "IntervalD"),
121 [](auto &mod, auto &cls) {
122 cls.def(py::init<IntervalI const &>());
123 cls.def("getCenter", &IntervalD::getCenter);
124 cls.def_property_readonly("center", &IntervalD::getCenter);
125 cls.def("isFinite", &IntervalD::isFinite);
126 declareCommonIntervalInterface(cls);
127 });
128}
A floating-point coordinate rectangle geometry.
Definition: Interval.h:413
A 1-d integer coordinate range.
Definition: Interval.h:50

◆ wrapInterval() [2/2]

void lsst::geom::wrapInterval ( WrapperCollection &  wrappers)

◆ wrapLinearTransform() [1/2]

void lsst::geom::wrapLinearTransform ( utils::python::WrapperCollection &  wrappers)

Definition at line 41 of file _LinearTransform.cc.

41 {
42 wrappers.wrapType(
43 py::class_<LinearTransform, std::shared_ptr<LinearTransform>>(wrappers.module, "LinearTransform"),
44 [](auto & mod, auto & cls) {
45
46 // Parameters enum is really only used as integer constants.
47 cls.attr("XX") = py::cast(int(LinearTransform::Parameters::XX));
48 cls.attr("YX") = py::cast(int(LinearTransform::Parameters::YX));
49 cls.attr("XY") = py::cast(int(LinearTransform::Parameters::XY));
50 cls.attr("YY") = py::cast(int(LinearTransform::Parameters::YY));
51
52 /* Constructors */
53 cls.def(py::init<>());
54 cls.def(py::init<LinearTransform::Matrix const &>(), "matrix"_a);
55
56 /* Operators */
57 cls.def("__call__",
58 py::overload_cast<Point2D const &>(&LinearTransform::operator(), py::const_));
59 cls.def("__call__",
60 py::overload_cast<Extent2D const &>(&LinearTransform::operator(), py::const_));
61 cls.def("__call__",
62 // We use pybind11's wrappers for the Python C API to
63 // delegate to other wrapped methods because:
64 // - defining this in pure Python is tricky because it's
65 // an overload, not a standalone method;
66 // - we'd rather not add a new pure-Python file just for
67 // this;
68 // - using py::vectorize internal to the method would
69 // involve defining a new internal callable every time
70 // this method is called.
71 // The other viable alternative would be to define
72 // applyX and applyY as Python callables with py::vectorize
73 // outside the lambda as C++ local variables, and then
74 // capture them by value in the lambda. This just seems
75 // slightly cleaner, as it's closer to how one would
76 // implement this in pure Python, if it wasn't an overload.
77 [](py::object self, py::object x, py::object y) {
78 return py::make_tuple(self.attr("applyX")(x, y),
79 self.attr("applyY")(x, y));
80 },
81 "x"_a, "y"_a);
82 cls.def("__getitem__",
83 [](LinearTransform const &self, int i) { return self[utils::python::cppIndex(4, i)]; });
84 cls.def("__getitem__", [](LinearTransform const &self, std::pair<int, int> i) {
85 auto row = utils::python::cppIndex(2, i.first);
86 auto col = utils::python::cppIndex(2, i.second);
87 return self.getMatrix()(row, col);
88 });
89 cls.def("__mul__", &LinearTransform::operator*, py::is_operator());
90 cls.def("__add__", &LinearTransform::operator+, py::is_operator());
91 cls.def("__sub__", &LinearTransform::operator-, py::is_operator());
92 cls.def("__iadd__", &LinearTransform::operator+=);
93 cls.def("__isub__", &LinearTransform::operator-=);
94
95 /* Members */
96 cls.def_static("makeScaling",
97 py::overload_cast<double>(&LinearTransform::makeScaling),
98 "scale"_a);
99 cls.def_static("makeScaling",
100 py::overload_cast<double, double>(&LinearTransform::makeScaling));
101 cls.def_static("makeRotation",
102 py::overload_cast<Angle>(LinearTransform::makeRotation),
103 "angle"_a);
104 cls.def("getParameterVector", &LinearTransform::getParameterVector);
105 cls.def("getMatrix",
106 py::overload_cast<>(& LinearTransform::getMatrix, py::const_));
107 cls.def("inverted", &LinearTransform::inverted);
108 cls.def("computeDeterminant", &LinearTransform::computeDeterminant);
109 cls.def("isIdentity", &LinearTransform::isIdentity);
110 cls.def("applyX", py::vectorize(&LinearTransform::applyX), "x"_a, "y"_a);
111 cls.def("applyY", py::vectorize(&LinearTransform::applyY), "x"_a, "y"_a);
112
113 cls.def("set",
114 [](LinearTransform &self, double xx, double yx, double xy, double yy) {
115 self[LinearTransform::XX] = xx;
116 self[LinearTransform::XY] = xy;
117 self[LinearTransform::YX] = yx;
118 self[LinearTransform::YY] = yy;
119 },
120 "xx"_a, "yx"_a, "xy"_a, "yy"_a);
121
122 cls.def("__str__", [](LinearTransform const &self) {
123 return py::str(py::cast(self.getMatrix()));
124 });
125 cls.def("__repr__", [](LinearTransform const &self) {
126 return py::str("LinearTransform(\n{}\n)").format(py::cast(self.getMatrix()));
127 });
128 cls.def("__reduce__", [cls](LinearTransform const &self) {
129 return py::make_tuple(cls, py::make_tuple(py::cast(self.getMatrix())));
130 });
131 }
132 );
133}
A 2D linear coordinate transformation.
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

◆ wrapLinearTransform() [2/2]

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

◆ wrapSpherePoint() [1/2]

void lsst::geom::wrapSpherePoint ( utils::python::WrapperCollection &  wrappers)

Definition at line 62 of file _SpherePoint.cc.

62 {
63 wrappers.addSignatureDependency("lsst.sphgeom");
64 wrappers.wrapType(
65 PySpherePoint(wrappers.module, "SpherePoint"),
66 [](auto & mod, auto & cls) mutable {
67 /* Constructors */
68 cls.def(py::init<>());
69 cls.def(py::init<Angle const &, Angle const &>(), "longitude"_a, "latitude"_a);
70 cls.def(py::init<double, double, AngleUnit>(), "longitude"_a, "latitude"_a, "units"_a);
71 cls.def(py::init<sphgeom::Vector3d const &>(), "vector"_a);
72 cls.def(py::init<sphgeom::UnitVector3d const &>(), "unitVector"_a);
73 cls.def(py::init<sphgeom::LonLat const &>(), "lonLat"_a);
74 cls.def(py::init<SpherePoint const &>(), "other"_a);
75 py::implicitly_convertible<SpherePoint, sphgeom::LonLat>();
76 py::implicitly_convertible<sphgeom::LonLat, SpherePoint>();
77
78 /* Operators */
79 cls.def("__getitem__",
80 [](SpherePoint const &self, std::ptrdiff_t i) {
81 return self[utils::python::cppIndex(2, i)];
82 });
83 cls.def("__eq__", &SpherePoint::operator==, py::is_operator());
84 cls.def("__ne__", &SpherePoint::operator!=, py::is_operator());
85
86 /* Members */
87 cls.def("getLongitude", &SpherePoint::getLongitude);
88 cls.def("getLatitude", &SpherePoint::getLatitude);
89 cls.def("getRa", &SpherePoint::getRa);
90 cls.def("getDec", &SpherePoint::getDec);
91 cls.def("getVector", &SpherePoint::getVector);
92 cls.def("getPosition", &SpherePoint::getPosition, "units"_a);
93 cls.def("atPole", &SpherePoint::atPole);
94 cls.def("isFinite", &SpherePoint::isFinite);
95 cls.def("bearingTo", &SpherePoint::bearingTo, "other"_a);
96 cls.def("separation", &SpherePoint::separation, "other"_a);
97 cls.def("rotated", &SpherePoint::rotated, "axis"_a, "amount"_a);
98 cls.def("offset", &SpherePoint::offset, "bearing"_a, "amount"_a);
99 cls.def("getTangentPlaneOffset", &SpherePoint::getTangentPlaneOffset, "other"_a);
100 utils::python::addOutputOp(cls, "__str__");
101 cls.def("__len__", [](SpherePoint const &) { return 2; });
102 cls.def("__reduce__", [cls](SpherePoint const &self) {
103 return py::make_tuple(cls, py::make_tuple(py::cast(self.getLongitude()),
104 py::cast(self.getLatitude())));
105 });
106
107
108 /* Module level */
109 mod.def("averageSpherePoint", averageSpherePoint);
110
111 // Used only by pure-Python extension toUnitXYZ in _SpherePoint.py.
112 mod.def("_toUnitX", py::vectorize(&toUnitX), "longitude"_a, "latitude"_a);
113 mod.def("_toUnitY", py::vectorize(&toUnitY), "longitude"_a, "latitude"_a);
114 mod.def("_toUnitZ", py::vectorize(&toUnitZ), "longitude"_a, "latitude"_a);
115 }
116 );
117}
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
SpherePoint averageSpherePoint(std::vector< SpherePoint > const &coords)
Return the average of a list of coordinates.
Definition: SpherePoint.cc:235
py::class_< SpherePoint, std::shared_ptr< SpherePoint > > PySpherePoint
Definition: _SpherePoint.cc:60

◆ wrapSpherePoint() [2/2]

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

Variable Documentation

◆ arcminutes

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

constant with units of arcminutes

Definition at line 112 of file Angle.h.

◆ arcseconds

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

constant with units of arcseconds

Definition at line 113 of file Angle.h.

◆ degrees

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

constant with units of degrees

Definition at line 110 of file Angle.h.

◆ HALFPI

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

Definition at line 42 of file Angle.h.

◆ hours

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

constant with units of hours

Definition at line 111 of file Angle.h.

◆ INVSQRTPI

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

Definition at line 46 of file Angle.h.

◆ IS_NOTHROW_CONVERTIBLE

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

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

Definition at line 45 of file CoordinateBase.h.

◆ milliarcseconds

constexpr AngleUnit lsst::geom::milliarcseconds
constexpr
Initial value:
=
AngleUnit(PI / (180.0 * 3.6e6))

constant with units of milliarcseconds

Definition at line 116 of file Angle.h.

◆ ONE_OVER_PI

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

Definition at line 43 of file Angle.h.

◆ PI

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

The ratio of a circle's circumference to diameter.

Definition at line 40 of file Angle.h.

◆ radians

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

constant with units of radians

Definition at line 109 of file Angle.h.

◆ ROOT2

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

Definition at line 47 of file Angle.h.

◆ SQRTPI

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

Definition at line 45 of file Angle.h.

◆ TWOPI

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

Definition at line 41 of file Angle.h.