22 #include "pybind11/pybind11.h" 23 #include "pybind11/stl.h" 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())));
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
py::class_< SpherePoint, std::shared_ptr< SpherePoint > > PySpherePoint
void wrapSpherePoint(WrapperCollection &wrappers)
This file declares a class for representing vectors in ℝ³.
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
This file declares a class for representing unit vectors in ℝ³.
void addSignatureDependency(std::string const &name)
Indicate an external module that provides a type used in function/method signatures.
A base class for image defects.
Point in an unspecified spherical coordinate system.
A helper class for subdividing pybind11 module across multiple translation units (i.e.
This file contains a class representing spherical coordinates.
SpherePoint averageSpherePoint(std::vector< SpherePoint > const &coords)
Return the average of a list of coordinates.
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...