Add distanceToPoint to VectorPy

This commit is contained in:
wmayer 2013-07-17 16:41:09 +02:00
parent 8cbcc06865
commit a882476c25
2 changed files with 22 additions and 0 deletions

View File

@ -88,6 +88,14 @@
</UserDocu>
</Documentation>
</Methode>
<Methode Name="distanceToPoint" Const="true">
<Documentation>
<UserDocu>
distanceToPoint(Vector)
returns the distance to another point
</UserDocu>
</Documentation>
</Methode>
<Methode Name="distanceToLine" Const="true">
<Documentation>
<UserDocu>distanceToLine(Vector,Vector)

View File

@ -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<VectorPy*>(pnt);
VectorPy::PointerType this_ptr = reinterpret_cast<VectorPy::PointerType>(_pcTwinPointer);
VectorPy::PointerType base_ptr = reinterpret_cast<VectorPy::PointerType>(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;