[TD] extend App.Vector API

This commit is contained in:
edi271
2024-01-11 20:43:22 +01:00
committed by WandererFan
parent a01220180f
commit 4e22e42410
2 changed files with 29 additions and 4 deletions

View File

@@ -154,6 +154,17 @@ tol : float</UserDocu>
Checks if this vector and `vector2` are
parallel less or equal to the given tolerance.
vector2 : Base.Vector
tol : float</UserDocu>
</Documentation>
</Methode>
<Methode Name="isNormal" Const="true">
<Documentation>
<UserDocu>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</UserDocu>
</Documentation>

View File

@@ -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<VectorPy*>(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;