diff --git a/src/Base/VectorPy.xml b/src/Base/VectorPy.xml index 1dfa45cfe9..e73a6af3ae 100644 --- a/src/Base/VectorPy.xml +++ b/src/Base/VectorPy.xml @@ -154,6 +154,17 @@ tol : float Checks if this vector and `vector2` are parallel less or equal to the given tolerance. +vector2 : Base.Vector +tol : float + + + + + isNormal(vector2, tol=0) -> bool + +Checks if this vector and `vector2` are +normal less or equal to the given tolerance. + vector2 : Base.Vector tol : float diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index 80655e1429..10729f32dd 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -390,13 +390,27 @@ PyObject* VectorPy::isParallel(PyObject* args) VectorPy::PointerType v1_ptr = getVectorPtr(); VectorPy::PointerType v2_ptr = vec->getVectorPtr(); - double dot = abs((*v1_ptr)*(*v2_ptr)); - double mag = v1_ptr->Length()*v2_ptr->Length(); - - Py::Boolean parallel(abs(dot-mag) < tolerance); + Py::Boolean parallel((*v1_ptr).IsParallel(*v2_ptr, tolerance)); return Py::new_reference_to(parallel); } +PyObject* VectorPy::isNormal(PyObject* args) +{ + PyObject* obj = nullptr; + double tolerance = 0; + if (!PyArg_ParseTuple(args, "O!d", &(VectorPy::Type), &obj, &tolerance)) { + return nullptr; + } + + VectorPy* vec = static_cast(obj); + + VectorPy::PointerType v1_ptr = getVectorPtr(); + VectorPy::PointerType v2_ptr = vec->getVectorPtr(); + + Py::Boolean normal((*v1_ptr).IsNormal(*v2_ptr, tolerance)); + return Py::new_reference_to(normal); +} + PyObject* VectorPy::scale(PyObject* args) { double factorX = 0.0;