From 40da8bf72f48833654d9f78574e97415109000be Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 20 May 2018 19:20:09 -0400 Subject: [PATCH] Added length() for point and dpoint in the Python API. --- tools/python/src/vector.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/python/src/vector.cpp b/tools/python/src/vector.cpp index d96fae380..dd1adb4f4 100644 --- a/tools/python/src/vector.cpp +++ b/tools/python/src/vector.cpp @@ -216,4 +216,9 @@ void bind_vector(py::module& m) .def("extend", extend_vector_with_python_list) .def(py::pickle(&getstate, &setstate)); } + + m.def("length", [](const point& p){return length(p); }, + "returns the distance from p to the origin, i.e. the L2 norm of p.", py::arg("p")); + m.def("length", [](const dpoint& p){return length(p); }, + "returns the distance from p to the origin, i.e. the L2 norm of p.", py::arg("p")); }