Add areCollinear overload for three points

This commit is contained in:
Jesse Talavera-Greenberg 2015-10-01 19:44:56 -04:00
parent e6426d5820
commit 4b9b39f1db
2 changed files with 19 additions and 1 deletions

View file

@ -44,6 +44,8 @@
// Dependency:
#include "../glm.hpp"
#include "../gtx/area.hpp"
#include "../gtc/epsilon.hpp"
#include "../gtc/constants.hpp"
#include <cfloat>
#include <limits>
@ -60,7 +62,12 @@ namespace glm
/// @see gtx_vector_query extensions.
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL bool areCollinear(vecType<T, P> const & v0, vecType<T, P> const & v1, T const & epsilon);
//! Returns true if the three given points are collinear.
/// @see gtx_vector_query extensions
template<typename T, precision P = defaultp>
GLM_FUNC_DECL bool areCollinear(tvec2<T, P> const& a, tvec2<T, P> const& b, tvec2<T, P> const& c);
//! Check whether two vectors are orthogonals.
/// @see gtx_vector_query extensions.
template <typename T, precision P, template <typename, precision> class vecType>

View file

@ -119,6 +119,17 @@ namespace detail
return detail::compute_areCollinear<T, P, vecType>::call(v0, v1, epsilon);
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER bool areCollinear
(
tvec2<T, P> const& a,
tvec2<T, P> const& b,
tvec2<T, P> const& c
)
{
return epsilonEqual(detail::area2(a, b, c), 0.0f, epsilon<float>());
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool areOrthogonal
(