Skip to content

Commit

Permalink
vec.h: fix incorrect quaternion normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom94 committed Jan 31, 2024
1 parent a8aed0d commit 235d1fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/tiny-cuda-nn/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ template <typename T> TCNN_HOST_DEVICE tquat<T> operator*(const tquat<T>& a, T b
template <typename T> TCNN_HOST_DEVICE tquat<T> operator/(const tquat<T>& a, T b) { return {a.w / b, a.x / b, a.y / b, a.z / b}; }

template <typename T> TCNN_HOST_DEVICE T dot(const tquat<T>& a, const tquat<T>& b) { return (a.w * b.w + a.x * b.x) + (a.y * b.y + a.z * b.z); }
template <typename T> TCNN_HOST_DEVICE T length2(const tquat<T>& a) { return sqrt(dot(a, a)); }
template <typename T> TCNN_HOST_DEVICE T length2(const tquat<T>& a) { return dot(a, a); }
template <typename T> TCNN_HOST_DEVICE T length(const tquat<T>& a) { return sqrt(length2(a)); }

template <typename T> TCNN_HOST_DEVICE tquat<T> mix(const tquat<T>& a, const tquat<T>& b, T t) { return a * ((T)1 - t) + b * t; }
Expand Down Expand Up @@ -1183,7 +1183,7 @@ TCNN_HOST_DEVICE tmat<T, 3, 3> to_mat3(const tquat<T>& q) {

template <typename T>
TCNN_HOST_DEVICE tmat<T, 3, 3> slerp(const tmat<T, 3, 3>& a, const tmat<T, 3, 3>& b, float t) {
return to_mat3(slerp(tquat<T>(a), tquat<T>(b), t));
return to_mat3(normalize(slerp(normalize(tquat<T>(a)), normalize(tquat<T>(b)), t)));
}

template <typename T>
Expand Down

0 comments on commit 235d1fd

Please sign in to comment.