Quaternion Quaternion::LookRotation(const Vector3 & aLookDirection, const Vector3 & aDesiredUp) { glm::quat quat1 = RotationBetween(Vector3::Forward(), aLookDirection).Raw(); glm::vec3 desiredUp = aDesiredUp.Raw(); glm::vec3 right = glm::cross(aLookDirection, desiredUp); desiredUp = glm::cross(right, aLookDirection); glm::vec3 newUp = quat1 * Vector3::Up().Raw(); glm::quat quat2 = RotationBetween(newUp, desiredUp); return quat2 * quat1; }
static void ApplySnapRotation(TransInfo *t, float *value) { float point[3]; getSnapPoint(t, point); float dist = RotationBetween(t, t->tsnap.snapTarget, point); *value = dist; }