Skip to content

Commit

Permalink
Merge pull request g-truc#1079 from BramblePie/Change_orientedAngle_f…
Browse files Browse the repository at this point in the history
…unction

Change orientedAngle function g-truc#1079
  • Loading branch information
christophe-lunarg committed Jul 15, 2021
2 parents f0066a2 + 90e8522 commit 2759cec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions glm/gtx/vector_angle.inl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ namespace glm
return acos(clamp(dot(x, y), T(-1), T(1)));
}

//! \todo epsilon is hard coded to 0.01
template<typename T, qualifier Q>
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");
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;
else
return -Angle;
Expand Down

0 comments on commit 2759cec

Please sign in to comment.