remove sleep calls, change some for loops to list comp, move isPointOnLine to base vector
This commit is contained in:
@@ -192,6 +192,26 @@ Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct)
|
||||
return cVctRes;
|
||||
}
|
||||
|
||||
template <class _Precision>
|
||||
bool Vector3<_Precision>::IsOnLine (const Vector3<_Precision>& startVct, const Vector3<_Precision>& endVct) const
|
||||
{
|
||||
Vector3<_Precision> vectorAB = endVct - startVct;
|
||||
Vector3<_Precision> vectorAC = *this - startVct;
|
||||
Vector3<_Precision> crossproduct = vectorAB.Cross(vectorAC);
|
||||
_Precision dotproduct = vectorAB.Dot(vectorAC);
|
||||
|
||||
if (crossproduct.Length() > traits_type::epsilon())
|
||||
return false;
|
||||
|
||||
if (dotproduct < 0)
|
||||
return false;
|
||||
|
||||
if (dotproduct > vectorAB.Length() * vectorAB.Length())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Precision>
|
||||
bool Vector3<_Precision>::operator != (const Vector3<_Precision>& rcVct) const
|
||||
{
|
||||
|
||||
@@ -133,6 +133,9 @@ public:
|
||||
bool operator == (const Vector3<_Precision>& rcVct) const;
|
||||
//@}
|
||||
|
||||
/// Check if Vector is on a line
|
||||
bool IsOnLine (const Vector3<_Precision>& startVct, const Vector3<_Precision>& endVct) const;
|
||||
|
||||
/** @name Modification */
|
||||
//@{
|
||||
void ScaleX (_Precision f);
|
||||
|
||||
@@ -74,6 +74,13 @@
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="isOnLine" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>isOnLine(Vector, Vector)
|
||||
checks if Vector is on a line
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getAngle" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>getAngle(Vector)
|
||||
|
||||
@@ -435,6 +435,32 @@ PyObject* VectorPy::cross(PyObject *args)
|
||||
return new VectorPy(v);
|
||||
}
|
||||
|
||||
PyObject* VectorPy::isOnLine(PyObject *args)
|
||||
{
|
||||
PyObject *start, *end;
|
||||
if (!PyArg_ParseTuple(args, "OO",&start, &end))
|
||||
return 0;
|
||||
if (!PyObject_TypeCheck(start, &(VectorPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "First arg must be Vector");
|
||||
return 0;
|
||||
}
|
||||
if (!PyObject_TypeCheck(end, &(VectorPy::Type))) {
|
||||
PyErr_SetString(PyExc_TypeError, "Second arg must be Vector");
|
||||
return 0;
|
||||
}
|
||||
|
||||
VectorPy* start_vec = static_cast<VectorPy*>(start);
|
||||
VectorPy* end_vec = static_cast<VectorPy*>(end);
|
||||
|
||||
VectorPy::PointerType this_ptr = reinterpret_cast<VectorPy::PointerType>(_pcTwinPointer);
|
||||
VectorPy::PointerType start_ptr = reinterpret_cast<VectorPy::PointerType>(start_vec->_pcTwinPointer);
|
||||
VectorPy::PointerType end_ptr = reinterpret_cast<VectorPy::PointerType>(end_vec->_pcTwinPointer);
|
||||
|
||||
Py::Boolean result = this_ptr->IsOnLine(*start_ptr, *end_ptr);
|
||||
|
||||
return Py::new_reference_to(result);
|
||||
}
|
||||
|
||||
PyObject* VectorPy::getAngle(PyObject *args)
|
||||
{
|
||||
PyObject *obj;
|
||||
|
||||
Reference in New Issue
Block a user