mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Fixed error: comparing floating point with == or != is unsafe
This commit is contained in:
parent
21d030ad3d
commit
3e364981e8
@ -18,6 +18,7 @@
|
|||||||
#include "../mat4x4.hpp"
|
#include "../mat4x4.hpp"
|
||||||
#include "../vec3.hpp"
|
#include "../vec3.hpp"
|
||||||
#include "../vec4.hpp"
|
#include "../vec4.hpp"
|
||||||
|
#include "../ext/vector_relational.hpp"
|
||||||
#include "../gtc/constants.hpp"
|
#include "../gtc/constants.hpp"
|
||||||
#include "../gtc/matrix_transform.hpp"
|
#include "../gtc/matrix_transform.hpp"
|
||||||
|
|
||||||
|
@ -603,13 +603,13 @@ namespace detail
|
|||||||
GLM_FUNC_QUALIFIER T pitch(tquat<T, Q> const& q)
|
GLM_FUNC_QUALIFIER T pitch(tquat<T, Q> const& q)
|
||||||
{
|
{
|
||||||
//return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
//return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||||
const T y = static_cast<T>(2) * (q.y * q.z + q.w * q.x);
|
T const y = static_cast<T>(2) * (q.y * q.z + q.w * q.x);
|
||||||
const T x = q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z;
|
T const x = q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z;
|
||||||
|
|
||||||
if(detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(y, static_cast<T>(0)) && detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(x, static_cast<T>(0))) //avoid atan2(0,0) - handle singularity - Matiis
|
if(all(equal(vec<2, T, Q>(x, y), vec<2, T, Q>(0), epsilon<T>()))) //avoid atan2(0,0) - handle singularity - Matiis
|
||||||
return static_cast<T>(static_cast<T>(2) * atan(q.x,q.w));
|
return static_cast<T>(static_cast<T>(2) * atan(q.x, q.w));
|
||||||
|
|
||||||
return static_cast<T>(atan(y,x));
|
return static_cast<T>(atan(y, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
|
@ -10,8 +10,8 @@ static int test_vec1_operators()
|
|||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
glm::ivec1 A(1.0f);
|
glm::ivec1 A(1);
|
||||||
glm::ivec1 B(1.0f);
|
glm::ivec1 B(1);
|
||||||
{
|
{
|
||||||
bool R = A != B;
|
bool R = A != B;
|
||||||
bool S = A == B;
|
bool S = A == B;
|
||||||
|
Loading…
Reference in New Issue
Block a user