mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 19:34:36 +00:00
Merge pull request #1079 from BramblePie/Change_orientedAngle_function
Change orientedAngle function #1079
This commit is contained in:
commit
2759ceca04
@ -20,14 +20,15 @@ namespace glm
|
|||||||
return acos(clamp(dot(x, y), T(-1), T(1)));
|
return acos(clamp(dot(x, y), T(-1), T(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \todo epsilon is hard coded to 0.01
|
|
||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER T orientedAngle(vec<2, T, Q> const& x, vec<2, T, Q> const& y)
|
GLM_FUNC_QUALIFIER T orientedAngle(vec<2, T, Q> const& x, vec<2, T, Q> const& y)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'orientedAngle' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'orientedAngle' only accept floating-point inputs");
|
||||||
T const Angle(acos(clamp(dot(x, y), T(-1), T(1))));
|
T const Angle(acos(clamp(dot(x, y), T(-1), T(1))));
|
||||||
|
|
||||||
if(all(epsilonEqual(y, glm::rotate(x, Angle), T(0.0001))))
|
T const partialCross = x.x * y.y - y.x * x.y;
|
||||||
|
|
||||||
|
if (partialCross > T(0))
|
||||||
return Angle;
|
return Angle;
|
||||||
else
|
else
|
||||||
return -Angle;
|
return -Angle;
|
||||||
|
Loading…
Reference in New Issue
Block a user