From a882476c25a3a341fe1a2ea27d44f67d374c2275 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 17 Jul 2013 16:41:09 +0200 Subject: [PATCH] Add distanceToPoint to VectorPy --- src/Base/VectorPy.xml | 8 ++++++++ src/Base/VectorPyImp.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Base/VectorPy.xml b/src/Base/VectorPy.xml index 6286e4b27..81cd9b005 100644 --- a/src/Base/VectorPy.xml +++ b/src/Base/VectorPy.xml @@ -88,6 +88,14 @@ + + + + distanceToPoint(Vector) + returns the distance to another point + + + distanceToLine(Vector,Vector) diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index 4a1bae849..830ec386e 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -380,6 +380,20 @@ PyObject* VectorPy::projectToPlane(PyObject *args) return Py::new_reference_to(this); } +PyObject* VectorPy::distanceToPoint(PyObject *args) +{ + PyObject *pnt; + if (!PyArg_ParseTuple(args, "O!",&(VectorPy::Type),&pnt)) + return 0; + + VectorPy* base_vec = static_cast(pnt); + VectorPy::PointerType this_ptr = reinterpret_cast(_pcTwinPointer); + VectorPy::PointerType base_ptr = reinterpret_cast(base_vec->_pcTwinPointer); + + Py::Float dist(Base::Distance(*this_ptr, *base_ptr)); + return Py::new_reference_to(dist); +} + PyObject* VectorPy::distanceToLine(PyObject *args) { PyObject *base, *line;