move isNaN() to shared utils

This commit is contained in:
ZappoMan 2014-04-13 19:09:07 -07:00
parent dfd6411a4f
commit a37921c1d5
3 changed files with 29 additions and 5 deletions

View file

@ -424,10 +424,6 @@ bool ViewFrustum::matches(const ViewFrustum& compareTo, bool debug) const {
return result;
}
bool isNaN(float f) {
return f != f;
}
bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const {
// Compute distance between the two positions
@ -449,7 +445,7 @@ bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const
float angleEyeOffsetOrientation = compareTo._eyeOffsetOrientation == _eyeOffsetOrientation
? 0.0f : glm::degrees(glm::angle(dQEyeOffsetOrientation));
if (isNaN(angleEyeOffsetOrientation)) {
angleOrientation = 0.0f;
angleEyeOffsetOrientation = 0.0f;
}
bool result =

View file

@ -661,3 +661,22 @@ glm::vec3 safeEulerAngles(const glm::quat& q) {
}
}
bool isNaN(float f) {
return f != f;
}
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) {
// Compute the angular distance between the two orientations
float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB)));
if (isNaN(angleOrientation)) {
angleOrientation = 0.0f;
}
return (angleOrientation <= similarEnough);
}
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) {
// Compute the distance between the two points
float positionDistance = glm::distance(positionA, positionB);
return (positionDistance <= similarEnough);
}

View file

@ -168,4 +168,13 @@ int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm
/// \return vec3 with euler angles in radians
glm::vec3 safeEulerAngles(const glm::quat& q);
/// \return bool are two orientations similar to each other
const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction
bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB,
float similarEnough = ORIENTATION_SIMILAR_ENOUGH);
const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH);
bool isNaN(float f);
#endif /* defined(__hifi__SharedUtil__) */