22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
36 using namespace py::literals;
41 using PySpherePoint = py::class_<SpherePoint, std::shared_ptr<SpherePoint>>;
47 [](
auto & mod,
auto &
cls)
mutable {
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>();
60 cls.def(
"__getitem__",
61 [](SpherePoint const &self, std::ptrdiff_t i) {
62 return self[utils::python::cppIndex(2, i)];
64 cls.def(
"__eq__", &SpherePoint::operator==, py::is_operator());
65 cls.def(
"__ne__", &SpherePoint::operator!=, py::is_operator());
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);
84 return py::make_tuple(
cls, py::make_tuple(py::cast(
self.getLongitude()),
85 py::cast(
self.getLatitude())));