diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index 3db1aa1f52..60612eebae 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -227,6 +227,25 @@ bool Vector3::IsEqual(const Vector3& rclPnt, float_type return Distance(*this, rclPnt) <= tol; } +template +bool Vector3::IsParallel(const Vector3& rclPnt, float_type tol) const +{ + Vector3 v1 = *this; + Vector3 v2 = rclPnt; + double dot = abs(v1 * v2); + double mag = v1.Length() * v2.Length(); + return (abs(dot - mag) < tol); +} + +template +bool Vector3::IsNormal(const Vector3& rclPnt, float_type tol) const +{ + Vector3 v1 = *this; + Vector3 v2 = rclPnt; + double dot = abs(v1 * v2); + return (dot < tol); +} + template Vector3& Vector3::ProjectToPlane(const Vector3& rclBase, const Vector3& rclNorm) diff --git a/src/Base/Vector3D.h b/src/Base/Vector3D.h index 03ca928e37..285ec9ed95 100644 --- a/src/Base/Vector3D.h +++ b/src/Base/Vector3D.h @@ -210,6 +210,10 @@ public: * equal. */ bool IsEqual(const Vector3& rclPnt, float_type tol) const; + /// Returns true if two vectors are parallel within the tol + bool IsParallel(const Vector3& rclPnt, float_type tol) const; + /// Returns true if two vectors are normal within the tol + bool IsNormal(const Vector3& rclPnt, float_type tol) const; /// Projects this point onto the plane given by the base \a rclBase and the normal \a rclNorm. Vector3& ProjectToPlane(const Vector3& rclBase, const Vector3& rclNorm); /**