mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Merge pull request #1038 from EZForever/patch-angle
fix: glm::angle() discards the sign of result for angles in range (2*pi-1, 2*pi) #1038
This commit is contained in:
commit
f52f232f59
@ -7,7 +7,10 @@ namespace glm
|
||||
{
|
||||
if (abs(x.w) > cos_one_over_two<T>())
|
||||
{
|
||||
return asin(sqrt(x.x * x.x + x.y * x.y + x.z * x.z)) * static_cast<T>(2);
|
||||
T const a = asin(sqrt(x.x * x.x + x.y * x.y + x.z * x.z)) * static_cast<T>(2);
|
||||
if(x.w < static_cast<T>(0))
|
||||
return pi<T>() * static_cast<T>(2) - a;
|
||||
return a;
|
||||
}
|
||||
|
||||
return acos(x.w) * static_cast<T>(2);
|
||||
|
@ -21,6 +21,12 @@ static int test_angle()
|
||||
Error += glm::equal(A, 90.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::quat const Q = glm::angleAxis(glm::two_pi<float>() - 1.0f, glm::vec3(1, 0, 0));
|
||||
float const A = glm::angle(Q);
|
||||
Error += glm::equal(A, 1.0f, Epsilon) ? 1 : 0;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user