22#include "pybind11/pybind11.h"
23#include "pybind11/stl.h"
24#include "pybind11/numpy.h"
38using namespace py::literals;
60using PySpherePoint = py::class_<SpherePoint, std::shared_ptr<SpherePoint>>;
63 wrappers.addSignatureDependency(
"lsst.sphgeom");
66 [](
auto & mod,
auto & cls)
mutable {
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>();
79 cls.def(
"__getitem__",
80 [](SpherePoint const &self, std::ptrdiff_t i) {
81 return self[utils::python::cppIndex(2, i)];
83 cls.def(
"__eq__", &SpherePoint::operator==, py::is_operator());
84 cls.def(
"__ne__", &SpherePoint::operator!=, py::is_operator());
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()),
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);
This file contains a class representing spherical coordinates.
This file declares a class for representing unit vectors in ℝ³.
This file declares a class for representing vectors in ℝ³.
table::Key< lsst::geom::Angle > longitude
table::Key< lsst::geom::Angle > latitude
Point in an unspecified spherical coordinate system.
std::pair< Angle, Angle > getTangentPlaneOffset(SpherePoint const &other) const
Get the offset from a tangent plane centered at this point to another point.
SpherePoint offset(Angle const &bearing, Angle const &amount) const
Return a point offset from this one along a great circle.
bool isFinite() const noexcept
true if this point is a well-defined position.
Point2D getPosition(AngleUnit unit) const noexcept
Return longitude, latitude as a Point2D object.
Angle bearingTo(SpherePoint const &other) const
Orientation at this point of the great circle arc to another point.
bool atPole() const noexcept
true if this point is either coordinate pole.
Angle separation(SpherePoint const &other) const noexcept
Angular distance between two points.
sphgeom::UnitVector3d getVector() const noexcept
A unit vector representation of this point.
Angle getLatitude() const noexcept
The latitude of this point.
Angle getLongitude() const noexcept
The longitude of this point.
SpherePoint rotated(SpherePoint const &axis, Angle const &amount) const noexcept
Return a point rotated from this one around an axis.
Angle getDec() const noexcept
Synonym for getLatitude.
Angle getRa() const noexcept
Synonym for getLongitude.
SpherePoint averageSpherePoint(std::vector< SpherePoint > const &coords)
Return the average of a list of coordinates.
void wrapSpherePoint(WrapperCollection &wrappers)
py::class_< SpherePoint, std::shared_ptr< SpherePoint > > PySpherePoint